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 !

step11-1

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)
    ln-s/var/log/nginx/etc/nginx/logs
  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 php-fpm systemctl start nginx
  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...

  • Pen prohibited

    I have a little problem with installing PHP…

    Nginx works very well, but when I have an index.php file, my browser shows "No input file specified '.. », whether it's at the final poster or source code level.

    Would you have an idea or could be the problem?

    I have 3 suspect at the moment, nginx.conf, FastCGI.conf and php - fpm.conf. Unfortunately, I can barely understand files :/

    • Hello,
      First step : Nginx. What if you put an index.html file (which displays a phony gimmick), the HTML page works ?
      2ND stage : php. What is your process runs well (with a ps for example command) ? What is your site's configuration in Nginx on the PHP side ?

      • Pen prohibited

        HTML works perfect.

        I read the man and I receive three PID for php - fpm.

        For PHP in nginx.conf, I stupidly did everything from copy paste:

        server {

        listen 80;

        server_name 192.168.1.25;

        location / {

        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;

        }

        • Here is mine :
          server {
          listen 80;
          server_name localhost;
          location / {
          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;
          }
          error_page 500 502 503 504 /50x.html;
          location = 50x.html {
          root/var/www;
          }
          rental cgi - bin /. {
          fastcgi_pass unix:/var/run/fcgiwrap.sock;
          include cgi_fastcgi_params;
          }
          rental /RPC2 {
          scgi_pass unix:/Home/rtorrent/SCGI.Socket;
          include scgi_params;
          }
          }

          CGI - bin and RPC2 are not useful for PHP

  • Gregory

    Hello,

    I am your site with great interest for a while already. I must admit that it was a great help to apprehend the shell and to deploy me a small home server.

    On the other hand, having a small preference for archlinux and wishing to have owncloud, I've never managed to combine the 2…. I tried to make a mix of several present tutorial on this site, without much success…. There is no longer any website that deals with the manipulation (except using apache, I tried, but it is extremely heavy and slow). Have you managed to install archlinux-nginx-owncloud trio on one of your raspberry ? If Yes, How (installation of a non-php extension of origin ?) ?

    Nice day

    Gregory

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop