In this tutorial we will how to install WordPress on a VPS running Ubuntu. WordPress is a free, open source and powerful content management system. It is built on PHP and uses MySQL to store its data. It has a very user friendly interface and requires no knowledge of coding skills. WordPress powers more than 50 millions websites globally and has thousands of themes and plugins available to supercharge your website. You can almost create every type of website through WordPress like Blogs, eCommerce websites, Business portfolios, hotels and bookings etc.
The requirements for installing WordPress are that you must have PHP version 5.6 or greater and MySQL version 5.6 or greater. Additionally you must have a web server up and running in your VPS. Refer to the how to install LAMP with phpMyAdmin in Ubuntu tutorial for setting up the required environment for the installation of WordPress.
It is not necessary to have phpMyAdmin installed on your VPS but it makes managing databases easier. In this tutorial we look at both options, creating the database and user with the MySQL command line and also creating the database and database user using phpMyAdmin. You can use either method available to setup database for your WordPress Installation.
Create the Database and User using the MySQL Command Line
WordPress uses a MySQL database to store all of its data, hence we will start the installation with creating a MySQL database.
Login to your MySQL command line by using the following command in your terminal.
mysql -u root -p
This command specifies that you are logging into MySQL using the username root, which is the administrative account for MySQL. It will ask you for the password of your MySQL root account, provide the password to login into MySQL command line. If you have not specified a root password, remove the -p option.
Once you are logged into MySQL, you can create a database using the following command.
CREATE DATABASE ;
You can specify any name for your database at the place of ``. In this tutorial we will use wpdata as the name of example database. The command
CREATE DATABASE wpdata;
will create an empty database wpdata in MySQL.
Please note that each command in MySQL ends with a semicolon, use a semicolon where specified to avoid errors.
For security reasons it is recommended that we create a separate database user for the database which we are going to use with WordPress rather than using the MySQL root user. This also makes the management of the database easier. We will create a new MySQL database user who will have full access to only the database we have recently created i.e. wpdata. For example we will name this user wpuser, You can use any name you want for your database user. The command for creating a database user wpuser will be
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'MyStrongPassword';
You can use any password in the place of MyStrongPassword, you should create a very strong password. The above command will create a user named wpuser and the password for wpuser will be MyStrongPassword.
Now that we have created both database and user, but the user wpuser does not have access to the database wpdata, you can give wpuser all permissions for the database wpdata by executing the following command.
GRANT ALL PRIVILEGES ON wpdata.* TO wpuser@localhost;
Now that we have made all necessary changes to MySQL we need to tell MySQL about the recent changes we have made. We can do so by executing the following command.
This command will flush all the privileges and MySQL will implement your recent changes immediately.
Now that we have all the things related to database are ready, you can exit from the MySQL command line using exit command.
Create Database and User using phpMyAdmin
phpMyAdmin provides a graphical user interface for managing databases. It's a very handy tool for editing the information stored in a database.
If you have already setup the database using the MySQL command line skip this step and directly continue with Installing WordPress.
Login to your phpMyAdmin dashboard by opening the following URL in your browser.
For example if you have a public IP address of 22.214.171.124, then you would open:
You can also use your domain name instead of IP address if you have this setup. Now login into phpMyAdmin using your MySQL root user and password.
To create a database through phpMyAdmin click on the New link from the left pane above the list of the databases.
In next step you will find interface to create a database as shown below, enter the name of the database you wish to create. In this tutorial we will use database named wpdata. Click on Create button to create the blank database.
Once the database has been created, you will see the name of the database on the left pane, click on the database to select it.
When the database is selected, it will show the structure of the database, since in your case the database is empty it will show you a message No tables found in database. Click on the Privileges tab from the top menu to view the users who have access to the database we have created.
You will see most of the users who has access to your database currently are global users like root. We will need to create a user for your database. Click on Add User to add another user to your database, you will see a interface to provide the username and password for your new user.
In Login Information section enter username for your new user. Leave the default value in Host text box which is %. Enter a strong password for your user, if you want you may generate the password instead.
In the Database for user section select the third checkbox on which Grant all privileges on database "wpdata". The name of database may change according to the database you have created earlier.
Finally Click on Go button to create a new user for your database and assign it full privilege on your database.
Now that we have database and database user setup, we can begin installing WordPress.
Start with logging in to terminal of your VPS.
If You are logged in using root account in your VPS, then you can omit using sudo command before all commands. If you logged in using an non root account then you will have to use sudo before all commands or you can use su command to switch to root account.
WordPress needs some additional packages to work properly and to perform additional tasks like sending emails, editing images etc. It's recommended that you install these packages also. To install recommended php packages run the following command in your terminal.
If you have some packages already installed then the system will update them.
Now download latest copy of your WordPress CMS by executing following command in your terminal.
Extract this archive by executing the following command.
tar -xzvf latest.tar.gz
This will extract all the files from archive to a directory wordpress. Move the files from wordpress to your Apache Web root directory by executing the following command.
sudo mv wordpress/* /var/www/html/
If you have still not deleted the Apache Default Page from /var/www/html/ directory, you may do so by executing the following command.
sudo rm /var/www/html/index.html
Next we will need to change ownership of the directory /var/www/html to the Apache web server user which is www-data. This will increase the security of the directory as well as allowing Apache web server permission to create and modify any file or directory. Otherwise WordPress will not be able to create any file or directory to store the files. To change the ownership to Apache web server process, execute the following command.
sudo chown -R www-data:www-data /var/www/html/
Now we will need to go to web interface of WordPress to complete the installation.
Access your website through any web browser, by public IP of your VPS or Your domain name.
You will see a welcome screen by WordPress and you will be asked to select your preferred language of installation.
Select your preferred language and click the Continue button. In next step you will be told to make sure that you have database name, database username and password and host ready. Click on the button Let’s go! to continue the installation.
Next, you will be asked for a Database Name, User name and Password. Fill these fields according to the database we have created before. For Database Host, leave this field as localhost, In the Table Prefix field you can leave this option as it is. Once you have filled in all the information, click on the Submit button to go the the next step.
If WordPress can establish a successful connection to the database it will tell you that WordPress can talk with the database and you can run the install. Click on the Run the install button. WordPress will now start the installation.
In next step it will ask you for the title of your website, and a username, password and email for your WordPress Administrator. Click on the Install WordPress button and It will write the changes to the database. Fill out the details accordingly and make a note of your Email address and Password, as you'll need this to login to your Wordpress Admin dashboard.
If successful you will see a success message like shown below.
WordPress has been installed. You may now login to your WordPress administrator dashboard by clicking on the Log in button. You may always login to your WordPress administrator dashboard by going to following link by a web browser.
In this tutorial we have learned how to create a database and database user using MySQL command line, or via phpMyAdmin. We then learned how to install WordPress on LAMP stack. You now have a WordPress installation in your VPS now which may be used for creating many types of websites.
If you find your cPanel disk space filling up, or an email address has hit its disk space quota, cPanel has a helpful built in Email Disk Usage tool. This will provide you with a simple to understand breakdown of how much disk space each folder for a particular email...
Although WHM will normally automatically keep itself up to date, you may want to manually check for server updates / push through an update that is pending, or it may be that you have automatic updates switched off on your cPanel server. In this guide we will show you how...
You may sometimes need to manually adjust the PHP settings on your cPanel server – for example if a site is hitting the PHP memory, or file size upload limit. WHM allows you to quickly change the settings of any PHP version installed on the server when needed, using the...