WordPress is Website Development, Blogging and Web Hosting Company, which is very Convenient for those who are intrested in Website related stuff like creating website, Web hosting just because of it’s highly customizable features, easily available plugins and options like media embedding ( Video and Audio file embedding ), Onpage Seo Checker tools and so on.

Download Free Linux eBook HERE! "Learn Linux in 5 Days" - A Free Linux eBooks for Beginners

The main Advantages for those people whose passion is blogging but don’t have technical knowledge like Website Designing, hosting etc….Just because of WordPress today they able to do the same. Here we are going to install wordpress with LAMP Stack.

Follow the below steps to install WordPress in Ubuntu 16.04

To Setup WordPress below tasks to be perform :

Update the System with all Packages and Repositories

Install Apache Webserver, PHP, PhpMyAdmin and My SQL Server ( LAMP Stack )

Then install WordPress Package

After install all required packages create database in MySQL Server by using PhpMyAdmin and cofigure the database with wordpress.

Then create credential to login WordPress admin page.

So let’s perform the tasks…..

STEP 1 : Update the Packages & Repositories

Before Install above packages Let’s install/update newer version of packages and their dependencies.

So update the packages by below command.

~$ sudo apt-get update # Update Packages and Dependencies [sudo] password for elinuxbook: Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB] Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB] Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [92.2 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages [159 kB] Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [418 kB] Get:7 http://us.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [163 kB] Get:8 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 DEP-11 Metadata [337 kB] Get:9 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [67.8 kB] Get:10 http://security.ubuntu.com/ubuntu xenial-security/main i386 DEP-11 Metadata [79.2 kB] Get:11 http://us.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [200 kB] Get:12 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [62.9 kB] Get:13 http://security.ubuntu.com/ubuntu xenial-security/restricted i386 Packages [6,528 B] Get:14 http://security.ubuntu.com/ubuntu xenial-security/restricted Translation-en [2,016 B] Get:15 http://security.ubuntu.com/ubuntu xenial-security/restricted i386 DEP-11 Metadata [199 B] Get:16 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages [56.9 kB] Get:17 http://us.archive.ubuntu.com/ubuntu xenial-updates/restricted i386 Packages [6,528 B] Get:18 http://us.archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2,016 B] Get:19 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [357 kB] Get:20 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [33.4 kB] Get:21 http://security.ubuntu.com/ubuntu xenial-security/universe i386 DEP-11 Metadata [7,418 B] Get:22 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [16.4 kB] Get:23 http://security.ubuntu.com/ubuntu xenial-security/multiverse i386 Packages [2,928 B] Get:24 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [131 kB] Get:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1,124 B] Get:26 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 DEP-11 Metadata [106 kB] Get:27 http://security.ubuntu.com/ubuntu xenial-security/multiverse i386 DEP-11 Metadata [199 B] Get:28 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [126 kB] Get:29 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 Packages [6,172 B] Get:30 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [2,988 B] Get:31 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 DEP-11 Metadata [2,529 B] Get:32 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse DEP-11 64x64 Icons [9,227 B] Get:33 http://us.archive.ubuntu.com/ubuntu xenial-backports/main i386 Packages [4,400 B] Get:34 http://us.archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [3,104 B] Get:35 http://us.archive.ubuntu.com/ubuntu xenial-backports/main i386 DEP-11 Metadata [195 B] Get:36 http://us.archive.ubuntu.com/ubuntu xenial-backports/universe i386 Packages [2,412 B] Get:37 http://us.archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [1,216 B] Get:38 http://us.archive.ubuntu.com/ubuntu xenial-backports/universe i386 DEP-11 Metadata [198 B] Fetched 2,503 kB in 22s (111 kB/s) AppStream cache update completed, but some metadata was ignored due to errors. Reading package lists... Done

As shown on above output all packages are now up to date, Now use below command to Install Apache Web Server.

STEP 2 : Install Apache Web Server Package

~$ sudo apt-get install apache2 # Install Apache2 Package Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 0 upgraded, 9 newly installed, 0 to remove and 395 not upgraded. Need to get 1,628 kB of archives. After this operation, 6,253 kB of additional disk space will be used. Do you want to continue? [Y/n] y

Now it’s asking to Enter “Y” to proceed for further installation, So press “Y”

Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for systemd (229-4ubuntu4) ... Processing triggers for ufw (0.35-0ubuntu2) ...

As we can see above the apache2 Package installed successfully, We can verify if apache2 package is installed or not by below command.

~$ sudo dpkg -l apache2 # Confirm if Apache2 Package is installed [sudo] password for elinuxbook: Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-============-============-================================= ii apache2 2.4.18-2ubun i386 Apache HTTP Server

As per output above the apache2 package is installed.

Now open the Web-Browser and enter “localhost” to check apache2 default page is showing or not.

