Preparing Ubuntu 14.04 for Web Hosting (LEMP installation)
IntroductionIn this tutorial, you’ll learn how to install WordPress on fresh created instance. I'll demonstrate you the installation on Ubuntu 14.04 server. It should work well for older versions of Ubuntu and for Debian too, but I’m not 100% certain about this.
So, let’s start.
Step One: Update existing packages
apt-get update && apt-get upgrade
Step Two: Install NginxNginx is a high performance lightweight web server designed with the purpose of delivering large amounts of static content with efficient use of system resources. In contrast to the Apache, nginx uses an asynchronous event-driven model which provides more predictable performance under load.
Let’s add third-party repository to install the latest version of Nginx (1.6.1).
sudo apt-get install python-software-propertiesNow, let’s test if the server is up and running.
add-apt-repository -y ppa:rtcamp/nginx
sudo apt-get update
sudo apt-get install nginx
service nginx start
http://YOUR-VPS-IPIt should take you to Nginx's default landing page:
Step Three: Install PHP 5.5PHP is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.
Let's install the latest version of PHP on our server.
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt
If you want to check PHP version, run the following command:
php -vYou will see something like this.
PHP 5.5.16-1+deb.sury.org~trusty+1 (cli) (built: Aug 25 2014 10:24:59)Now, we'll make a slight configuration change to make our setup more secure.
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
withZendOPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
Open the main php5-fpm configuration file with root privileges:
sudo nano /etc/php5/fpm/php.iniPress Ctrl+W and search for “cgi.fix_pathinfo=”
Uncomment it (delete and change 1 to 0.
After changes, this line should look like this:
cgi.fix_pathinfo=0Save (Ctrl+O) and close the file (Ctrl+X).
Now, we just need to restart our PHP processor by typing:
sudo service php5-fpm restart
Step Four: Install MySQLTo store and manage databases, we need to install MySQL. You can easily install it by typing the following in the console:
sudo apt-get install mysql-serverDuring the installation process, you will be asked to set a root password for MySQL.
After that, we will have to tell MySQL to generate the directory structure where it will store databases.
sudo mysql_install_dbLet’s finish it up by running a security script that will modify some default insecurities.
sudomysql_secure_installationJust type the MySQL root password and type “n” if you don’t want to change it. After that, type “y” to every question.
Set Timezone (conditional)By default, the timezone of your server is UTC. If you're living in a different timezone, you can change it by typing in the following command:
sudo dpkg-reconfigure tzdata
That’s it! Your LEMP server is up and running now.