Raspberry Pi and Arch Linux – Install Nginx with PHP support

Any server should have its Web server ! 🙂 Aujourd’hui, We will install Nginx on our Arch Linux server !


Reminder : for those who want a comparison of different web servers, You can watch article here.

  1. Install the different packages
    Pacman-s nginx php - fpm php - apc
  2. Create the directory /var/www
    mkdir/var/www chown-r http:http/var/www
  3. Make a link to the logs (I have not found how to jump an error without making the link)
  4. Check the file /etc/php/PHP-fpm.conf pour changer/confirmer le user utilisé par le process et les droits sur le fichier socket
    ; Unix user/group of processes
    ; Note: The user is mandatory. If the group is not set, the default user's group
    ; will be used.
    user = http
    group = http

    ; Set permissions for unix socket, if one is used. In Linux, read/write

    ; permissions must be set in order to allow connections from a web server. Many

    ; BSD-derived systems allow connections regardless of permissions.

    ; Default Values: user and group are set as the running user

    ; mode is set to 0666

    listen.owner = http

    listen.Group = http

    listen.mode = 0660

  5. Edit the file /etc/nginx/nginx.conf
    root /var/www;
    index index.php index.html index.htm;
    location ~ .php$ {
           fastcgi_pass unix:/var/run/PHP-fpm/PHP-fpm.sock;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME/var/www / $fastcgi_script_name;
  6. Change the setting open_basedir in the file /etc/php/PHP.ini by adding the directory /var/www in the list
  7. Enable and start the servers
    systemctl enable php - fpm systemctl enable nginx systemctl start systemctl start nginx php - fpm
  8. Create a file index.php in /var/www with the following content :
    <?PHP phpinfo();

Check by going to the ip of the Raspberry that you have the picture below that appears. Details of the capture is not good, it comes from the Moebius distribution, but the principle remains the same.

Viewing PHP file with Nginx

View a file PHP with Nginx

For the CGI support, I crashes. I installed FastCGI Wrapper (fcgiwrap) but no way to start without an error 403 … I'll try manual compilation and you would like to know !

You may also like...