Probably a lot of people are going to use their Vultr VPSes as webservers, a good choice would be Nginx as a webserver.
In this topic I’m going to describe on how to install Nginx, PHP FPM and MySQL. Also we’re going to look at Nginx’s caching feature. In this topic we’re using Ubuntu 12.04, I do not know if this will also work on CentOS or Debian.
Make sure your server is up to date:
Install Nginx and PHP FPM
apt-get install -y nginx php5-fpm
apt-get install -y php5-mysql mysql
When prompted enter a password. This is the root password which you will need to create databases and users.
Now that we’re installed all the programs we need, we’ll configure our so called vhosts. A vhost is the configuration file for a domain, this means you can attach multiple domain to your server.
The configuration file can be found here:
To begin we’ll remove the default vhost for nginx:
rm -rf /etc/nginx/sites-enabled/default
We’ll now create a new one with the contents of the vhost I gave you.
Now that we’ve created our vhost and we’ve pasted the contents we’ll have to edit some things.
Below the old values:
Line 1: fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=Nginx:100m inactive=60m; Line 6: server_name nginx.dev; Line 9: root /var/www/nginx.dev/public/; Line 26: fastcgi_cache Nginx; Line 27: fastcgi_cache_valid 200 5m;
And the new values:
Line 1: fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=DOMAIN:100m inactive=60m; Line 6: server_name DOMAIN; Line 9: root /var/www/DOMAIN/public/; Line 26: fastcgi_cache DOMAIN; Line 27: fastcgi_cache_valid 200 TIME_TO_CACHE;
If you don’t want caching, remove/comment the following lines:
Line 1 & 2 Line 12 - 16 Line 26 - 31 Line 34 - 37
Now that our configuration is complete and we’ve setup all our services, we can restart Nginx.
service nginx restart
We’re done! If you go to the domainname you’ve pointed to your server, you should see the new document root and you should be able to put content on it.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article