We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Unable to get PHP configured using nginx


24x7servermanagement
2016-04-10, 03:46 AM
Quote Originally Posted by Ciriis
So long story short I have registered a new Debian 7 VPS w/ OVH and have been attempting to install nginx w/ PHP and MySQL.
Everything seems to have gone ok, with the exception of the PHP not functioning.

I initially used the following guide:
https://www.digitalocean.com/communi...n-ubuntu-12-04

However, I get the distinct impression something has gone off in this portion:

Code:
[...]
server {
        listen   80;
     
        root /usr/share/nginx/www;
        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                
        }

}
[...]
Add index.php to the index line.
Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)
Change the correct lines in “location ~ \.php$ {“ section <- Unsure what needs to be added or changed.
Save and Exit

Any assistance would be greatly appreciated.

Try to change the code as given below.

---------------------
From :
try_files $uri $uri/ /index.html;

To
try_files $uri $uri/ /index.php;
---------------------


--------------------
From
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

To
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
--------------------

Ciriis
2016-04-05, 06:38 PM
So long story short I have registered a new Debian 7 VPS w/ OVH and have been attempting to install nginx w/ PHP and MySQL.
Everything seems to have gone ok, with the exception of the PHP not functioning.

I initially used the following guide:
https://www.digitalocean.com/communi...n-ubuntu-12-04

However, I get the distinct impression something has gone off in this portion:

Code:
[...]
server {
        listen   80;
     

        root /usr/share/nginx/www;
        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                
        }

}
[...]
Add index.php to the index line.
Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)
Change the correct lines in “location ~ \.php$ {“ section <- Unsure what needs to be added or changed.
Save and Exit

Any assistance would be greatly appreciated.