WordPress is basically a content management system (CMS). It is written in PHP. Initially, WordPress was just a tool for blogging. But, today it is being used to serve variety of web content. Furthermore, it was first released on May 27, 2003. And, at the time of writing the article the latest stable release of WordPress is 5.4.1. In this article, we would discuss how to install WordPress in Ubuntu 20.04 through apt.
apt – Advanced Package Tool. Besides, we would also like to clarify – at the time of writing, Ubuntu 20.04 LTS release has version 5.3.2 in its standard repository.
Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.
Install WordPress in Ubuntu 20.04 through apt
Since the package is already available in standard Ubuntu repository. Therefore, issue the following in terminal –
sudo apt update
It will update the Ubuntu repository to make the latest version of package available. Next, to install WordPress –
sudo apt install wordpress
It will install relevant dependencies as well. Major ones include – apache2, mysql-client-8.0, php-mysql, php7.4-cli and wordpress-theme-twentynineteen. It will automatically start apache2.service also.
It is worth mentioning here that, default installation installation directory of WordPress is
/usr/share/wordpress (only applicable in case we install WordPress through standard Ubuntu repository). But, for apache server its
/var/www/html. So, we need a workaround. Hence, this is where symbolic link steps in. We would therefore create a symbolic link of
/usr/share/wordpress pointing to
/var/www/. We will explain it later why just
/var/www/ and why not
/var/www/html. Issue the following in terminal –
sudo ln -s /usr/share/wordpress/ /var/www/wordpress
Thereafter, we need to install mysql-server –
sudo apt install mysql-server
In next step, create a MySQL database and hostname. It is always better to use database name similar to your hostname. Syntax –
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n <database_name> <hostname>
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost
Here, a database – wordpress and hostname – localhost is now available for use. It would return with the following –
Goto http://localhost to setup WordPress
Lastly, open a browser and type the following in address bar –
This won’t work in most cases and will throw 404 error. By default, DocumentRoot entry for apache server is
/var/www/html. Therefore, we need to change it to make our configuration work –
sudo nano /etc/apache2/sites-available/000-default.conf
and, edit the entry –
Next, restart apache2.service –
sudo systemctl restart apache2.service
Lastly, in the browser –
It will come up WordPress installation process. It will ask you to login in next stage.
There would be another issue while you update WordPress themes and plugins. To resolve that, we need to change the ownership of following folder/subfolder to www-data. It is done through chown command-line utility with -R (recursive) option.
chown -R www-data /usr/share/wordpress
In conclusion, we have discussed how to install WordPress in Ubuntu 20.04 through apt.