How to Install VestaCP with Nginx + PHP-fpm
| |VestaCP is known nowadays as the best free and easy to use hosting control panel (according on me). Well, as you may know that by default Vestacp implements Nginx as frontend webserver while makes use of Apache as backend. This becomes the most common configuration allowing its users to enjoy the speed of Nginx –in delivering static contents– while also the easiness and flexibility of Apache.
In today’s guide, I’m going to show you how to install Vestacp with Nginx and PHP-fpm, instead of with Nginx, Apache and PHP5, on your VPS (Ubuntu or CentOS server). In addition, there are also few results of performance benchmark test so you can estimate how powerful it is to build a hosting server powered with Vestacp, Nginx, and PHP-fpm on a 512MB RAM server. Are your curious enough? Get Ready!
Prerequisites
- A SSH client like Bitvise or Putty and basic knowledge about how to use it.
- Basic knowledge about common Unix command to SSH to your server.
- A server or VPS with at least 512MB of RAM (1GB or more is recommended).
- About 30 minutes of your time
- a cup of coffee or tea.
Confused on choosing which VPS provider to install VestaCP? Read my recommended VPS providers or top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.
In this guide I’m using a 512MB RAM Cloud VPS from Digital Ocean running Ubuntu 15.10 x64. You can use steps below on CentOS and any Ubuntu versions which are supported by Vestacp.
VestaCP Installation
Step 1 – Login to your server via Putty (or any SSH client) as root or as user with root privilege (sudo).
Step 2 – Now open up your favorite web browser (e.g: Firefox, Chrome, IE), then visit vestacp.com. Scroll down the page a little bit and find the Advanced Install Settings section. Choose nginx + php-fpm from the dropdown menu.
Step 3 – Because Vestacp doesn’t come with File Manager (unless you buy its license), so you better also choose which FTP server you prefer to install: vsftpd or proftpd. It is necessary for you to easily transfer and manage your site’s files and folders.
Step 4 – Next, if you also planned your server to host your email so you can have your own name@yourdomain.com for instance, then also choose which mail server and its necessary software to install. The least and common things to install are exim and dovecot but you can also install spamassassin and/or clamav.
Step 5 – Regarding DNS, you have only two options: either to use NAMED or use no DNS at all. As per my example, I simply chose to use no DNS because I’m going to use default Namecheap DNS Management features. Also, reducing one or more component can help save my server’s RAM usage.
Step 6 – Next is firewall, you can choose whether to use iptables and fail2ban, iptables only or no firewall at all. In my case, I decided to use iptables and fail2ban. It is the safest scenario.
Step 7 – Also, you can choose either MySQL or PostgreSQL as your database engine. In fact, you can -if you want- to choose both of them as well as none of them. It just depends on your need, but if you plan to install WordPress then you are going to need MySQL.
Step 8 – Additional repository part is just an optional but if you are on CentOS, you should better to install it. Remi repo provides lot more awesomeness. There are many additional packages there.
Step 9 – For the File System Quota, I really suggest you to simply choose no especially if you are going to use your server alone. I mean, if you are not going to use it as Shared Web Hosting service so what’s the point of System Quota anyway. But however the choice is up to you.
Step 10 – Next, type in your server hostname: using valid FQDN is strongly recommended. Also, do not forget to type your email and password. It is not your email password but the password for admin account used to login to Vestacp.
Step 11 – Finally, do not forget to click on the green “Generate Install Command” button.
Step 12 – You’ll then get few lines of install command. Just copy that code.
The code is something like this one below. Tips: You can simply copy the code below actually, but I still told you how’s the process (above) to get the code so you can modify it according to your need:
bash vst-install.sh --nginx yes --phpfpm yes --apache no --vsftpd yes --proftpd no --exim yes --dovecot yes --spamassassin yes --clamav no --named no --iptables yes --fail2ban yes --mysql yes --postgresql no --remi yes --quota no --hostname your.hostname.com --email your@email.com --password yourpassword
**replace your.hostname.com, your@email.com and yourpassword with your own.
Step 13 – Go back to Terminal / Putty window. Now execute the command below to download Vestacp installation file:
curl -O http://vestacp.com/pub/vst-install.sh
If you are also using DigitalOcean droplet and running Ubuntu, most likely you’ll get curl is not currently installed. It means you have to firstly install it using command : apt-get install curl
Step 14 – Now you can paste the install command copied earlier (in Steps 12) there then hit Enter to execute it.
Step 15 – You’ll then be asked “Would you like to continue” so simply type y then hit Enter.
Step 16 – Sit tight and wait till the install process is complete. At the end of the process, you should see something like this :
Step 17 – That’s it. You can now login to your Vesta Dashboard page via web browser by typing :
https://x.x.x.x:8083
replace x.x.x.x with your server IP address. Use admin as username and use the password you defined earlier.
Vestacp dashboard page:
That’s it. Also read :
- How to add new website on Vestacp
- How to install wordpress on Vestacp
- How to find out MySQL root password on Vestacp
Performance of VestaCP Nginx + PHP-fpm
I posted several benchmark like how Vestacp with PHP7 performs either on Ubuntu and CentOS. So just in case if you are so curious about the performance of VestaCP nginx + php-fpm, here’s I’ll show you the result I got by using several tools. However in actual condition the result may vary but at least you can have rough estimation.
My inventory
- A 512MB cloud server from Digital Ocean on Ubuntu 15.10 x64
- Vestacp v0.9.8-15 with Nginx and PHP-fpm mode.
- WordPress v4.4.2
- WordPress theme is Schema by MyThemeShop.
- Dummy content also from MyThemeShop.
- No caching plugin in use.
Screenshot of the blog :
and the result :
GT Metrix Test
With 43 Requests needed to load the 1.36MB page size, it took 3.8s to load the site. The performance scores are B (82%) for PageSpeed ad B (88%) for YSlow. Pretty good isn’t it. However you can still tweak it more like installing caching plugin, using CDN, and so on.
Pingdom Tools
According to Pingdom, the performance grade is 92/100 and it needs about 41 requests to load the page. It took 818ms (under 1 second) to load the blog main page sized 1.2MB. Pingdom said it is faster than 93% or all tested websites. Sounds good does it?
Loader.io
I set up the test to have 10 clients requesting the site every second. It means the simulation is like “there are 10 new visitor try to access the site every second“. It’s a client per second test. Read here for the differences. The result is as shown above. There is no invalid redirect, there is now 400 and 500 error (server error), the average response time is 3487ms (3.5s), fastest response time is 837ms ( <1s ) and slower response time is 5487ms (5.5s). I tried to rise the number of request to 15 req/sec but it started getting many errors.
For you who are wondering, 10 clients or visitors are requesting per seconds means 600 visitors per minute or it is roughly about 864k visitors per day. So if, for instance, your question is like “Can with this setting my 512MB DO cloud handle 50k unique visitors per day?” then the answer is most likely Yes (assumed there is no single second with more than 10 requests at the same time, otherwise it will crash). But however in actual environment the result may vary.
LoadImpact
The test was using 50 unique visitors for 5 minutes test duration. The fastest load time around 300ms and the slowest load time was still below 1s. Even 50 UVs opening the site at the same time but the load time is still below 1s.
That’s it. I hope you have something in your mind already concluding the result of the performance test above.
I really wanna install php-fpm instead of apache but how does php-fpm handle .htaccess files?
You couldn’t use .htaccess on nginx + php-fpm setup. But you can use nginx .conf instead. Anyway, Vesta has provided ready to use configurations for most common CMS like WordPress, Magento, etc.
that seem to work out of the box, but I highly recommend this modification: https://forum.vestacp.com/viewtopic.php?t=13668
Hey Sawiyati, this is an excellent guide!! Thanks to your detailed step-to-step I achieved to setup my first nginx server by myself with your fantastic guide, thank you!
But I have a big doubt regarding to the hostname, it’s something I can create? And then I have to add in my domain an A DNS record pointing the hostname invented by me (subdomain) to the IP server?
Or maybe I can use the hosname generated by my hosting? For example for this guide I used a Kimsufi dedicated server and everytime I make an order of a new server, Kimsufi sent me an email with details of the IP, credentials, etc and also a HOSTNAME that is something like: ns38289.ip.194-42-92.net so I wonder if I can use this as hostname in the vesta installation process or it’s not safe to use the hostname generated by your host?
I will be pending for your answer, thank you again!!
It is better to use your own hostname. I mean, a hostname of the domain that you really own it. So feel free to create one and change your server FQDN before installing Vestacp
ok great, did not know nothing about FQDN but I made a search on your blog and found this, I use CentOS so I think this help me for what you tell to change y serveer FQDN before installing VestaCP?
http://servermom.wpengine.com/setup-fqdn-hostname-centos-server/2399/
Also I use CloudFlare to manage my DNS so I think I will need to add the new hostname as a subdomain record in my DNS manager? for example if my hostname is: server.domain.com I will need to add the next A record:
server pointing to domain.com
In my CloudFlare DNS manager true?
Or it’s not necessary to add this A record on CloudFlare? considering that I use CloudFlare to manage all my domain’s DNS records.
yes you have to add A record in your DNS setting
Hello! His tutorial helped me a lot. I managed to install but can not access the phpMyAdmin and Webmail. What might be happening?
Hello I followed all the steps and I ended up having Apache 2 default page 🙁 I can’t see my index.html …
mom… i got this “-bash: !: event not found” from installing vestacp in ramnode
when i install without params it said i have “httpd” already installed. i uninstalled the httpd, but it keep saying that. i tried to use –force also but nothing happen
please enlight me
You could simply rebuild the OS from Ramnode’s solusvm panel. It’s easier instead of removing httpd
WordPress permalinks dont work ! Pls Help me !
Have you select WordPress template in settings
Click on “WEB” from your Vesta CP, edit the domain, and change “Web Template” from default to “wordpress2”
mom why i got 500 internal server error when i try to installing drupal?
You should have made changed first to nginx .conf file
You can help with this problem?
How update php?
https://www.digitalocean.com/community/questions/problem-to-update-php-in-vestacp