0

TL;DR Nginx, compiled from source, had trouble process .php files, while with the same PHP-FPM configuration, nginx , from official Fedora repository, worked like a charm on DigitalOcean 512MB Fedora 21 x64 VPS. What is the reason behind it?

I am using DigitalOcean 512MB Droplet with Fedora 21 x64 VPS.

I compiled Nginx from source and installed it in /opt/nginx/. Here's the output of /opt/nginx/nginx -V

nginx version: nginx/1.7.10
built by gcc 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --sbin-path=/opt/nginx --without-http_autoindex_module --without-http_browser_module --without-http_empty_gif_module --without-http_geo_module --without-http_map_module --without-http_referer_module --without-http_scgi_module --without-http_split_clients_module --without-http_ssi_module --without-http_userid_module --without-http_uwsgi_module --with-http_gzip_static_module --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-openssl=openssl --with-pcre=pcre --with-zlib=zlib --with-ipv6

Till now, I was using it to serve only static pages. Today, I installed php-fpm from official Fedora repository and configured nginx (the one that I compiled from source with the above given configuration) to pass .php pages to PHP-FPM via unix sockets.

Unfortunately, I received the No input file specified error. I've previously faced this issue, so I knew what to do. I quickly changed the file permission but it still received the same error.

After searching for hours and trying every possible solution, I was still receiving the same error. I found this thread to be sharing somewhat same issue.

I thought why not give Nginx from offical Fedora repository a try. I installed it. Stopped the previous nginx (compiled from source) with /opt/nginx/nginx -s stop and configured the new nginx (from official Fedora repository) to pass .php to PHP-FPM to the same unix sockets.

And it worked.

My question is "Why did nginx (compiled from source) had trouble processing php while nginx, from official Fedora repository, worked like charm?". Could this be SELinux?

EDIT: More information about my setup.

Nginx (compiled from source)

  • Installed in /opt/nginx/
  • Serves web content from /srv

Nginx (from official Fedora repository)

  • Default installation, usually /usr/sbin/nginx
  • Serves content from /usr/share/nginx/html/
6
  • misconfiguration of php-fpm – alexus Feb 26 '15 at 17:34
  • No @alexus. I've confirmed it. Configuration is all OK. The same configuration works in my local server. – user213598 Feb 26 '15 at 17:37
  • well obviously not, as you're getting No input file specified and that's very common mistake pointing to misconfiguration of php-fpm. – alexus Feb 26 '15 at 17:38
  • You are right. "No input file specified" is very common error. But the same PHP-FPM configuration works with the nginx from official Fedora repository but not with the nginx that I have compiled from source. – user213598 Feb 26 '15 at 17:40
  • Check your logs. – Michael Hampton Feb 26 '15 at 17:49
0

Solved it finally.

SELinux was forbidding PHP-FPM from accessing the file since web content was served from /srv.

Running the following command

sudo chcon -R -t httpd_sys_content_t /srv/

solved the issue.

Thank you everyone for helping.

Reference: https://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy