Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Great tutorial. However I experienced problems with php files, for I received a 404 error everytime I tried to access my phpinfo.php file.
- The root directory is /usr/share/nginx/html, BUT don't be fooled for having declared the index.php in the index line. That root directory is for static content. I spent like 2 hours literally going crazy because when you see a 404 error you might think Nginx is getting the root directory from another one... but in my case I edited the index.html and it got affected, so Nginx was indeed targeting that root directory.
- Checking the error log file I see that for php files (I still don't know why)
- What I did, according to my personal needs, was use the same root for all. I just stated it once at the server level and it'll be inherited by all the locations.
- Here's my default.conf file:
- server {
- listen 80;
- server_name www.alemany.me;
- #charset koi8-r;
- access_log /var/log/nginx/alemany.access.log main;
- error_log /var/log/nginx/alemany.error.log;
- root /usr/share/nginx/html;
- index index.php index.html index.htm;
- error_page 404 /404.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- location ~ \.php$ {
- try_files $uri =404;
- include fastcgi_params;
- fastcgi_pass unix:/var/run/php-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- }
- }
- I'm not being redundant here. I might be jumping a couple of things here.
- Anyway, this is how I worked around this and it's up and running right now.
- Best regards.
- HeartedHeart
- 0
- damijanc
- damijanc March 18, 2015
- Did you check file access permissions. You need read permissions. This is typical error.
- HeartedHeart
- 0
- alainalemany
- alainalemany March 18, 2015
- I don't think that was the problem. Everytime I tried to access my index.php and got the 404 error, I checked in the logs and by unknown reasons Nginx was looking for the php file in /etc/nginx/html/index.php as you can see below:
- 2015/03/18 09:37:13 [error] 13192#0: *1 FastCGI sent in stderr: "Unable to open primary script: /etc/nginx/html/index.php (No such file or directory)" while reading response header from upstream, client: 200.55.154.30, server: www.alemany.me, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.alemany.me"
- I worked around this as I mention previously. If there's a more orthodoxe way, please share it with me.
- HeartedHeart
- 0
- damijanc
- damijanc March 18, 2015
- One more thing.
- you root is pointing to
- root /usr/share/nginx/html
- You should change this if you want it to point somewhere else.
- HeartedHeart
- 0
- akef
- akef March 23, 2015
- work foot
- thank you
- HeartedHeart
- 0
- sthiina
- sthiina April 22, 2015
- sudo vi /etc/php-fpm.d/www.conf
- im not having above path. pleae help.
- HeartedHeart
- 0
- dmgap
- dmgap July 3, 2015
- Maybe you do not install php-fpm yet?Or you can find it in whole etc path like:
- sudo find /etc -name "www.conf"
- HeartedHeart
- 0
- saw
- saw August 30, 2015
- Hi, I got some issues start from step four: Configure Nginx to Process PHP Pages
- After I typed this $ sudo vi /etc/nginx/conf.d/default.conf. I can't find
- ```server {
- listen 80;
- server_name localhost;
- location / {
- root /usr/share/nginx/html;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- }```
- ..to make an edit. It just showing me as a blank. Here's the screencast
- I sent a ticket to windows.nginx.apache.kvm.www.digitaloceandatacenters.info Support, they told me to force go on but I can't put this <?php phpinfo(); ?> in the file at** step five**.
- Guys, help me!
- HeartedHeart
- 0
- 0b7a770b9860b33000e31b870e815b33355f8459
- NearlyNormal September 5, 2015
- I installed this way, and it only installed php 5.4. When I upgraded to php 5.6 with "yum install php56w-common"....etc, now Nginx and php-fpm are not linked to each other.
- The default php56w* does not seem to install the php-fpm at this location:
- /var/run/php-fpm/php-fpm.sock
- What should be the path? Do I need to change it in /etc/php-fpm.conf or something?
- HeartedHeart
- 0
- 0b7a770b9860b33000e31b870e815b33355f8459
- NearlyNormal September 5, 2015
- Any PHP from Nginx is giving me 502 bad gateway error.
- My /etc/php-fpm.conf file has the following:
- pid = /var/run/php-fpm/php-fpm.sock
- Should I leave that as the default "pid = /var/run/php-fpm/php-fpm.pid" instead? What' the difference between sock and pid?
- HeartedHeart
- 0
- iamkingsleyf
- iamkingsleyf October 1, 2015
- Thanks but how do I create virtual host for my wordpress sites?
- HeartedHeart
- 0
- fixwen
- fixwen October 31, 2015
- hello , i had some problems,
- I install the php5.6 but the nginx cannot work with it,how to config the php5.6 and make it work with nginx
- centos7 + php5.6 + nginx
- HeartedHeart
- 0
- djtthompson
- djtthompson November 9, 2015
- Centos 7 users: http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied
- HeartedHeart
- 0
- geo.sukarno
- geo.sukarno December 21, 2015
- Thanks for you comprehensive tutorial.
- My web server is up and running, but cannot process the php script.
- Every time i open http://geosukarno.com/info.php , the info.php always served as download file.
- You can see my Nginx's /etc/nginx/conf.d/default.conf at this txt file:
- http://geosukarno.com/nginx__default.conf.txt
- I tried: systemctl restart nginx
- and: systemctl restart php-fpm
- didn't help.
- Is somebody can help me, what i'm miss, that php script cannot be processed?
- HeartedHeart
- 0
- geo.sukarno
- geo.sukarno December 22, 2015
- I think i miss something.
- 8 hours until 6 hours ago, after i tried using SSL (http://www.server-world.info/en/note?os=CentOS_7&p=nginx&f=4), i tried some troubleshooting, such as restart the droplets, make sure the nginx's default.conf as same as tutorial's , still nginx cannot process the php script.
- I always tried call info.php on https protocol (http://geosukarno.com/info.php), still nginx didn't process the php script.
- Now after 8 hour, i accidently call info.php on http protocol, and it's work. Nginx can process the php script.
- This 8 hours long, i didn't realize nginx already can process the php script, but on http protocol.
- So, another problem still not solved yet.
- Why nginx cannot process php script when it called on https protocol?
- Every time i open http://geosukarno.com/info.php , the info.php always served as download file.
- I made SSL certificate by following tutorial from server-world.info
- http://www.server-world.info/en/note?os=CentOS_7&p=nginx&f=4
- HeartedHeart
- 0
- geo.sukarno
- geo.sukarno December 22, 2015
- Now i know why nginx didn't process php script on http protocol.
- Because at early time, in nginx's /etc/nginx/conf.d/default.conf , i'm using wrong servername.
- I was using servername gitu;
- gitu is my hostname.
- But my domain for this droplet is geosukarno.com
- Thats why nginx didn't process the php script on http protocol.
- You can see my first Nginx's /etc/nginx/conf.d/default.conf that made nginx cannot process php script on http protocol at this txt file:
- http://geosukarno.com/nginx1default.conf.txt
- http://geosukarno.com/nginx1default.conf.txt
- But until now, nginx still cannot process php script on https protocol.
- HeartedHeart
- 0
- geo.sukarno
- geo.sukarno December 22, 2015
- [deleted]
- HeartedHeart
- 0
- geo.sukarno
- geo.sukarno December 22, 2015
- I found why php script cannot be processed when called with https protocol on my nginx.
- The mistake is,
- regarding to server-world.info's tutorial
- (http://www.server-world.info/en/note?os=CentOS_7&p=nginx&f=4)
- i put these 3 statements in /etc/nginx/nginx.conf
- listen 443 ssl;
- ssl_certificate /etc/pki/tls/certs/server.crt;
- ssl_certificate_key /etc/pki/tls/certs/server.key;
- Regarding to this tutorial, we using Nginx server block configuration file in
- /etc/nginx/conf.d/default.conf
- Then i move those 3 statements from
- /etc/nginx/nginx.conf
- into
- /etc/nginx/conf.d/default.conf
- You can see my Nginx server block configuration file
- /etc/nginx/conf.d/default.conf
- at
- http://geosukarno.com/nginx3default.conf.txt
- Maybe you wondering what's another statements on my default.conf ?
- Well i got that configuration statements from chrismeller's tutorial:
- http://blog.chrismeller.com/configuring-and-optimizing-php-fpm-and-nginx-on-ubuntu-or-debian
- Now my nginx can process php script on http and https protocol.
- HeartedHeart
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement