Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Aug 23, 2011 4:15 am 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
On ubuntu 10.04, I got 99 problems and wordpress w/ nginx, varnish, apc, w3tc, cdn among them.

How do I make php5-fpm work?

I dropped apache. I opted for nginx. I loaded php-fpm. Then, loaded varnish. I grabbed W3 total cache. I haven't installed memcache, apc yet. Site worked.

During the set up, first I followed lemp set up.
http://library.linode.com/lemp-guides/u ... 0.04-lucid
Quote:
apt-get install nginx

then, apt-get install php5-cli php5-cgi psmisc spawn-fcgi


Then, I found cool links. I wanted to squeeze every little ounce of performance on 512.

I used this link
http://danielmiessler.com/blog/optimizi ... -memcached

it had missing elements on the documentation, then I found this one
http://blog.nas-admin.org/?p=25

Those two links are similar in content, and one seemed to fill the gap, where the other lacked.

The site works.

I really didn't get any better performance than apache, except memory and cpu cycles. Then, couple days later, the cpu went up from 10% to 60-70% on nginx. More on that later...

I needed to reboot the server anyhow. At that point, I realized the optimization never worked properly. I only realized this when I needed to reboot the server.

I wanted to go over the links, one more time. I still couldn't make it work.
Either, they are out dated, or missing sections that are obvious but I just dont know where to kick....

instead of listing every issue at once, I want to solve it one at a time.

will you join me solving this problem? I want php5-fpm to work on ubuntu 10.04 with wordpress.

Here we go... PHP5-FPM
after installing apt-get install php5-cli php5-cgi psmisc spawn-fcgi, and adding php-fpm. I realized I really needed php5-fpm. Ubuntu 10.04 doesnt support it.

so, I did a backport, I added php5-fpm to the repo.

repo links
Quote:


then, hit the
http://blog.nas-admin.org/?p=25
Quote:
they are both running on the same server so we are going to adjust the php5-fpm config to use a unix socket instead. Edit the config file located at /etc/php5/fpm/pool.d/www.conf and find the below line

listen = 127.0.0.1:9000

and change it to…

;listen = 127.0.0.1:9000
listen = /var/run/php5-fpm.sock

Now we have php-fpm listening on a unix socket, lets configure nginx. Go to the directory /etc/nginx/conf.d and make a file named php5-fpm.conf and put this in there:

upstream php5-fpm-sock {
server unix:/var/run/php5-fpm.sock;
}


I dont have /etc/php5/fpm/pool.d/www.conf

I have /etc/php5/fpm/php5-fpm.conf

so, I followed those instructions on php5-fpm.conf.
service nginx restart
Code:
Restarting nginx: [emerg]: no port in upstream "php5-fpm-sock" in /etc/nginx/sites-enabled/domain.com:27
configuration file /etc/nginx/nginx.conf test failed

service php5-fpm stop
shutting down php5-fpm warning, no pid file found - php5-fpm is not running ?
service php5-fpm start
Starting php5-fpm  done.... [fail]


there isnt any php5-fpm.sock over at /var/run/... /var/run/php5-fpm.sock ??? where is php5-fpm.sock?

I commented the /etc/nginx/conf.d/php5-fpm.conf file that I created....

then, on /etc/php5/fpm/php5-fpm.conf
instead allowed listen = 127.0.0.1:9000, and commented
;listen = /var/run/php5-fpm.sock

restart nginx...
nginx doesnt give errors anymore. But php5-fpm doesnt work.

How do I make php5-fpm work? Thank you.


Top
   
 Post subject:
PostPosted: Tue Aug 23, 2011 10:55 am 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
bump


Top
   
 Post subject:
PostPosted: Tue Aug 23, 2011 12:14 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
The socket file doesn't exist, because FPM is not running. Fix FPM first, and nginx will work.

If you were playing with spawn-fcgi before you installed FPM, what did you do to spawn-fcgi afterward? Did you make sure to stop it, uninstall it, and remove its init script? It could interfere with FPM if it is configured to use the same port 9000.

EDIT

I would also generally recommend against using PPAs in servers. In particular, FPM packages in Ubuntu 10.04 LTS are so fragmented, it's impossible to figure out which is which. They all seem to keep the config files in different places, too, which makes debugging painful when you mix and match packages and tutorials from different places.

Moreover, since 10.04 is now 16 months old, unofficial packages built for 10.04 are beginning to get rather outdated. PHP gets frequent security updates, so it's very important to use the latest version or stick to your distribution's official repository. If you really wanted FPM, I'd suggest upgrading to Ubuntu 11.04 and installing the official package. It's stable enough, and you'll have plenty of time to move on to 12.04 LTS when it comes out.


