Learn How to Install WordPress on Ubuntu 16.04 with a LAMP Stack

learn how to install wordpress on ubuntu with a lamp stack

WordPress is a free and open source platform written in php. It is the best content management system. WordPress is used by millions to create websites and blogs around the world.

Install LAMP Stack on Ubuntu 16.04:

To install Apache web server:

Run the commands to install apache web server as below

sudo apt-get update
sudo apt-get install apache2

Open browser and access your ip address or domain name http://ip_address to see the ubuntu apache default page to confirm its working properly as seen the image below.

To install Mysql Server:

Run the following commands to install mysql server

sudo apt-get install mysql-server

During this installation process It will be prompted twice to set root password for mysql as seen the below image. Choose secure password and enter Ok to proceed

To Install PHP and its modules:

to install php and its related modules, execute the following command

sudo apt-get install php7.0 libapache2-mod-php php-mcrypt php-mysql php-gd php-bcmath

After that we have to create info.php file in the /var/www/html directory for testing php is installed or not

sudo nano /var/www/html/info.php

and paste the code below

<?php
phpinfo();
?>

Save and exit

Next open your browser and access your ip_address http://IP_address/info.php or if you have domain name access your domain http://domain_name/info.php to see the php info page as seen the image below for confirmation

PHP testing

Install WordPress on Ubuntu 16.04:

Downlaod the latest wordpress package and extract it by executing following commands:

wget https://wordpress.org/latest.tar.gz

tar -xzvf latest.tar.gz

Next move your wordpress files form extracted folder to /var/www/html directory

sudo mv wordpress/* /var/www/html

Set permissions to your website directory

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Create database:

Execute the following command and type your password

mysql -u root -p

Create new wordpress database:

mysql>CREATE DATABASE mywordpress;
mysql>GRANT ALL PRIVILEGES ON mywordpress.* TO 'username'@'localhost' IDENTIFIED BY 'password';
mysql>FLUSH PRIVILEGES;
mysql>EXIT;

Go to wordpress directory and copy wp-sample-config.php and create wp-config.php

cd /var/www/html
sudo cp wp-config-sample.php wp-config.php

update your database details in the wp-config.php file

After that restart apache and mysql

sudo service apache2 restart
sudo service mysql restart

Open browser and visit your ip address or domain name http://ip_address to get wordpress page.

Note: Before access your ip_address or domain_name delete the Apache default index.html file.

You have successfully installed WordPress on Ubuntu 16.04.

Leave a Reply

Post your comments here

You May Also Like