Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Jul 29, 2013 1:14 pm 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Hello all, this is my first post on this fine forum. :)

Just installed nginx and php fast cgi on my linode. Everything was going fine, nginx seems to be up and running but my domain is not rendering a simple hello world html file on it.

All I get when visiting my site is the standard 'welcome to nginx' message.

On the bash every install went smoothly, I followed all the guides.

Is this a config issue I have to resolve ?

I've just added the server config to:

Code:
/etc/nginx/sites-available/mysite.com


as per the guide. I haven't touched the:

Code:
/etc/nginx/nginx.conf


Top
   
PostPosted: Mon Jul 29, 2013 1:38 pm 
Offline
Senior Member

Joined: Tue Dec 20, 2011 5:17 pm
Posts: 52
Location: Serbia, Europe
Did you reload/restart nginx after adding the server config(s)?


Top
   
PostPosted: Mon Jul 29, 2013 2:49 pm 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
Create a symbolic link in /etc/nginx/sites-enabled and reload nginx :

# cd /etc/nginx/sites-enabled
# ln -s /etc/nginx/sites-available/mysite.com ./
# /etc/init.d/nginx reload

_________________
sleddog


Top
   
PostPosted: Mon Jul 29, 2013 5:08 pm 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Restarting nginx did it, thanks.

Now the html renders, but no luck processing my php. Now to find the cause of this...

Thanks petar & sleddog.


Top
   
PostPosted: Mon Jul 29, 2013 5:18 pm 
Offline
Senior Member
User avatar

Joined: Thu Jun 16, 2011 8:24 am
Posts: 412
Location: Cyberspace
Several things to check:

  1. Is php-fpm running? Check using the command (without quotes): "ps aux | grep fpm"
  2. Does your nginx vhost include index.php as a possible index?
  3. Is your nginx vhost configured with a php location block?
  4. Does your php location block have "include fastcgi_params" or "include fastcgi.conf" without quotes? (look in /etc/nginx to see which one to use)

EDIT: If all of those are true, please paste the vhost file. Make sure click the Code button near the top of the forum's Reply screen, and ensure that the vhost appears between the code tags that appear.

_________________
Kris the Piki Geeker


Top
   
PostPosted: Mon Jul 29, 2013 5:36 pm 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Hi Piki.

Responses:

1. Yes.

2. It includes it under fastcgi_index , not index.

3. Yes.

4. Its has "include fastcgi_params", which is correct I believe.

My virtual host file, where "mysite.com" is my actual domain:

Code:
server {
    server_name www.mysite.com mysite.com;
    access_log /srv/www/mysite.com/logs/access.log;
    error_log /srv/www/mysite.com/logs/error.log;
    root   /srv/www/mysite.com/public_html;

    location / {
        index  index.html index.htm;
    }

    location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/www/mysite.com/public_html$fastcgi_$
    }
}





UPDATE: Now, attempting to restart fast cgi gives me:

spawn-fcgi: bind failed: Address already in use


Top
   
PostPosted: Mon Jul 29, 2013 5:41 pm 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Go it working! It was just a matter of adding the index.php to the location index, not just the location ~ \.php$ fastcgi_index.

Thanks for your time and help.

Now, is that error while attempting a fast cgi restart to be expected ?

The "spawn-fcgi: bind failed: Address already in use" error.


Top
   
PostPosted: Mon Jul 29, 2013 5:54 pm 
Offline
Senior Member
User avatar

Joined: Thu Jun 16, 2011 8:24 am
Posts: 412
Location: Cyberspace
EduardoV5 wrote:
Go it working! It was just a matter of adding the index.php to the location index, not just the location ~ \.php$ fastcgi_index.


That is needed for most cases since fastcgi_index and index are not the same thing. fastcgi_index is specific to cgi wrappers such as fcgi or php-fpm, where index is global to the entire vhost.

EduardoV5 wrote:
Thanks for your time and help.

Now, is that error while attempting a fast cgi restart to be expected ?

The "spawn-fcgi: bind failed: Address already in use" error.


You shouldn't be seeing that error, however I've seen many people report issues with using php directly through fcgi (instead of php-fpm. Far fewer problems seem arise from using php-fpm, so it may be worth switching, if only just to try it and see if it works. Just make sure fcgi isn't running when you start php-fpm.

Quick tip: This isn't really necessary, but it's generally good to keep the index directive outside location blocks. This way, if you decide to place subdirectories in your vhost's root which also contain one of the index options you specify, nginx will automatically use it when visiting the subdirectory.

Better yet, if all your vhosts will use the same index line, place it in your nginx.conf instead, in the http section.

_________________
Kris the Piki Geeker


Top
   
PostPosted: Mon Jul 29, 2013 7:55 pm 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Ok, I'll move the index directive outside, as I'm planning on hosting several sites on this Linode.

Could you point to a guide on installing php-fpm with nginx? I just seem to find fcgi guides on the Linode Library.


Top
   
PostPosted: Mon Jul 29, 2013 7:58 pm 
Offline
Senior Member

Joined: Tue Dec 20, 2011 5:17 pm
Posts: 52
Location: Serbia, Europe
This could be what you are looking for, assuming that you are using Ubuntu. If not, you can most probably find a proper tutorial at the site, lots of good stuff there.


Top
   
PostPosted: Tue Jul 30, 2013 6:37 am 
Offline
Senior Member
User avatar

Joined: Thu Jun 16, 2011 8:24 am
Posts: 412
Location: Cyberspace
Since I don't know your distro, I can't point you to any guides (they tend to be distro-specific). Finding them is relatively easy using Google, search "how to set up nginx and php-fpm on centos" (replace centos with your distro).

Here are some generic instructions, use your distro's package manager to install/remove stuff:

  1. Remove the fcgi package that the Linode Library had you install.
  2. Install php-fpm (it might be called php5-fpm by your distro).
  3. Open the php-fpm config file, locate the listen line, and make sure it's set to 127.0.0.1:9000
  4. Restart both php-fpm and nginx and see if it works.

Finding the php-fpm config file should be easy, just search through the /etc directory. Likely possibilities are /etc/php.ini, /etc/php/php.ini, or /etc/php/php-fpm.conf. Some distros (Debian included) put the listen line in a separate file, e.g. /etc/php/fpm/pool.d/www.conf.

EDIT: If you're using Debian, you may wish to use Dotdeb. They provide slightly newer server packages (Nginx, PHP, etc.) than the official Debian repos, and they work fairly well.

_________________
Kris the Piki Geeker


Top
   
PostPosted: Tue Jul 30, 2013 11:14 am 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
Nice, thorough answers. I appreciate the time given.

If I make the change over to fpm from fcgi, I'll make another thread detailing whether the former produces less errors, or none at all.


Top
   
PostPosted: Tue Jul 30, 2013 11:15 am 
Offline
Senior Newbie

Joined: Mon Jul 29, 2013 1:06 pm
Posts: 9
By the way, my distro is Ubuntu.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group