How to Install WordPress and LAMP Stack on Ubuntu 16

Here are steps on how to install WordPress on a VPS or Dedicated Server with Ubuntu 16.x as OS:

WordPress Require Web Server, PHP and Mysql, we are going to install Apache for Web Server and PHP 7.0 for PHP

Step 1: Install Apache:

To install Apache web server, issue the command below:

# apt-get install apache2 apache2-utils 

Now start Apache and also enable Apache to start automatically on every reboot:

# systemctl enable apache2

# systemctl start apache2

By default root directory for Apache Web Server is /var/www/html, so we are going to store/upload all fines in this directory.

Step 2: Install MySQL:

Install Mysql as Under:

#apt-get install mysql-client mysql-server

While installation of Mysql Database Server is going on you will be asked to enter Mysql Root Password, please enter a secure password, you will need to type same password twice.

Once mysql is installed run following command to secure mysql installation:


Step 3: Install PHP and required PHP Modules:

Install PHP As under:

# apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd  

Step 4: Download and Install WordPress

Download the latest WordPress package and extract it by issuing the commands below on the terminal:

First change to our Apache Root Directory:

# cd /var/www/html

Download WordPress:

# wget -c

Now untar and unzip wordpress files:

# tar -xzvf latest.tar.gz

Now copy wordpress files to /var/www/html as untarred files are extracted in a sub-directory – wordpress.

# cp -R ./wordpress/* ./*

Now remove all unneeded files and directories:

# rm -rf ./wordpress ./latest.tar.gz

Now set required file and directory permissions so that apache can access wordpress files:

# chown -R www-data:www-data /var/www/html/

# chmod -R 755 /var/www/html/

Step 5: Create Database for WordPress:

Run the command below and provide the mysql root user password, then hit Enter to move to the mysql shell:

# mysql -u root -p 

At the mysql shell, type the following commands, pressing Enter after each line of a mysql command. Replace wp_user with a username of your choice, and wp_password with a secure password:

mysql> CREATE DATABASE wp_blog;

mysql> GRANT ALL PRIVILEGES ON wp_blog.* TO ‘wp_user’@’localhost’ IDENTIFIED BY ‘wp_password’;


mysql> EXIT;

Go the /var/www/html/ directory and rename existing wp-config-sample.php to wp-config.php:

# cd /var/www/html

# mv wp-config-sample.php wp-config.php

Now update wp-config.php with your database information under the MySQL settings section 

Now restart the Apache web server and mysql service using the commands below:

# systemctl restart apache2.service 

# systemctl restart mysql.service 

Also delete the default index.html or index.htm file from /var/www/html else it won’t open worpdress:

# cd /var/www/html

# rm -rf index.htm index.html

Now Open your web browser and go to http://your_server_ip and it should start WordPress Installation/Configuration Wizard just follow it and your WordPress Installation should be ready.

Support 24/24h with coupon code: 1DOLLAROFF 10% discount. Click now! 👆