Install WordPress On Ubuntu 16.04 LAMP
Have you just planned to start a website with WordPress? Do you need some information about how can you make your WordPress site run on Ubuntu 16.04(Xenial Xerus) or later? Here is, How to Install WordPress on Ubuntu 16.04 with LAMP stack.
WordPress is a popular open source content management system with over 2.5 billion installs. It also comes with a lots of plugin and themes that makes it easy for beginners to enhance site functionality and customize the visual parts of a website. WordPress can be also used to make a fully featured and powerful website with a lot of functionality.
It is also easy to install and learn. If you are an absolute beginner and want to start your first website from scratch, Start with WordPress. Here in this tutorial, we will show you how to install WordPress on Ubuntu 16.04 with LAMP (Linux, Apache, MySQL, PHP) stack.
In order to start WordPress installation with LAMP on Ubuntu 16.04, We need a few things to prepare.
- Ubuntu 16.04 server installation: You need to setup Ubuntu 16.04 (Xenial Xerus) on your VPS server. In my case I’m going to use Vultr’s $5 instance with Ubuntu 16.04 x64 as server type.
- Domain (Optional): You also need a registered domain name pointing your server IP address where you want your WordPress installation goes live.
- SSH Access: Make sure that you have root access to your server using SSH. In Windows, you can access your server through SSH using putty.
Install LAMP On Ubuntu 16.04 (Xenial Xerus)
The very first step in WordPress installation after basic Ubuntu 16.04 server configuration is, Installing Apache, MySQL and PHP. To do so, Follow the instructions below and If you already have LAMP stack installed on your server, Click here to jump directly to the WordPress installation steps:
Install Apache Web Server
Apache is a most widely used open source web server software.
In order to run any kind of web application that server files over HTTP like WordPress, Drupal or Joomla, require a web server software that use HTTP to process request and serve files. Most of the WordPress hosting provider use Apache web server software. However, WordPress can run on other web server software like Nginx or Lighttpd as well.
To install Apache web server execute the command below:
sudo apt-get install apache2
Now direct your web browser to your server IP or domain and you should see the default page of apache like below:
If you see the page after browsing your server IP, That’s mean Apache is working.
Install MySQL Database Server
WordPress use MySQL database management system to store and organize data. In this step, We will install MySQL database in Ubuntu 16.04.
In order to install MySQL database, Issue the following command:
sudo apt-get -y install mysql-server mysql-client
Above the command will start installing MySQL database server on your Ubuntu 16.04. It also needs some info like root user password that will be prompted during MySQL server package installation.
Type a secure password when prompted and hit enter twice to proceed further.
The MySQL database server is installed. Now you need to secure the installation by executing the command below in to your terminal:
During the session, you will be asked to enter MySQL root user password that you have set during installation and other security settings like:
VALIDATE PASSWORD PLUGIN: Firstly you will be asked for install the
VALIDATE PASSWORD PLUGINthat check your password strength. In my case I’ve chosen not to setup this plugin. If you want to install
VALIDATE PASSWORD PLUGINtype
yand choose the password strength level.
- Change the password for root: You will also be asked for change the root user password. Answer
nfor no at this prompt to leave root user password unchanged.
- Remove anonymous users: In this prompted answer
yfor yes and hit enter to remove some anonymous users.
At this point, The MySQL server has been installed and now we can move ahead for further steps.
Install PHP 7 and PHP Extensions
WordPress is written using PHP scripting language. You must have PHP installed on your Ubuntu 16.04 server to run WordPress.
Here is the command/code to install PHP 7 and some popular PHP extension that you may need to enhance your WordPress capabilities:
sudo apt-get install php php-curl php-gd php-mbstring libapache2-mod-php php-mcrypt php-mysql php-xml php-xmlrpc
You can also install additional PHP extension using
apt-get as demonstrate above.
After that, we need to restart Apache web server to leverage these new installation. To restart Apache:
sudo service apache2 restart
At this point, We need to create a
info.php file to test if PHP is working in collaboration with your Ubuntu 16.04 web server. To do that, follow the process next.
info.php file in your web root directory
sudo nano /var/www/html/info.php
Now paste the below content to
<?php phpinfo(); ?>
Exit the editor by pressing
Ctrl + x. You will be asked to save the modified file, simply type
y and hit enter to save the changes.
Once you have done with the
info.php file, open your browser and visit
http://your-server-ip/info.php. You should be able to view the PHP information page like this:
Now you have LAMP stack installed on your Ubuntu 16,04.
Now you are ready to start with WordPress installation. Below is the steps of WordPress installation.
Step 1: Create MySQL Database
As I wrote earlier, WordPress uses MySQL database to store and organize data. In an earlier step, We have installed MySQL database server, Now wee need to create a database for WordPress.
To create MySQL database, issue the following command and type root user password when prompted for and hit enter:
mysql -u root -p
After that you should be on the MySQL shell.
Note: We are going to create MySQL wp_database, database_username and database_password. Make sure to use your own DB name, DB User and a secure DB password.
Let’s create a database:
CREATE DATABASE wp_database;
Create a user and grant permission:
GRANT ALL PRIVILEGES ON wp_database.* TO 'database_username'@'localhost' IDENTIFIED BY 'database_password';
Flush privileges and exit from MySQL shell
FLUSH PRIVILEGES; EXIT;
Step 2: Download and extract WordPress
wget https://wordpress.org/latest.tar.gz tar -xzvf latest.tar.gz
Move the extracted files to apache server’s root web directory:
sudo rsync -av wordpress/* /var/www/html/
Now we need to set appropriate permission to the web directory:
sudo chown -R www-data:www-data /var/www/html/ sudo chmod -R 755 /var/www/html/
We are now ready to process further step.
Step 3: Start WordPress Installer
At this step, We are going to run WordPress installer.
Visit your server IP or domain using a web browser and you will get a WordPress installer page asking you for language selection.
Select the language of your WordPress installation and click Continue button.
The welcome screen will shows up, like this:
Click on the Let’s go! button and provide MySQL database connection information that you have created in step 1.
You should left Database Host and Table prefix field at it’s default and click on the Submit button to process further.
Click on Run the install button and you will be asked for provide site information like Site Title, User details etc.
Once you entered site information and user details, Click on the Install WordPress button to finish the installation.
If you don’t receive any fatal error, You should get a success message like above. Click on the Login button to log in your WordPress site.
That’s it, Now you have a WordPress installed on Ubuntu 16.04 server.
Hopping, Everything went as shown here. If you have received any error, please let us know using the comments below. Also don’t forget to let us know your feedback, suggestion or questions concerning any of the steps above.