Installing WordPress on Raspberry Pi

Please share with your friends...
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

⇐ BackPageNext ⇒

php-med-trans PHP

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
  1. Change to the root of the user’s home directory, using the following command:
    cd ~
  2. 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
  3. Once installed, Nginx must be configured to serve dynamic PHP content. The following Nginx configuration file will be used to service WordPress:
  4. Download this Nginx configuration file directly from GitHub, using the following command:
    wget https://gist.github.com/chrisloweau/40f3ef0c9d7471007874e864ead57223/raw
  5. Use the nano text editor to modify the downloaded configuration file, using the following command:
    nano raw
  6. Locate the line that appears as follows:
    server_name _;
  7. Add the name of your server or domain:
    server_name example.com *.example.com;
  8. Press Ctrl+X to exit nano, press Y to save changes when prompted, and press Enter to accept the default filename.
  9. 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
  10. Restart the Nginx and PHP services, using the following commands:
    sudo systemctl restart nginx && sudo systemctl restart php5-fpm
  11. 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
  12. Create a new PHP Information page, using the following commands:
    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/index.php > /dev/null
  13. 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 Information

    PHP Information

PHP is now installed and running on your Raspberry Pi.

⇐ BackPageNext ⇒

Please share with your friends...
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

4 comments

  1. Thanks for this tutorial, Chris. I was just wondering, do you have any tips for helping to “harden” the web server? I guess I’m a tiny bit paranoid and wish to deter would be intruders …

    1. Hi Ben,

      The Nginx configuration is already very lean and should be secure (barring code vulnerabilities – remember to keep Raspbian and WordPress updated!).

      However, you will get lots of bruit-force login attempts though the standard WordPress Log In page. I decided to use a Google Authenticator plugin to enable two-factor authentication.

      Kind Regards,
      Chris.

  2. Excellent tutorial!
    I’m getting blank page with index.php like but not when i remove “!–” to
    What would be the steps to add multi-site subdomain such as – http://www.example.com and wiki.example.com?

    1. Hi idris,

      Thanks for letting me know about the “!–” for the phpinfo() page – that was a bug in my tutoral!! I’ve fixed it up now 🙂

      If you have followed all the steps in the tutorial, you should be setup for multi-site subdomains. You just need to run the configuration.

      The most important steps of the tutorial for WordPress multi-site are:
      PHP step 5 – adding *.example.com to the server_name list; and
      WordPress step 17 – adding the WP_ALLOW_MULTISITE line to wp-config.php.

      This bit is from memory (I need to write a tutorial on this bit too). Log in to the WordPress Dashboard and go to Tools > Network Setup. You should have the option of creating a Subdomain or Subdirectory site install.

      http://codex.wordpress.org/Create_A_Network

      Also, for a Subdomain setup to work, WordPress expects that you have DNS wildcard subdomains setup with your DNS provider.

      Hope that gets you started! 🙂
      Chris

Leave a Reply