So apache web service is working fine as shown on the snapshot above.

STEP 3 : Install PHP Package

Let’s go ahead and install php by below command.

~$ sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-cli php7.0-cgi php7.0-gd # Install PHP7.0 Package Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: php-common php7.0-common php7.0-opcache php7.0-readline Suggested packages: php-pear The following NEW packages will be installed: libapache2-mod-php7.0 php-common php7.0 php7.0-cgi php7.0-cli php7.0-common php7.0-curl php7.0-gd php7.0-json php7.0-mysql php7.0-opcache php7.0-readline 0 upgraded, 12 newly installed, 0 to remove and 403 not upgraded. Need to get 5,054 kB of archives. After this operation, 21.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y

Now it’s asking to Enter “Y” to proceed for further installation, So press “Y”

Creating config file /etc/php/7.0/cgi/php.ini with new version Setting up php7.0 (7.0.8-0ubuntu0.16.04.3) ... Setting up php7.0-curl (7.0.8-0ubuntu0.16.04.3) ... Creating config file /etc/php/7.0/mods-available/curl.ini with new version Setting up php7.0-gd (7.0.8-0ubuntu0.16.04.3) ... Creating config file /etc/php/7.0/mods-available/gd.ini with new version Setting up php7.0-mysql (7.0.8-0ubuntu0.16.04.3) ... Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version Processing triggers for libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.3) ...

As we can see above the php package installation process has been completed, We can verify if php package is installed or not by below command.

~$ sudo dpkg -l php7.0 # Confirm if PHP7.0 Package is installed Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==============-============-============-================================= ii php7.0 7.0.8-0ubunt all server-side, HTML-embedded script ~$

As we can see above php is installed, now restart the apache2 service to take effect by below command.

~$ sudo /etc/init.d/apache2 restart # Restart Apache2 Service [ ok ] Restarting apache2 (via systemctl): apache2.service.

Now let’s go ahead and test if php is working properly or not, for that create a file under Document Root of apache i.e. “/var/www/html” and then enter “<?php phpinfo(); ?>” to check php information.

Follow the below steps to do the same :-

Enter the below code in file to check if php is working fine and then save. <?php phpinfo(); ?> # to check the PHP Information Note: I prefer “nano” as a text editor, you can use “vi” or any other text editor.

~$ sudo nano /var/www/html/file.php # Create a file

Restart the apache2 service then open the web browser and then enter “http://localhost/file.php”

PHP is working fine as shown on the above snapshot.

STEP 4 : Install MySQL Database Server Package

Now it’s time to install mysql-server, follow the below command to install the same.

~$ sudo apt-get install mysql-server # Install mysql-server Package Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 Suggested packages: libipc-sharedcache-perl mailx tinyca The following NEW packages will be installed: libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7 0 upgraded, 9 newly installed, 0 to remove and 395 not upgraded. Need to get 18.7 MB of archives. After this operation, 157 MB of additional disk space will be used. Do you want to continue? [Y/n] y

As shown above on the output its asking to enter “Y” to proceed the installation process, So enter “Y“.

Now its asking to set the password for mysql-server login for the user “root“.

Confirm the password by Re-Entering the same password.

Setting up libaio1:i386 (0.3.110-2) ... Setting up mysql-client-core-5.7 (5.7.16-0ubuntu0.16.04.1) ... Setting up mysql-client-5.7 (5.7.16-0ubuntu0.16.04.1) ... Setting up mysql-server-core-5.7 (5.7.16-0ubuntu0.16.04.1) ... Setting up mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) ... update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode Renaming removed key_buffer and myisam-recover options (if present) Setting up libhtml-template-perl (2.95-2) ... Setting up mysql-server (5.7.16-0ubuntu0.16.04.1) ... Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for systemd (229-4ubuntu4) ...

mysql-server installation process has been completed, we can verify if mysql-server package is installed or not by below command.

~$ sudo dpkg -l mysql-server # Confirm if mysql-server Package is installed [sudo] password for elinuxbook: Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=============================-===================-===================-================================================================ ii mysql-server 5.7.16-0ubuntu0.16. all MySQL database server (metapackage depending on the latest versi

STEP 5 : Install WordPress Package

Now Let’s go ahead and install WordPress Package :

Before Installation we have to download wordpress package as shown below.

~$ sudo wget https://www.wordpress.org/latest.tar.gz # Download WordPress Package [sudo] password for elinuxbook: --2016-11-21 08:57:26-- https://www.wordpress.org/latest.tar.gz Resolving www.wordpress.org (www.wordpress.org)... 66.155.40.250, 66.155.40.249 Connecting to www.wordpress.org (www.wordpress.org)|66.155.40.250|:443... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://wordpress.org/latest.tar.gz [following] --2016-11-21 08:57:32-- https://wordpress.org/latest.tar.gz Resolving wordpress.org (wordpress.org)... 66.155.40.250, 66.155.40.249 Connecting to wordpress.org (wordpress.org)|66.155.40.250|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 7961036 (7.6M) [application/octet-stream] Saving to: ‘latest.tar.gz’ latest.tar.gz 100%[==================================================================>] 7.59M 124KB/s in 65s 2016-11-21 08:58:38 (120 KB/s) - ‘latest.tar.gz’ saved [7961036/7961036]

