Multiple WordPress in Lighttpd & Php5 in Ubuntu VPS or Server
By Fahad Ahammed
- 6 minutes read - 1203 wordsLighttpd = Security, speed, compliance, and flexibility.
It is pronounced as “Lighty”. Lighttpd is rapidly redefining efficiency of a webserver . It is Designed and optimized for high performance environments. With a small memory footprint compared to other webservers. 128mb ram can run it like a mig29 with several wordpress(I will try two today). It has advanced feature set like FastCGI, SCGI, Auth, Output-Compression,URL Rewriting and many more. It is perfect for every server and also for VPSs with low memory. You will be amazed by its speed with low ram and swap. It is totally free.
Let’s install Lighttpd with MySql with PHP-FPM in Ubuntu or maybe Debian, But i tried in Ubuntu. Look my VPS which is 128mb ram with 256mb swap and running two wordpress with lightspeed.
First open putty or terminal and connect to your vps or server. Then after login upgrade Ubuntu.
Reboot system and reconnect by ssh.
Now Install mysql.
You will be asked to set mysql root password. Now remove apache if it is pre-installed.
Then put this.
Now install lighttpd.
Now in the browser you can access your lighttpd server by this.
xxx.xxx.xxx.xxx is your server or vps ip address.
You will get a page like below.
Now let us Install php5, php-fpm.
Now we have to edit a file. I use nano for editing files.
Now let us edit php.ini.
You will see many text. Now press ctrl+w and write cgi.fix_pathinfo=1 in the below appeared field. And delete “;” symbol from the lines start. Press ctrl+x the y and then press Enter to save the file.
The Lighttpd configuration file for PHP /etc/lighttpd/conf-available/15-fastcgi-php.conf is suitable for use with spawn-fcgi, however, we want to use PHP-FPM, therefore we create a backup of the file (named 15-fastcgi-php-spawnfcgi.conf) and modify 15-fastcgi-php.conf as follows:
Now edit fastcgi and put there the texts from below :
To enable the fastcgi configuration, run the following commands:
This creates the symlinks /etc/lighttpd/conf-enabled/10-fastcgi.conf which points to /etc/lighttpd/conf-available/10-fastcgi.conf and /etc/lighttpd/conf-enabled/15-fastcgi-php.conf which points to /etc/lighttpd/conf-available/15-fastcgi-php.conf:
Now let us check if php works or not.
And put below texts and save.
Now try accessing the page by browser.
If you see a page with php on the page head then you are passed. 🙂
To get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:
Pick the ones you need and install them like this:
Xcache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It’s similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page.
Xcache can be installed as follows:
Now restart PHP-FPM:
Now if you reload that page in your browser you will see more module added there.
Now let us install phpmyadmin for our easy access to mysql database.
During installation you will be promted to chose one server.
You will have to select lighttpd by pressing Down Keybord Button to take marker on lighttpd and Select by SPACE BAR. And then press TAB to take the marker to OK option and press enter. You will also be asked “Configure database for phpmyadmin with dbconfig-common?” where you will have to select NO by pressing Right Keybord Button and Enter Button to select.
Now in browser you can access phpmyadmin by :
Now open php-fpm config file by:
adn search for listen = 127.0.0.1:9000 and put ” ; ” in the lines start. and then after that line put this, “listen = /tmp/php5-fpm.sock” and save the file.
Then restart PHP-FPM:
Next open Lighttpd’s PHP configuration file /etc/lighttpd/conf-available/15-fastcgi-php.conf and replace the host and port lines with “socket” => “/tmp/php5-fpm.sock”:
Finally restart Lighttpd:
Now , let us point domain to server. Open domain control panel and in nameserver you have to select default and then from DNS management you will have to create A record to point your servers IP. If you can’t, ask your domain host to help you. I will use two domain now to show you how to add multiple site by only pointing by A record.
Now open lighttpd config file.
Now remove # from front of “mod_rewrite”,
And check what is saying server.document-root , normally it is always /var/www . If not that , then change that to it.
Now , let you have two website site1.com and site2.com
As we have selected or got /var/www as document root , we have to use /var/www as our default website folder. We have to create two folder for two website.
This will create two folder with sub folder named web and logs. Now let us create two index.php file to both domain folder to check virtual host.
FOR SITE1.COM:
And put text/code from below and save.
FOR SITE2.COM:
And put text/code from below and save.
Now open lighttpd configuration file and add below two lines to the end and save.
Now for both of the site we have to create configuration file.
FOR SITE1.COM:
Put below code and save the file.
FOR SITE2.COM
Put below code and save file.
now save and restart lighttpd by
Access the both domains and if you can see in your browser that site1.com is showing site1.com and site2.com is showing site2.com then you have done well.
Now let us install wordpress. First access phpmyadmin from browser to create database.
or
or
You will be asked for user and password. Use root as user and password as you are chosen earlier. Click on Databases and create Database.
Create Two database for two site/wordpress. I use collation as utf8_general_ci for my native language support and all.
Now from ssh go to site1s default folder:
And download wordpress from https://wordpress.org/download/ link. You can download zip file or tar.gz . I am showing you how to extract both files.
ZIP:
Extract By
TAR.GZ:
Extract By
whatever you do you will find a folder extracted there named wordpress. If you want to acces wordpress from a folder then let it stay that way or maybe you want your wordpress site access directly by domain name which is the coolest and i follow that. How to move all files from that sub folder of wordpress ? Let us begin. First delete old created index.php file from websites default folder.
And now move all files from wordpress to default directory/folder.
Now all files moved keeping wordpress folder empty and we don’t need that folder. So delete it and also delete the archieve file(though you can use that file for site2.com by copying or maybe download ? ).
Now follow the same procedure for site2.com.
Let us start wordpress installation. First edit site1.com config file.
First Rename sample config file.
Now edit the renamed file.
Now put everything like below.
Now access your site1.com and put admin informations there and one wordpress installed.
Follow these for second one too. Just change the Database name from wp-config.php file to whatever you chosen when you created from phpmyadmin.
So your two wordpress in a vps with super speedy lightspeed server is created.