|⇐ Back||Page||Next ⇒|
PHP (Hypertext Preprocessor – a recursive backronym) is a server-side scripting language, coded as a mix of HTML, or in combination with various templating engines and web frameworks. PHP code is usually implemented as a Common Gateway Interface (CGI) executable, and the resulting output is then sent to the client in form of a generated web page.
The following PHP components will be required:
- FastCGI Process Manager
- Client URL Library
- GD Image Library
- MySQL Library
- Alternative PHP Cache
- SSH2 Library
- Change to the root of the user’s home directory, using the following command:
- To install the required PHP components, use the following package install command:
sudo apt-get install php5-fpm php5-curl php5-gd php5-mysql php-apc libssh2-php -y
- Once installed, Nginx must be configured to serve dynamic PHP content. The following Nginx configuration file will be used to service WordPress:
- Download this Nginx configuration file directly from GitHub, using the following command:
- Use the nano text editor to modify the downloaded configuration file, using the following command:
- Locate the line that appears as follows:
- Add the name of your server or domain:
server_name example.com *.example.com;
- Press Ctrl+X to exit nano, press Y to save changes when prompted, and press Enter to accept the default filename.
- Replace the existing default Nginx configuration file with the one downloaded from GitHub, using the following command:
sudo mv raw /etc/nginx/sites-available/default
- Restart the Nginx and PHP services, using the following commands:
sudo systemctl restart nginx && sudo systemctl restart php5-fpm
- Verify the status of the PHP service, using the following command:
systemctl status php5-fpm
The command will produce output similar to the following:
● php5-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php5-fpm.service; enabled) Active: active (running) since Sun 2016-04-25 12:02:45 UTC; 45s ago Main PID: 9059 (php5-fpm) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec" CGroup: /system.slice/php5-fpm.service ├─9059 php-fpm: master process (/etc/php5/fpm/php-fpm.conf) ├─9061 php-fpm: pool www └─9062 php-fpm: pool www
- Create a new PHP Information page, using the following commands:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/index.php > /dev/null
- Use a web browser to view your Raspberry Pi’s IP address, and assuming all has gone well, you will see the PHP Information page.
PHP is now installed and running on your Raspberry Pi.
|⇐ Back||Page||Next ⇒|