Ubuntu 12.04 has reached end-of-life. The steps and commands used in this guide may no longer be relevant to newer versions of Ubuntu.
Probably a lot of people are going to use their AKLWEB HOST VPS as web servers; a good choice would be Nginx as a web server. In this topic, I’m going to describe 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:
apt-get updateapt-get install -y nginx php5-fpmapt-get install -y php5-mysql mysqlWhen prompted, enter a password. This is the root password that you will need to create databases and users.
Now that we’ve 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 domains to your server.
The configuration file can be found here: https://gist.github.com/GiovanniK/11194798
To begin, we’ll remove the default vhost for nginx:
rm -rf /etc/nginx/sites-enabled/defaultWe’ll now create a new one with the contents of the vhost I gave you.
nano /etc/nginx/sites-enabled/DOMAINNow that we’ve created our vhost and we’ve pasted the contents, we’ll have to edit some things.
Below are 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 out the following lines:
Line 1 & 2
Line 12 - 16
Line 26 - 31
Line 34 - 37Now that our configuration is complete and we’ve set up all our services, we can restart Nginx.
service nginx restartWe’re done! If you go to the domain name you’ve pointed to your server, you should see the new document root, and you should be able to put content on it.
Enjoy!