Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04) Without Compiling Anything
|
Submitted by Sypher (Contact Author) (Forums) on Mon, 2010-06-14 18:52. :: Debian | Ubuntu | nginx | PHP
Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04) Without Compiling AnythingVersion 1.0 Since Apache is most of the time a memory hungy process, people started to look for different ways to host their website. Apache is clearly not the only webserver available. A few good examples are lighttpd and nginx. In this tutorial I will show you how to install it on your Ubuntu server. This tutorial also applies to Debian, though. There is only a very small difference. Ready? Let's begin shall we.
Step 0 - Preliminary NotesIn order to complete this tutorial, I assume you have installed a base system of Ubuntu Lucid (10.04). How this can be done, can be read in different tutorials. This tutorial only focusses on getting nginx+php running without much hassle.
Step 1 - NginxInstalling nginx is the first step we have to do. This can be easily done by downloading it from the repository. sudo apt-get install nginx The default vhost has to be changed in order to work properly. sudo vim /etc/nginx/sites-available/default A nice starting point for your config is: server {
Ok, we're done here. Now we'll install the needed files for PHP.
Step 2 - Installing PHPMany sites rely on PHP for providing them dynamic content, whether this is a wiki, forum software, weblog or something entirely different. There is no need to use DotDeb, since PHP5.3 is now officially supported in Ubuntu Lucid (10.04). Its as easy assudo apt-get update The resulting text should include dotdeb. Now we'll install PHP. In order to install PHP-FPM, we'll have to add the PPA to it since it is not officially supported. add-apt-repository ppa:brianmercer/php sudo apt-get update && sudo apt-get install php5-fpm If you are planning to use a database or require specific modules (mcrypt, ldap, snmp etc) you can install them as well. Ok, so now we have nginx and PHP installed and ready to go.
Step 3 - FinalizingRestart nginx in order to catch up with the config changes we made earlier. sudo service nginx restart The restart should have gone without any problems. After installing php5-fpm, it should have been started. If you did change your php.ini files, you have to restart php5-fpm. sudo service php5-fpm restart All right. They should now both be running. Step 4 - TestingIn order to test if the execution of PHP is working, create an index.php file in /var/www with the following content: <?php phpinfo(); ?> Visit your webserver and you should be able to see the generated phpinfo. If not, something went wrong.
Step 5 - Troubleshooting & Final notesIf you did not see the phpinfo, there might be something wrong. In order to track down what went wrong, you can check the nginx error log: sudo tail /var/log/nginx/error.log Remember, if you did change your php.ini you have to restart php5-fpm. Restarting nginx isn't' necessary. In my example config I've enabled the fastcgi error interception. If a serious error occurs (for instance a "cannot redeclare class xyz"), nginx can catch this page and show a "nice" error page that something went wrong. This way, there is less information given out in case something is going seriously wrong. If you do not like this, you can turn it off. If php5-fpm is not running, your PHP files cannot be parsed and nginx will show the user an error page. Well, I guess we're done and you are now able to serve PHP with your new nginx based webserver. Nginx is pretty nice and you can configure a lot. If you need rewrites, be aware that nginx does not work with .htaccess files. You will need to change your vhost settings in order for the rewrites to work.
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
One number. one voicemail. Seize the lead with Sprint. Learn more
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video
Sprint 4G - The Ultimate Mobile Broadband
Click here
SAP-Business Objects Crystal Reports Server
Complete reporting without hidden costs. Free Trial








Recent comments
20 hours 48 min ago
1 day 33 min ago
1 day 5 hours ago
1 day 8 hours ago
2 days 12 hours ago
2 days 12 hours ago
2 days 13 hours ago
2 days 13 hours ago
2 days 13 hours ago
2 days 21 hours ago