YouTube Icon

Code Playground.

How to Install WordPress with Apache on Ubuntu 18.04


How to Install WordPress with Apache on Ubuntu 18.04

WordPress is by a wide margin the most well known open-source contributing to a blog and CMS stage that controls over a fourth of the world's sites. It depends on PHP and MySQL and packs a huge load of highlights that can be reached out with free and premium modules and topics. WordPress empowers you to effectively fabricate your eCommerce store, site, portfolio or blog. 

In this instructional exercise, we will tell you the best way to introduce WordPress on a Ubuntu 18.04 machine. It is a genuinely clear cycle that takes under ten minutes to finish. At the hour of composing this article, the most recent form of WordPress is adaptation 5.0.2. 

We'll be utilizing a LAMP stack with Apache as a web worker, SSL authentication, the most recent PHP 7.2 and MySQL/MariaDB as an information base worker. 


Guarantee the accompanying essentials are met prior to proceeding with this instructional exercise: 

Have a space name highlighting your worker public IP. We'll utilize 

Signed in as a client with sudo advantages . 

Apache introduced by adhering to these directions . 

You have a SSL declaration introduced for your space. You can introduce a free Let's Encrypt SSL declaration by adhering to these directions . 

Update the bundles rundown and redesign the introduced bundles to the most recent forms: 

sudo apt update
sudo apt upgrade

Creating a MySQL database

WordPress utilizes MySQL information base to store all its information like posts, pages, clients, modules and topics settings. We'll begin by making a MySQL information base, MySQL client record and award admittance to the information base. 

On the off chance that you don't have MySQL or MariaDB introduced on your Ubuntu worker you can do that by following one of the aides beneath: 

Introduce MySQL on Ubuntu 18.04 

Introduce MariaDB on Ubuntu 18.04 

Login to the MySQL shell by composing the accompanying order: 

sudo mysql

From inside the MySQL shell, run the accompanying SQL proclamation to make an information base : 

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Next, make a MySQL client record and award admittance to the information base: 

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

At long last, leave the mysql support by composing: 


Installing PHP

PHP 7.2 which is the default PHP form in Ubuntu 18.04 is completely upheld and suggested for WordPress. 

To introduce PHP and all necessary PHP augmentations run the accompanying order: 

sudo apt install php7.2 php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl

Restart apache so the recently introduced PHP expansions are stacked: 

sudo mkdir -p /var/www/

Downloading Wordpress 

Prior to downloading the Wordpress file, first make an index which will hold our WordPress documents: 

sudo mkdir - p/var/www/ 

The subsequent stage is to download the most recent variant of WordPress from the WordPress download page utilizing the accompanying wget order : 

cd /tmp

Once the download is finished, separate the chronicle and move the removed records into the area's report root index: 

tar xf latest.tar.gz
sudo mv /tmp/wordpress/* /var/www/

Set the right authorizations with the goal that the web worker can have full admittance to the website's documents and catalogs utilizing the accompanying chown order : 

sudo chown -R www-data: /var/www/

Configuring Apache

At this point, you should as of now have Apache with SSL endorsement introduced on your framework, if not check the essentials for this instructional exercise. 

The subsequent stage is to alter the Apache virtual hosts setup for our WordPress space: 

sudo nano/and so on/apache2/locales accessible/ 

The accompanying Apache arrangement diverts HTTP to HTTPS and www to non-www rendition of your space and empowers HTTP2. Remember to supplant with your Wordpress area and set the right way to the SSL declaration records. 


<VirtualHost *:80>

  Redirect permanent /

<VirtualHost *:443>

  Protocols h2 http/1.1

  <If "%{HTTP_HOST} == ''">
    Redirect permanent /

  DirectoryIndex index.html index.php
  DocumentRoot /var/www/

  ErrorLog ${APACHE_LOG_DIR}/
  CustomLog ${APACHE_LOG_DIR}/ combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/
  SSLCertificateKeyFile /etc/letsencrypt/live/
  SSLCertificateChainFile /etc/letsencrypt/live/

  <Directory /var/www/>
      Options FollowSymLinks
      AllowOverride All
      Require all granted


Empower the virtual host for the area. The order underneath will make an emblematic connection from the locales accessible to the destinations empowered index: 

sudo a2ensite

For the new setup to produce results, restart the Apache administration by composing: 

sudo systemctl restart apache2

Since Wordpress is downloaded and the worker setup is finished, the time has come to conclude the WordPress establishment through the web interface. 

Completing the WordPress InstallationOpen your program, type your area and a screen like the accompanying will show up: 

Select the language you might want to utilize and tap on the Continue button. 

Next, you will see the accompanying data page, click on the Let's go! button. 

On the following screen, the arrangement wizard will request that you enter your information base association subtleties. Enter the MySQL client and information base subtleties you recently made. 

Introduce wordpress information base data 

Start the establishment by tapping on the Run the Installation button. In the subsequent stage, you'll need to enter a name for your WordPress site and pick a username (for security purposes don't enter "administrator" ). 

The installer will naturally produce a solid secret word for you. Remember to spare this secret word. You can likewise set the secret word without help from anyone else. 

Enter your email address and select whether you need to debilitate web crawlers from ordering the website (not suggested). 

he establishment is finished you will be taken to a page illuminating you that WordPress has been introduced. To get to your WordPress login structure click on the Log in catch. 

Enter your username and secret key and snap on the Log in catch. 

When you sign in, you will be diverted to the WordPress organization dashboard. From here, you can begin modifying your WordPress establishment by putting in new topics and modules. 


Congrats, you have effectively introduced WordPress with Apache on your Ubuntu 18.04 worker. Initial Steps With WordPress is a decent beginning spot to study how to begin with WordPress. 

In the event that you have questions, don't hesitate to leave a remark underneath.