How to Install WordPress on Ubuntu 20.04 Tutorial (Step by Step)

How To Install WordPress on Ubuntu 20.04 (Step by Step). The world of open source software development is fascinating to dive into for any developer.  The list of successful open source projects used by enterprises and individual developers is enormous. Some open source projects go on to become the industry standard software for their respective field.  One of the most popular and free content management system is WordPress.

This article takes you through installing and setting up WordPress on Ubuntu operating system. In particular, this article discusses configuring WordPress on Linux distribution, Ubuntu 20.04.

What is WordPress

Any website you visit during your daily internet browsing, be it a personal blog or an online eCommerce store, was likely built using WordPress. Most beginner website owners opt for WordPress due to its user friendly experience and easy to setup configurations. Users can upgrade and maintain their websites quickly and from anywhere. The final website can be hosted on any popular hosting service, like WordPress for Windows Server.

WordPress websites can be configured, and their features extended through Themes and Plugins. The aesthetics and visual design of the WordPress website are managed by selecting from thousands of themes or making a custom one. Similarly, the website’s functionalities are configured by integrating various of WordPress’s own or third-party plugins.

 

As an open source project, WordPress was developed to give internet users an easy way to publish and create websites for themselves. It has became the most popular choice for websites with CMS

Among the many features it offers, WordPress websites come with high security, which can be further enhanced by integrating high end security plugins.  The websites are SEO friendly and are optimized for smooth performance and user experience. WordPress also provides its users with powerful options to manage all different kinds of media. 

Ubuntu Linux

Linux is one of the earliest projects that inspired the now global and vast open source movement.   It has become one of the most widely used Linux distributions currently available. It offers some of the most robust open source security configurations and is also preferred in software houses for its low costs. 

Let’s move to how to Install WordPress on Ubuntu 20.04.

How to Install WordPress on Ubuntu 20.04

Prerequisites

Both hugely favorite open-source projects, it is hardly surprising that Ubuntu’s official website provides the instructions for installing WordPress on the OS. The instructions are a series of simple terminal instructions that install all the relevant dependencies and then WordPress’s package itself.

 

Discussed below are all the directions of installing WordPress on Ubuntu. These instructions are intended for the 20.04 release of Ubuntu.

  • We will firstly update the apt package installer.
				
					sudo apt update
				
			

Install PHP Extensions

Next, we will install the technologies that support WordPress: popular web development language PHP and the open source web server server platform Apache. The following instructions installs all the mentioned packages.

				
					sudo apt install apache2 \
                 ghostscript \
                 libapache2-mod-php \
                 mysql-server \
                 php \
                 php-bcmath \
                 php-curl \
                 php-imagick \
                 php-intl \
                 php-json \
                 php-mbstring \
                 php-mysql \
                 php-xml \
                 php-zip

				
			

The WordPress package we are going to install is the official release from WordPress.org. First we will make the directory and change its permissions to download our installation in.

				
					sudo mkdir -p /srv/www
sudo chown www-data: /srv/www

				
			

The following instruction downloads the WordPress package.

				
					curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www
				
			

Configure Apache

Now, we need to configure the Apache web server site for WordPress. We create a file in the with the path /etc/apache2/sites-available/wordpress.conf and copy the following into the conf file (edit your ServerName and ServerAlias).

				
					    <VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /srv/www/wordpress
     ServerName sitename.com
     ServerAlias www.sitename.com
     <Directory /srv/www/wordpress/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
     CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>
				
			

We will now enable the site and enable URL writing.

				
					sudo a2ensite wordpress
sudo a2enmod rewrite

				
			

Now, we reload apache2.

				
					sudo service apache2 reload
				
			

Run the following command to disable the default page so that WordPress loads.

				
					sudo a2dissite 000-default
				
			

Create MySQL Database for WordPress

Now, let’s create a MySQL database for our WordPress.

				
					sudo mysql -u root
				
			

The above instructions opens MySQL’s own terminal. We create a separate database titled ‘wordpress-db’ and create a user identified by a password of your choosing.

				
					CREATE DATABASE wordpress-db;
CREATE USER wordpress-db@localhost IDENTIFIED BY 'password';
				
			

We grant it privileges and flush them.

				
					GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
FLUSH PRIVILEGES;
exit

				
			

To connect the database, we copy the config file and set the configuration in the file. Replace with your database name, db username and password.

				
					sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php

sudo -u www-data sed -i 's/database_name_here/wordpress/' /srv/www/wordpress/wp-config.php

sudo -u www-data sed -i 's/username_here/wordpress/' /srv/www/wordpress/wp-config.php

sudo -u www-data sed -i 's/password_here//' /srv/www/wordpress/wp-config.php

				
			

Open the following file using nano.

				
					sudo -u www-data nano /srv/www/wordpress/wp-config.php
				
			

Locate the following lines. Delete the lines and replace with content from https://api.wordpress.org/secret-key/1.1/salt/. Save the file.

				
					define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

				
			

And we are done! Opening http://localhost/ will take you to your WordPress website that is waiting to be configured as you please.

Great you have learned how to Install WordPress on Ubuntu 20.04.

How To Install WordPress on Ubuntu 20.04 Conclusion

Bringing together WordPress on Ubuntu is a powerful move to having complete and precise control over your website. The site can be directly altered and configured as you please from the Ubuntu terminal without any extra installations. The above setup also ensures the basic security of your website is set up. Any additional security measure lies in your hands as the administrator.

Avatar for Emad Bin Abid
Emad Bin Abid

I'm a software engineer who has a bright vision and a strong interest in designing and engineering software solutions. I readily understand that in today's agile world the development process has to be rapid, reusable, and scalable; hence it is extremely important to develop solutions that are well-designed and embody a well-thought-of architecture as the baseline. Apart from designing and developing business solutions, I'm a content writer who loves to document technical learnings and experiences so that peers in the same industry can also benefit from them.

5 2 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x