How to Set Up LNMP on Debian, Ubuntu or CentOS
By rockia on May 06, 2010 with Comments 22
As I announced that Rockia.com has been moved to Linode VPS, I received numerous emails asking how they can do that. My answer is that if you are professional in Linux, you can just follow the tutorials in Linode Library; I strongly believe that there are more tutorials than you actually need to set up your server. However, I don’t consider myself as one of Linux guru so I am going to do it the lazy way.
Before I go any further, I would like to give the credits of the pre-made package to the Chinese developer Licess; if you are happy with his/her work, please donate some money to him/her and keep the project going, you can donate the money by clicking the donate button on this page: http://www.lnmp.org/donation.html .
Linux supported:
- Debian (32bit or 64bit), Ubuntu or CentOS
Included Software:
- Nginx
- MySQL
- PHP
- PHPMyAdmin
- Zend Optimizer
- eAccelerator (Optional)
- Nginx-RRD
- vsFTPD (Optional)
What does LNMP stand for?
LNMP is be abbreviation for Linux+Nginx+MySQL+PHP.
Why I chose Nginx rather than Apache, considering Apache has bigger user group and better support from the whole community? Well, I only get the cheapest plan form Linode and I would like to save as much memory as possible for my running websites. Nginx is a light-weight web server that will do pretty much the same thing as Apache. And you know what? Even WordPress.com is using Nginx as their web server and so that I think Nginx is good for me to host my own wordpress blog.
OK, now let’s get started.
1. Download Licess’ LNMP Package:
Use your SSH client software to login your Linux server (in this case, either Debian or CentOS), since I am using Mac OS X so I can simply use my Terminal and type in “ssh root@my_ip_address” (my_ip_address is my IP address). However, there are numerous SSH client software with very good GUI that will help you log in.
Now with your root account signed in, you can go ahead to download the software with the following command line:
wget -c http://www.rockia.com/dl/lnmp0.4.tar.gz
2. Unzip LNMP Package:
Within the same directory, run the following command line to unzip the file you just downloaded:
tar zxvf lnmp0.4.tar.gz
3. Run installation script
Once you unzipped the package, you should be able to see there is a folder in the same directory. If you want to make sure if it’s there or you would like to double check the folder’s name, you can run the following command line:
ls
The default folder name is “lnmp0.4“, we can navigate to this folder by typing in the following command line:
cd lnmp0.4
And you can find there are different installation scripts in the folder, you should choose different installation script if you are using different OS, for example, if you are using Debian or Ubuntu, you can type in the following command line:
./debian.sh
If you are using CentOS, then the command line should be:
./centos.sh
The installation should start instantly once you hit enter.
4. Simple Setting During Installation
During the installation, you will be prompted to type in your domain name and set your password for your root database.
In my case, the domain name is www.rockia.com.
For the domain name, if you are not ready yet, just simply type in your IP address and the default root MySQL database password is “root” if you don’t want to set one at that moment, and you can change it very easily later when your server is ready to go.
You will also be asked to type in your server location which you can choose from Asia、America、Europe、Oceania or Africa.
The whole installation could take up to 10 minutes and the following software will be installed according to your OS chosen:
Nginx、PHP、MySQL、phpMyAdmin、Zend
5. Install Optional Software
The LNMP 0.4 package also include eAccelerator and PureFTPd with admin panel, if you would like to install there packages, just type in the following command lines:
./eaccelerator.sh
If you would like to install PureFTPd, you will need first type in the command line to install the service:
./pureftpd.sh
Once the service is installed, you will need to visit http://your.own.ip.address/ftp/install.php (replace your.own.ip.address with your IP address of the server) to install the Admin Panel for PureFTPd. I didn’t install PureFTPd for my server so I will skip the introduction here but it should be fairly easy and staright forward.
6. Test Your LNMP Server
The installation is considered to be done. If you would like to test your server, you can use the following PHP pages to test your server:
phpinfo : http://your IP/phpinfo.php
phpMyAdmin : http://your IP/phpmyadmin/
Pointer : http://your IP/p.php
Here is how you can manage your server:
LNMP Server: /root/lnmp {start|stop|reload|restart|kill|status}
PureFTPd Server /root/pureftpd {start|stop|restart|kill|status}
Let’s say, if you would like to restart your LNMP server, just use your root account to log into SSH, and then type in /root/lnmp restart
7. For WordPress Users
You might found some problems with the URL rewrite function (Permalinks) or Super Cache if you use it. The solution is posted on Rockia.com, you may find it helpful.
Post Note:
Isn’t that simple? Please let me know if you have problems understanding my post or you need some help on your server setup. However, I must say that I am not a pro on Linux platform and I personally not the maker of the package.
If you are looking for a reliable VPS, I strongly recommend Linode VPS, and if you are ready to buy a Linode VPS, please use the following link to sign up. I am not going to set up a trap, this is my referral link, if you don’t want to give me a referral, just simply type in linode.com in you browser.
http://www.linode.com/?r=fd71913368eb7c8ef638f842af2b45d49a2966a7
If you want me to help you with Linode, I can give it a try too.
Once again, I am here to thank Lincess the developer who worked hard for this package; it really saved me some time on the server set up and optimization.
Hi
I can’t host multiple sites here right ?
What about dns ?
Hi Viv, for sure you can host multiple sites. All you need to do is to configure a vHost file. When I am back from my vacation, I can write a post on it.
For the DNS, the hosting panel could take care of it for you. I use Linode as my hosting provider and I can configure the domain DNS in my account panel.
Dear Sunny, you don’t set up the nameserver or DNS with the Nginx. You will have to do it with your hosting provider, in my case, it’s Linode. If you are using Linode, maybe you would like to read an article from Linode library : http://library.linode.com/linode-manager/configuring-dns-with-the-linode-manager
Hello,
Can you please tell me that how to add a ftp account to the system after installing to upload the files for my site without pureftpd? (im using linode and centos5.5)
Also after installing this it gives me 403 forbidden error when i navigate to my ip is it normal?
Ok I have resolved the ftp thing with sftp! Please can you tell me that how you enabled permalinks in wordpress? Can you please post the lines which added to nginx.conf !
Please post the lines for wp super cache if you can!
Thanks
Hi Sahan, I just posted a solution. Please check and see if my solution works for you.
WordPress Conf file for Nginx URL rewrite and Super Cache
Thank you very much Rokia! I figured it out!
Hi rockia,
Im running lnmp without any problems for my small wordpress site which gets about 400 visitors a day!
Im on linode 512 and centos 5.5 my problem is that lnmp memory usage slowly increases day by day! But my sites running super fast as usual!
After a vps restart and fresh start of lnmp memory usage about 220MB and after about 3 days memory usage is about 450MB are you facing similar problems’? How about your memory usage? Please help me to solve this!
Dear Sahan, without any detailed record, I don’t think I could help you much with it because it may caused by some other software installed. Anyways, you can take a look at this post first http://www.rockia.com/2010/09/mysql-manager-or-server-pid-file-could-not-be-found , I kinda having the same problem before.
I used to have Debian, and now switeched to CentOS 5.5, so I should have the same set up with you. I found CentOS tend to use more CPU in a regular period of time, but it’s still below the limit so I didn’t really checked it yet. If I found anything, I will let you know.
Thanks for your reply rockia
I had crazy file system failure with linodes back restore process So I had to install everything from scratch! Then I choose Ubuntu Lucid and now its running great again. I also had that mysql pid problem after few hours installing lnmp then I restarted linode and problem is gone!
Ill inform you that if my memory usage problem grow with this setup too. And Im only running lnmp with 1 site and didnt have any additional scripts installed. Can you please reply with your memory usage details after running lnmp for like 24 hours? My memory usage is now about 400MB (including 128MB memcached instance)
Thanks,
Hi Sahan, my memory use is at about 300MB level so it should be reasonable, because I am running other scripts other than LNMP (which hosts 3 WordPress blogs).
LNMP has been updated to v0.5
http://translate.googleusercontent.com/translate_c?hl=en&sl=auto&tl=en&u=http://lnmp.org/index.html&rurl=translate.google.ca&twu=1&usg=ALkJrhgVAwx5SNC89hqq5apDuL0DdCGbgA
Could you please update the guide?
Many thanks
Yes, Bob, LNMP package has been updated to V0.5, but according to licess, the developer, nothing really has been changed except the software version. So the installation procedure stays the same, but thanks for your reminder and I will update this post when I finish the work on hand which is probably in 4 or 5 days.
Hi Bob, just to give you an update. I have upgraded my server to LNMP 0.5 and the new tutorial is here:
http://www.rockia.com/2010/10/easy-installation-of-lnmp-0-5-on-centos-debian-or-ubuntu
Hi Rockia,
I tried to install lnmp two times. Both time, It took more than two hours and I had to stop. I used slicehost 768 with centos 5.5 and 5.4. Didnt install any other software.
why does it take so long?
Try to use “wget -c http://www.rockia.com/dl/lnmp0.6.tar.gz” instead of “wget -c http://www.rockia.com/dl/lnmp0.4.tar.gz“, the LNMP version 0.6 has installation optimization over version 0.4 and the software version is newer.
hi Rockia,
when i install lnmp0.6 in centos, it stuck at make[4]
make[3]: Leaving directory `/home/admin/lnmp0.6-full/mysql-5.1.48/mysql-test/lib/My/SafeProcess’
make[2]: Leaving directory `/home/admin/lnmp0.6-full/mysql-5.1.48/mysql-test/lib/My/SafeProcess’
make[2]: Entering directory `/home/admin/lnmp0.6-full/mysql-5.1.48/mysql-test’
make[3]: Entering directory `/home/admin/lnmp0.6-full/mysql-5.1.48/mysql-test’
make[3]: Nothing to be done for `install-exec-am’.
make INSTALL_TO_DIR=”/usr/local/mysql/mysql-test” install_test_files
make[4]: Entering directory `/home/admin/lnmp0.6-full/mysql-5.1.48/mysql-test’
Thanks for the script, rockia!
Would you know how I can remove phpmyadmin after the script installation? Not sure if deleting the whole directory is the right way to do it.
Yep, if you want to remove phpmyadmin, just delete the whole phpmyadmin folder and it will do the job.
Hello there,
I installed the LNMP 0.6 version on a Debian 6 box a moment ago. Before installing LNMP, I did not install any other packages or software (since the OS was freshly re-booted).
My problem is that I can’t seem to get PHP working on LNMP. When ever I visit a .php page (i.e. the ‘phpinfo.php’ page in ‘/home/wwwroot’) I get a “502 Bad Gateway”.
What should I do? Kindly advice as I’m rather new to LNMP and Nginx.
Yes, you need to run the vhost under your /root/lnmp0.6 folder and assign a path to your root folder. For example, if your IP is 12.23.45.67, then key this IP as your domain and point it to /home/wwwroot, you need to run vhost for every domain you add
I get 502 error on any of this
phpinfo : http://your IP/phpinfo.php
phpMyAdmin : http://your IP/phpmyadmin/
Pointer : http://your IP/p.php
fresh debian on xen vps