Installing wordpress on Ubuntu

Install Apache

First check whether apache is already installed

service apache2 status

if not, install it by issuing the following command

sudo apt-get install apache2 apache2-utils

To make apache service run at boot time, this is optional in case if you want to start the service manually, if you have not selected the auto start option below

sudo service apache2 start
 sudo systemctl enable apache2
sudo systemctl enable apache2
sudo systemctl start apache2

Check whether it is up and running

$ service apache2 status
● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
Active: active (running) since Sun 2018-12-23 16:15:22 IST; 2min 20s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/apache2.service
├─11260 /usr/sbin/apache2 -k start
├─11263 /usr/sbin/apache2 -k start
└─11264 /usr/sbin/apache2 -k start

Starting LSB: Apache2 web server…
Starting Apache httpd web server apach
AH00557: apache2: apr_sockaddr_info_get()
AH00558: apache2: Could not reliably dete
apache2[11230]: *
systemd[1]: Started LSB: Apache2 web server.

Go to your default web browser, and type localhost or This should result in displaying the default apache2 web page.

Apache Web Server homepage

The web server serves the default home page from a web directory. The default root web directory for apache on Ubuntu is /var/www/html, all your web files will be stored in this directory.

By default, Ubuntu has mysql installed with it. Just in case if it is not found you could run the command

sudo apt-get install mysql-client mysql-server

Install PHP

Lastly we need to install php.

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

To check whether it has been installed,

:~$ whereis php
php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.0-readline /usr/share/php7.0-mysql /usr/share/php7.0-opcache /usr/share/php7.0-gd /usr/share/php7.0-common /usr/share/php7.0-json /usr/share/man/man1/php.1.gz

Other possible way to check if php is working fine, in collaboration with the apache web server, create a info.php file inside /var/www/html

This should result in a web page like the one displayed below when we key in the url localhost/info.php


That completes the pre-requisites installation for a functional wordpress.

Installing WordPress

Download the latest of wordpress and extract it, extracting the latest.tar.gz would result in wordpress directory created.

$ wget -c
$ tar -xzvf latest.tar.gz

Move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:

$ sudo cp -r wordpress/* /var/www/html/

Next, set the correct permissions on the website directory, that is give ownership of the WordPress files to the web server as follows:

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

In case of uploading themes or folder, you may encounter php_file_upload_size limit error, to work around this

  1. using terminal (cmd) and connect to your server via ssh code
  2. type cd \ to go root folder
  3. type sudo nano /etc/php/7.0/apache2/php.ini
  4. add after php.ini file upload_max_filesize = 32M post_max_size = 32M => save your php.ini file
  1. type : sudo service apache2 restart