0

I know it's a very much known issue. I have tried almost everything but couldn't fix yet.

Intent is to create a blog using php/wordpress with already existing nginx as web server. Nginx is already being used as a web server to a Rails app.

Here's what my nginx.conf looks like

user  centos;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    passenger_root /home/centos/.rvm/gems/ruby-2.1.4@tripshelf/gems/passenger-5.1.2;
    passenger_ruby /home/centos/.rvm/gems/ruby-2.1.4@tripshelf/wrappers/ruby;

    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    rails_env staging;

    server {
        listen       80;

        server_name  xx.xxx.xxx.xx;
        location / {
            root   /data/staging-tiger/current/public/;
            passenger_enabled on;
            index index.html index.htm;
        }

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

        location ~ \.php$ {
           root           /data/blog/;
           index          index.php index.html index.htm;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }
    }
}

I followed digital ocean's tutorial on how to install LEMP stack.

After installation, when I hit http://example.com/info.php I get

 No input file specified 

On further research, I tried:

  1. Setting the right permissions to document root - /data/blog with proper execute permissions to /, /data, /data/blog and /data/blog/info.php

  2. php location block has its own index and root directives.

  3. Nginx is running as centos user. Here's the output of ps aux | grep nginx

root 11510 0.0 0.1 53984 1320 ? Ss 07:06 0:00 nginx: master process /opt/nginx/sbin/nginx

centos 11513 0.0 0.2 54364 2612 ? S 07:06 0:00 nginx: worker process

centos 13471 0.0 0.0 103312 876 pts/1 S+ 07:42 0:00 grep nginx

  1. User and Group are set to centos in /etc/php-fpm.d/www.conf file.

    user = centos

    group = centos

  2. Running stat on Document root shows

File: /data/blog/info.php

Size: 20  Blocks: 8 IO Block: 4096   regular file
Device: ca01h/51713d Inode: 525709   Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/  centos)   Gid: (  500/  centos)
Access: 2017-10-19 16:47:54.528000890 +0000
Modify: 2017-10-19 16:47:54.528000890 +0000
Change: 2017-10-20 06:18:28.000001084 +0000

I have been wrapping my head around this but no breakthrough so far. Please help.

Thanks in advance

1 Answer 1

1

The guide followed wasn't for WordPress, so the nginx config is probably a little off.

Try amending the PHP block, notice the added fastcgi_param lines.

location ~ \.php$ {
    root           /data/blog/;
    index          index.php index.html index.htm;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;

    fastcgi_split_path_info       ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

If that fails, there might be something you can use from either https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

Or the more detailed https://codex.wordpress.org/Nginx

Also, it should be generating the errors in the nginx log file.

clear && tail -f /var/log/nginx/error.log
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.