How to Install WordPress on Ubuntu Server 18.04

How to Host Your Own WordPress Site with Ubuntu 18.04

Install WordPress on Ubuntu Server is, without query, the most widely-used blogging platform on this planet. But the device may be used for lots more than just running a blog.

With the proper addition of extensions, you can morph WordPress into an e-commerce web page, a multimedia web page, and lots extra.

If you appear to have a server of your very own, you may host a WordPress installation, while not having to show to a 3rd party.

And this is precisely what we’re going to do right here. In this tutorial, you’ll discover ways to set up the essential additives in addition to the WordPress platform on Ubuntu Server 18.04.

This will most effective assume one factor: That you’ve got Ubuntu Server up and jogging.


The first thing to do is to get our LAMP (Linux Apache MySQL PHP) server up and jogging.

Since Ubuntu is already there, all that wishes to be carried out is install the secondary components.

Because we’re using Ubuntu, this can be achieved with a unmarried command.

However, earlier than we do that, we need to ensure our server is updated. Open a terminal window and problem the following instructions:

sudo apt-get update
sudo apt-get upgrade

Should the kernel get upgraded in the technique, a reboot may be vital.

If that’s the case, the server will want to be restarted (so the modifications will take effect).

This means you have to run the replace/upgrade at a time when a reboot is viable.

With the update/upgrade out of the way, it’s time to install the web/database servers and PHP.

This can be finished with a unmarried command:

sudo apt-get install lamp-server^

During the set up, you’ll be brought on to create/affirm a password for the MySQL admin user.

When the system completes, you can point a browser to http://SERVER_IP (Where SERVER_IP is the IP cope with of your Ubuntu Server) to look the Apache welcome display screen.

Next we have to set up some necessary PHP extensions. This may be carried out with the command:

sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Enabling SSL

Before we get into the configuration of Apache and the set up of WordPress, we’re going to prepare our server to apply SSL (Secure Sockets Layer), that are numerous web protocols that paintings collectively to wrap normal HTTP site visitors in a protected, encrypted wrapper.

So HTTP becomes HTTPS. As I am only putting in place a testing server, I’ll be growing a self-signed SSL certificates for an IP address. To do that, observe those steps.

Generate the SSL certificate with the following command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt

When you run that command, you’ll be required to answer the subsequent questions:

Country Name (2 letter code) [AU]: State or Province Name (complete name) [Some-State]: Locality Name (eg, metropolis) []: Organization Name (eg, organization)[] Organizational Unit Name (eg, segment) []: Common Name (e.G. Server FQDN or YOUR name) []: Email Address []:

It is vital, for the self-signed certificate, which you enter the IP cope with of your server for the Common Name entry.

Next we configure Apache to use SSL. Create a new document with the command:

sudo nano /etc/apache2/conf-available/ssl-params.conf

In that new file, paste the following:

SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the "preload" directive if you understand the implications.
# Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
# Requires Apache >= 2.4
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
# Requires Apache >= 2.4.11
SSLSessionTickets Off

Save and near that file.

Install WordPress on Ubuntu Server, Secure Sockets Layer

Now we’re going to create a brand new default-ssl.Conf report. Before we try this, backup the unique with the command:

sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/default-ssl.conf.bak

Create the new file with the command:

sudo nano /etc/apache2/sites-available/default-ssl.conf

In that new file, paste the following:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin YOUR_EMAIL
ServerName SERVER_IP
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile     /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars

Where SERVER_IP is the IP address of your server and YOUR_EMAIL is your electronic mail deal with.

Save and close that report.

Now we’re going to set up a redirect so that each one HTTP visitors is routinely redirected to HTTPS. To do that, create a new file with the command:

sudo nano /etc/apache2/sites-available/000-default.conf

In that file, add the following line under the DocumentRoot entry:

Redirect “/” “https://SERVER_IP/”

Where SERVER_IP is the IP address of your server.

Save and close that file.

Next we need to enable a few modules and hosts with the commands:

sudo a2enmod ssl
sudo a2enmod headers
sudo a2ensite default-ssl
sudo a2enconf ssl-params

Install WordPress on Ubuntu Server Finally, restart Apache with the command:

sudo systemctl restart apache2

You need to now be able to point your browser to https://SERVER_IP (Where SERVER_IP is the IP cope with of your server) and nonetheless see the Apache Welcome Screen.

Install WordPress on Ubuntu Server, The Database

WordPress depends upon a database to characteristic. To create that, you first ought to log into the MySQL prompt with the command:

mysql -u root -p

You can be brought on for the MySQL admin consumer password you created in the course of the LAMP server installation. At the MySQL activate, create the database with the command:


Next, create a new consumer and supply that person permission to access the database with the command:

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'PASSWORD';

Install WordPress on Ubuntu Server, Where PASSWORD is a unique, robust password.

Flush the database privileges and exit with the instructions:


Allow .htaccess and Enable the Rewrite Module

We need to allow .Htaccess for WordPress. To do this, create a new Apache configuration file with the command:

sudo nano /etc/apache2/sites-available/wordpress.conf

In that report paste the subsequent:

<Directory /var/www/html/wordpress/>
AllowOverride All

Enable the rewrite module with the command:

sudo a2enmod rewrite

Restart Apache with the command:

sudo systemctl restart apache2

Download, Unpack, and Prepare WordPress

We’re going to download the official WordPress file with the following commands:

cd /tmp
curl -O

Unpack WordPress with the command:

tar xvzf latest.tar.gz

Create a dummy .htaccess file with the command:

touch /tmp/wordpress/.htaccess

Copy the sample configuration file to the necessary config file with the command:

cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

Create an upgrade directory (to avoid permissions issues) with the command:

mkdir /tmp/wordpress/wp-content/upgrade

Copy the contents of the wordpress directory into the document root with the command:

sudo cp -a /tmp/wordpress/. /var/www/html/wordpress

Finally, adjust the ownership and permissions of the newly moved wordpress directory with the commands:

sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

Configuring WordPress

This phase gets a bit complicated. The wp-config.Hypertext Preprocessor report wishes to be edited, however before that can be carried out, you should download unique mystery keys to be delivered to the config record. To get the ones keys, difficulty the command:

Install WordPress on Ubuntu Server, This will output some of lengthy strings, every related to a particular configuration option.

Each string is related to the subsequent values inside the configuration file:


Copy those values into another file. Next open the WordPress configuration file with the command:

sudo nano /var/www/wordpress/wp-config.php

Locate the values above and paste the secret key for each. After that, scroll up and edit the values for:


The above values were created in advance (with MySQL).

Save and close that record.

Install WordPress on Ubuntu Server, Complete the Installation

You can now point your browser to https://SERVER_IP/wordpress and walk through the web-primarily based installer to finish the set up.

After multiple clicks and a piece of typing, your instance of WordPress may be up and walking.