How To Install WordPress on a LEMP On VULTR VPS


In this tutorial, you’ll learn how to install WordPress on a freshly created instance. I’ll demonstrate the installation on an Ubuntu 14.04 server. These instructions may also work on older versions of Ubuntu and Debian.

So, let’s start.

how to install wordpress on LEMP server on vultr vps

Step One: Update existing packages

Step Two: Install Nginx

Nginx 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 Apache, Nginx uses an asynchronous event-driven model which provides more predictable performance under load.

Let’s add a third-party repository to install the latest version of Nginx (1.6.1).

Now, let’s test if the server is up and running.

It should take you to Nginx’s default landing page.

Step Three: Install PHP 5.5

PHP 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.

If you want to check your PHP version, run the following command:

You will see something like this.

Now, we’ll make a slight configuration change to make our setup more secure. Open the main php5-fpm configuration file with root privileges:

Press Ctrl+W and search for cgi.fix_pathinfo=. Uncomment it (delete 😉 and change 1 to 0. After changes, the line should look like this:

Save (Ctrl+O) and close the file (Ctrl+X).

Now, we just need to restart our PHP processor by typing:

Step Four: Install MySQL

To store and manage databases, we need to install MySQL. You can easily install it by typing the following in the console:

During the installation process, you will be asked to set a root password for MySQL. Once you have set the root password, we will have to tell MySQL to generate the directory structure where it will store databases.

Let’s finish it up by running a security script that will modify some default insecurities.

Just 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:

At this point, your LEMP server is up and running.

Step Five: Configuring Nginx to serve WordPress

Let’s start our WordPress installation by creating an Nginx server block for our site.

Paste the following code there:

This is a well tuned WordPress configuration file with permalinks support. Save (Ctrl+O) and close the file (Ctrl+X). Let’s enable the server block by symlinking:

Next, we’ll delete the Nginx default server block.

Now, we’ll tune the main Nginx configuration file:

Make sure that the number of worker processes is equal to the number of cores in your instance.

Add use epoll; to the events block.

Add client_max_body_size and server_tokens off directive. Set keepalive_timeout to 30 seconds.

Make sure that the whole Gzip settings block looks like this:

Save (Ctrl+O) and close the file (Ctrl+X). Then restart the server:

Step Six: Configure PHP

If you want to upload files more than 2mb to your WordPress site, you have to increase PHP upload size variables in php.ini.

Now, press Ctrl+W and search for “upload_max_filesize” and set it to 100m.

Do the same with post_max_size. post_max_size needs to be the same size or larger than upload_max_filesize.

Restart PHP.

Step Seven: Setting up the MySQL database

In this step, we’ll create the database user and tables. Go ahead and log into the MySQL shell:

Log in using your MySQL root password. We will need to create a WordPress database, along with a user in the database. First, let’s make the database (feel free to give it whatever name you like):

After that, we need to create a new user. Please replace the database, name, and password with whatever you prefer:

Set a password for your new user:

Finish up by granting all privileges to the new user. Without this command, the WordPress installer will not be able to start up:

Then refresh MySQL:

Exit the MySQL shell:

Step Eight: Installing the WordPress files

We’re almost done. Let’s proceed to installing WordPress.

First navigate to the site root directory:

Now, download the latest version of WordPress:

Extract it from the archive:

Give the permissions of /var/www/wordpress to www-data user. It will allow future automatic updating of WordPress plugins and file editing with SFTP.

You’re done! Your new WordPress site is now ready. Just navigate to your website and finish the installation.