Installing WordPress on Ubuntu Linux

This tutorial will show you all the steps required to install WordPress on Ubuntu Linux.

This tutorial was tested on Ubuntu 18.04.

Installing MySQL on Ubuntu Linux

WordPress requires a database system to store all its configuration.

Use the Ubuntu APT command to install the MySQL server.

# apt-get update
# apt-get install mysql-server mysql-client

Use the following command to access the MySQL service console.

# mysql -u root -p

On the MySQL console, you need to perform the following tasks:

• Create a database named wordpress.
• Create a MySQL user account named wordpress.
• Give full control over the wordpress database to the wordpress user.

CREATE DATABASE wordpress CHARACTER SET UTF8 COLLATE UTF8_BIN;
CREATE USER 'wordpress'@'%' IDENTIFIED BY 'kamisama123';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'%';
FLUSH PRIVILEGES;
quit;

Installing Apache on Ubuntu Linux

WordPress requires a web server with PHP support to present its web pages.

Use the Ubuntu APT command to install the Apache server.

# apt-get update
# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# service apache2 restart

Optional. Use the following command to install the Apache most used PHP modules.

# apt-get install php7.2-xml php7.2-curl php7.2-gd php7.2-mbstring
# apt-get install php7.2-bz2 php7.2-zip php7.2-xml php7.2-curl
# apt-get install php7.2-json php7.2-opcache php7.2-readline

Optional. Use the following command to enable apache mod_rewrite and SSL.

Only enable the SSL module if you are planning to offer HTTPS content.

# a2enmod rewrite
# a2enmod ssl
# service apache2 restart

Find the location of the PHP configuration file on your system.

Edit the php.ini configuration file.

# updatedb
# locate php.ini
# vi /etc/php/7.2/apache2/php.ini

Your PHP version may not be the same as ours.

Your PHP configuration file location may not be the same as ours.

Here is the file with our configuration.

file_uploads = On
max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
max_input_time = 60
max_input_vars = 4440

Restart the Apache web server manually.

# service apache2 restart
# service apache2 status

Verify the Apache service status.

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Mon 2018-12-03 03:41:12 -02; 2 days ago

Installing WordPress on Ubuntu Linux

After finishing the MySQL and the Apache configuration, we can start the WordPress installation.

Download the WordPress latest version and extract the package.

# cd /tmp
# wget https://wordpress.org/latest.tar.gz
# tar -zxvf latest.tar.gz

Move the WordPress folder inside your Apache root drive directory.

Give the www-data user full control over the WordPress directory and its files.

# mv wordpress /var/www/html/
# chown www-data.www-data /var/www/html/wordpress/* -R

Create and edit the WordPress configuration file wp-config.php.

# cd /var/www/html/wordpress
# mv wp-config-sample.php wp-config.php
# vi wp-config.php

Edit the MySQL database connection information located on the wp-config.file.

As an example, here is the file with our configuration.

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'kamisama123');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

Configuring WordPress on Ubuntu Linux

Open your browser and enter the IP address your web server plus /wordpress.

In our example, the following URL was entered in the Browser:

• http://200.200.200.200/wordpress

The WordPress installation wizard will be presented.

Wordpress Select Language

On the next screen you will have to enter your website information.

wordpress website information

On the next screen, you will receive the confirmation of your WordPress installation.

wordpres finished installation

Click on the Login button and enter the administrator account and password.

After a successful login, The WordPress dashboard will be displayed.

Wordpress dashboard