So we successfully downloaded the WordPress Package, as we can see above on output we have downloaded the package on elinuxbook user home directory as a latest.tar.gz as shown below.

but we need it on Apache Webserver Document Directory i.e. “/var/www/html“.

so let’s extract the latest.tar.gz file on /var/www/html as shown below.

~$ cd /var/www/html/ $ sudo tar -xzvf /home/elinuxbook/latest.tar.gz # Extract WordPress Compressed Package

After extract the latest.tar.gz we got a wordpress (Hilighted in Yellow Color) directory on “/var/www.html” as shown below on the output.

But as we can see the Owner of the WordPress Directory is nobody:nogroup (Highlighted in Blue Color), So we need to change the Ownership to www-data by chown command, So follow the below step.

$ ls -l total 16 -rw-r--r-- 1 root root 11321 Nov 21 08:05 index.html drwxr-xr-x 5 nobody nogroup 4096 Sep 7 07:59 wordpress $ sudo chown www-data:www-data -R wordpress/ elinuxbook@ubuntu:/var/www/html$ ls -l total 16 -rw-r--r-- 1 root root 11321 Nov 21 08:05 index.html drwxr-xr-x 5 www-data www-data 4096 Sep 7 07:59 wordpress

As we can see above on output the Ownership has been changed to www-data:www-data (Hilighted in Orange Color), So our installation part is over, now it’s time of configuration and WordPress web access.

STEP 6 : Create Database and User in MySQL Server

we need to logging in MySQL Database server to create WordPress database, So follow the below steps to do the same.

Login to MySQL server by user root and use the password which we had set during MySQL Database Server package installation.

~$ mysql -u root -p # Login as a root with it's password Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> create database mywpdb; # Create a Database for WordPress Query OK, 1 row affected (0.06 sec) mysql> create user 'wplocal'@'localhost' identified by 'pass@123'; # Create a User & It's Password for Authentication Query OK, 0 rows affected (0.21 sec) mysql> grant all privileges on mywpdb.* to 'wplocal'@'localhost'; # Grant Previleges to above created user (wplocal) to access the Database (mywpdb) Query OK, 0 rows affected (0.09 sec) mysql> flush privileges; # Now Flush the Privileges Query OK, 0 rows affected (0.16 sec) mysql> exit # Logout from SQL Server Bye

~$ sudo /etc/init.d/apache2 restart #Restart the Apache2 Service [ ok ] Restarting apache2 (via systemctl): apache2.service.

STEP 7 : WordPress Configuration with Database (wp-config.php)

Before open the WordPress webaccess we need to do some configuration in WordPress Website Documents, Please follow the below steps :-

Change the Directory to “/var/www/html/wordpress” as shown below…

~$ cd /var/www/html/wordpress

As we can see above on the snapshot “wp-config-sample.php” is the sample configuration file of the WordPress, So Let’s copy the wp-config-sample.php as wp-config.php as shown below.







Now edit “wp-config.php” as shown below and go to MySQL settings section :

Now Enter the Required details i.e. Database Name, Database Username, Database Password & Host.

After changes the configuration should look like shown above on snapshot.

All above details (Database Name, Username, Password) are we had created on Step : 5

Note : Above mentioned database details are given as per my Scenario You have to mention all details as per yours.

Now restart the apache2 Service to take effect.

STEP 8 : Access WordPress Web Access

Access the WordPress Web-access by URL http://localhost/wordpress

As shown on the Snapshot above select the Language and Click on Continue

As per above snapshot it’s asking for MySQL Database and Login details which we have already mentioned on wp-config.php file, So click on Let’s go! Button.

Now on our next step it’s asking to enter your WordPress Account details Like Username, Password, Email ID…etc… for wordpress web login

So you can enter as per your choice and then click on Install WordPress.

Note : On Step:5 we had created username and password for MySQL WordPress database authentication and here on above snapshot we are going to create username password for WordPress Web Login, So Please don’s get confused.

Now click on Login.

Here Enter Username and Password to login WordPress Webaccess.

Note: Here enter the Username and Password we have created on Step : 7

Atlast we are able to successfully logged in the WordPress Portal as shown on the snapshot above.

So we successfully installed and Configured the WordPress Version 4.6.1 with LAMP Stack on Ubuntu 16.04, For any Query please feel free to comment us on below comment box.