Comments on Drupal 6 Hosting With nginx And PHP-FastCGI On Ubuntu 9.10
Drupal 6 Hosting With nginx And PHP-FastCGI On Ubuntu 9.10 Drupal is a great CMS but is a bit hefty when you host it on bargain-basement shared hosting, and virtual private servers are great but memory-constrained at the low-end. Apache can be a big offender when it comes to resource usage, so a nice alternative is nginx, a fast, light-weight and efficient http server that supports PHP via PHP-FastCGI. So this is a pretty slick setup for hosting Drupal, and I've taken a few different howtos and forum posts to put together this guide, which should have all you need in one stop, including a working URL rewrite config.
7 Comment(s)
Comments
Overall, a nice howto, but whether you see gains will depend on the particulars of the traffic and server configuration.
Most of the "apache" vs "nginx" are really mod_php vs fast-cgi.
The gain you are getting by using fast-cgi is that you are not loading php to handle static files such as images, .txt and html files.
mod_php is generally faster than fast-cgi for serving php files due to the apache module design (but fast-cgi is normally within 5%)
However, the reduced memory foot print of not using mod_php while serving static files, means that you are less likely to start using swap, which is the noticible performance killer.
Nginx is generally faster than apache with mod_php when serving static files (generally about 2-10%) and uses less memory.
I like nginx and lighttpd, especially their non-blocking nature, but apache is an amazingly flexible webserver, that can be pushed to be competitive with nginx and lighttpd in the low end, and on the high end it may well be worth using both nginx or lighttpd and apache.
One other thing you might mention is that many people find that they have to restart their fast-cgi server periodically due to poorly written php programs, that show memory leaks over time.
I restart mine weekly, but a few people have /etc/init.d/php-fastcgi restart in their daily crontab.
One other comment, this howto configures nginx for clean urls without index.php in them. so you can just enable them in drupal.
Thanks for your tutorial, really helpfull. Everything works correctly on my dev computer. Just wanted to test ngninx stuff. It will really help me to make website faster. I really see the difference in loading time on my personnal computer.
But I have an error that I really don't know how to resolve, I'm really a new to linux configuration...
In my admin reports status of my drupal website:
GD Image Filtering | Low Quality / Poor Performance |
---|---|
The installed version of PHP GD does not support image filtering(desaturate, blur, negate, etc). It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See http://www.php.net/manual/en/image.setup.php. An implementation of imagefilter in PHP will be used in the interim. | |
GD Image Rotation | Low Quality / Poor Performance |
The installed version of PHP GD does not support image rotations. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See: http://www.php.net/manual/en/image.setup.php. An implementation of imagerotate in PHP will used in the interim. How I could resolve this dependencies. I'm on Ubuntu 9.10. Thansk for your help.
|
I appreciate the work that you have put in this page. Really good, Thanks.
Thanks for this great tutorial, but I am having problem with LDAP, i tried adding the extension=ldap.so to the php.ini but the phpinfo(); still does not show any information about ldap.
Any helps are appreciated, thx.
still working on figuring out my problem but the infamous nginx 502 gateway error appears, randomly
apparently apt-get update / upgrade fixed the issue
and the final comment from me in this thread. After getting the lates updates and upgrades the 502 error became less frequent, but it would still appear if i did something resource intensive and javascript, it would appear every time i worked with views module for a while. Finally i was able to completely resolve this issue.
In the nginx.conf i made sure to increase the worker processes to 4, worker_connections to 2048, comment out the multi accept, set keepalive to 0. Now i have ran sever loadimpact tests, bunch of views added, etc and the 502 issue has not reappeared. So i think the increasing the workers and worker connections is what finally did it. Obviously i am not a professional, but for someone who is banging their head on the wall over the "nginx 502 bad gateway" with drupal and fastcgi error i recommend this solution.