Install wordpress on ubuntu 20.04 apache

Install wordpress on ubuntu 20.04 apache

WordPress is a popular content management software based on PHP programming language paired with MySQL or MariaDB database.

In this tutorial we will guide you on how to install Wordpress using the LAMP stack.

Let’s proceed with the steps on how to install WordPress on Ubuntu 20.04 with LAMP stack.

1 1. Installing PHP and PHP extension

First we need to install PHP and PHP extensions needed to run WordPress. To do that let us first update our system.

sudo apt update

Let us proceed with the PHP and PHP extensions installation.

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

2 2. Creating Database and Database user

In this step we will create a Database and Database user for our WordPress site. To do that we first we need to enter to the MySQL terminal.

mysql -u root -p

Let’s create a database.

MariaDB [(none)]> create database wordpress;

Let’s create a user and grant all privileges to the database wordpress.

MariaDB [(none)]> grant all privileges on wordpress.* to 'wordpress_user'@'localhost' identified by 'mypassword';

Please don’t forget to change ‘mypassword‘ to your desired password.

Let us save the chages we made and exit;

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

3 3. Download WordPress

Now that PHP and MySQL is setup we will now download WordPress.

First we need to change directory.

cd /var/www/

Let us download WordPress.

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

Let’s extract the file.

tar -xvzf latest.tar.gz

Now we need to create an .htaccess file.

sudo touch /var/www/wordpress/.htaccess

Then open the .htaccess file.

sudo nano /var/www/wordpress/.htaccess

Add the following to the .htaccess file.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Then save and exit.

Let us change the ownership to the Apache user www-data.

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

Let us fix the permission of the WordPress directory. To do that run the 2 commands below.

sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;

The first command will find and set all directories to 755 and the second will look for all the files and set the permission to 644.

4 4. Creating Apache Virtual Host

Let us create a virtual host for our WordPress site.

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

Add the following on the wordpress.com.conf file.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/wordpress
     ServerName domain.com


     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

     <Directory /var/www/wordpress/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

</VirtualHost>

Don’t forget to change the Servername directive to your domain.

Then save and exit.

Before we restart the Apache web server we need to enable the Apache mod_rewrite. To do that run this command.

sudo a2enmod rewrite

Now Let’s enable the virtual host we created.

sudo a2ensite wordpress.com.conf

Then restart the Apache webserver.

sudo systemctl restart apache2

5 5. Finalizing the WordPress Installation

Now that the Apache virtual host is setup you can now access your site to finalize the wordpress installation. To do that you need to open your Web Browser and access your site http://domain.com.

Install wordpress on ubuntu 20.04 apache

Choose your preferred Language then click continue.

Install wordpress on ubuntu 20.04 apache

Click Let’s go.

Install wordpress on ubuntu 20.04 apache

Provide the Database name, the Database Username, and the Database user password that we created in step 2 and just leave the Database host is the Table Prefix as it is then click submit.

Install wordpress on ubuntu 20.04 apache

Click Run the installation.

Install wordpress on ubuntu 20.04 apache

Fill up the forms and click Install WordPress.

Install wordpress on ubuntu 20.04 apache

Congratulation the installation was successful. Now you can start blogging.

6 Conclusion

You have learned how easy to install WordPress on Ubuntu 20.04 with the LAMP stack. If you like this article you might like also our article on Drupal.

If you have questions, feel free to leave a comment and we will try to answer it.

Thank you and hope you enjoy our tutorial ?

How do I install WordPress on Apache?

Install WordPress on Ubuntu 18.04.
Step 1: Install Apache. Let's jump right in and install Apache first. ... .
Step 2: Install MySQL. Next, we are going to install the MariaDB database engine to hold our Wordpress files. ... .
Step 3: Install PHP. ... .
Step 4: Create WordPress Database. ... .
Step 5: Install WordPress CMS..

Is Apache a WordPress?

Most WordPress hosting providers use Apache as their webserver software. However, WordPress can run on other webserver software as well.

How do I install WordPress on a LAMP server?

First, we shall uncover the various steps for the installation of the LAMP stack before progressing to install WordPress..
Step 1: Install Apache Web Server on Ubuntu. ... .
Step 2: Install MySQL Database Server. ... .
Step 3: Install PHP in Ubuntu. ... .
Step 4: Install WordPress in Ubuntu. ... .
Step 5: Create WordPress Database..

How do I install WordPress on Linux Apache MySQL and PHP stack?

htaccess file, we will be installing WordPress in /var/www/wordpress, so we will use it as a directory. Now enable the Apache rewrite module and check the Apache config syntax..
A Linux machine (Here using Ubuntu).
A sudo user account..
Some basic command line experience..
Little MySQL experience..