Top
   
 Post subject:
PostPosted: Tue Aug 23, 2011 12:37 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
this link helped a lot.
http://tutspundit.com/how-to-install-ng ... ss-part-2/

php5-fpm is working now. I still cant use the socket. It gives errors.

Quote:
If you were playing with spawn-fcgi before you installed FPM, what did you do to spawn-fcgi afterward?

I played with so much, that I dont even remember.

Code:
Did you make sure to stop it, uninstall it, and remove its init script?
It could interfere with FPM if it is configured to use the same port 9000.

It was a port issue.

I am using 10.4, because I figure it is LTS, so it is stable. I do agree with you regarding php, and issues with using unoffical PPAs in servers, and ridiculously fragmented . I figured I will just make sure I can utilize all these combo set ups such as nginx, php5-fpm, varnish, apc, wt3c, etc... then upgrade.


Top
   
 Post subject:
PostPosted: Tue Aug 23, 2011 12:59 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
after fixing the port issue, I tried the php5-fpm.sock again. I used the instructions from here http://blog.nas-admin.org/?p=25

It works. :twisted:

It seems a bit slower, compare to using localhost IP - 127.0.0.1:#.

Maybe I can get it to perform better with a bit tweaking.


Top
   
 Post subject:
PostPosted: Tue Aug 23, 2011 3:13 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
this link is a bit different than other two links on set up
http://tutspundit.com/how-to-install-ng ... ss-part-2/
Code:
on php5-fpm.conf file I had
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
[www]
listen = 127.0.0.1:9001
user = www-data
group = www-data
pm = static
pm.max_children = 10


then on my nginx.conf file
Code:
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
     worker_connections  1024;
#    multi_accept on;
#    accept_mutex_delay 50ms;
}

http {
    include       /etc/nginx/mime.types;
#from linode
default_type  application/octet-stream;
#linode end
    access_log  /var/log/nginx/access.log;
# Miscellanous options danielmiessler start
   sendfile        on;
   tcp_nopush     off;
   keepalive_timeout  30;
   tcp_nodelay        on;
#   expires max;
#server token disables version of nginx
   server_tokens off;

   gzip  on;
   gzip_proxied any;
   gzip_comp_level 2;
   gzip_disable "MSIE [1-6].(?!.*SV1)";
   gzip_types text/plain text/css application/x-javascript text/xml
   application/xml application/xml+rss text/javascript;

#   gzip_vary on;
#
# Virtual Host Configs
##
   client_max_body_size 20M;
   client_body_buffer_size 128k;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}



then, I used this link http://tutspundit.com/how-to-install-ng ... ss-part-2/
moved only to 'worker_processes 4;' and 'worker_connections 4096;'

the site flew nicely.

Then, added on nginx.conf file
Code:
worker_rlimit_nofile 32768;
multi_accept on;
accept_mutex_delay 50ms;
keepalive_timeout  65;
gzip_vary on;


The conf file overall looked llike this.
Code:
user www-data;
worker_processes  4;
worker_rlimit_nofile 32768;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  4096;
    multi_accept on;
    accept_mutex_delay 50ms;
}

http {
    include       /etc/nginx/mime.types;
#from linode
default_type  application/octet-stream;
#linode end
    access_log  /var/log/nginx/access.log;

# Miscellanous options danielmiessler start
   sendfile        on;
   tcp_nopush     off;
   keepalive_timeout  65;
   tcp_nodelay        on;
#   expires max;
#server token disables version of nginx
   server_tokens off;

   gzip  on;
   gzip_proxied any;
   gzip_comp_level 2;
   gzip_disable "MSIE [1-6].(?!.*SV1)";
   gzip_types text/plain text/css application/x-javascript text/xml
   application/xml application/xml+rss text/javascript;

   gzip_vary on;
#
# Virtual Host Configs
##
   client_max_body_size 20M;
   client_body_buffer_size 128k;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


It worked nicely, but it got a bit sluggish.

Are there any bottlenecks on these settings?

Then, I figured maybe I should tune fpm a bit. Again, I followed http://tutspundit.com/how-to-install-ng ... ss-part-2/
Code:
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
[www]
listen = /var/run/php5-fpm.sock
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 1000
user = www-data
group = www-data


I stopped and checked the site. It got a bit better, but occasionally, I get error 500.

I dont have these checked yet
Code:
emergency_restart_threshold = 4
emergency_restart_interval = 10s
process_control_timeout = 10s
daemonize = yes
listen.backlog = -1
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
rlimit_files = 32768

rlimit_core = unlimited


If you see any crucial points, where it could be tweaked, or it is a 'must have'. Please, let me know.


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