Install WordPress in Ubuntu 19.04

WordPress is one of the most popular Content Management Systems available. It is used for building websites. In this article, we cover how to install WordPress in Ubuntu 19.04 release.

So, we need to –

  1. Get super user privileges.
  2. Install Lamp-Server.
  3. Create database user and grant privileges.
  4. Install relevant PHP packages and edit few config files.
  5. Install WordPress.

Setup LAMP on Ubuntu 19.04

STEP – 1: We have to use administrative rights, if you don’t have the privileges then contact System Administrator for assistance.

STEP – 2: If you don’t have the package tasksel installed, then install it through the following command –

sudo apt install tasksel

Next, install lamp-server through tasksel –

sudo tasksel install lamp-server

STEP – 3: Now, we need to do secure installation of MySQL –

sudo mysql_secure_installation

It asks for a password. Remember the password as it will be used while creating a database for WordPress soon. For plugin validation, we chose NO and for the rests of options go ahead with YES. Now, create a database for WordPress  –

sudo mysql -u root -p

Enter the password that we entered during secure installation of MySQL and enter the following commands. We do this to create a database “wp_database” for user “wp_user” and password as “password”. And, grant privileges to the user.

CREATE DATABASE wp_database;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
quit

STEP – 4: Install some useful PHP extensions –

sudo apt install php-curl php-mbstring php-xml

Restart Apache services.

sudo systemctl restart apache2

This is the configuration for hosting one website on our server, so edit the default file –

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

and, add the following code in the above file – 000-default.conf. Then, save and exit.

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

To use Permalink feature of WordPress, enable rewrite module –

sudo a2enmod rewrite

To spot any error in syntax –

sudo apache2ctl configtest

It should return with the output Syntax OK message.

Lastly, run

sudo systemctl restart apache2

Install WordPress on Ubuntu 19.04

STEP – 5: Download WordPress from the official website – https://wordpress.org/download./

Save the the downloaded file (file version could be different for you) – wordpress-6.1.1.tar.gz in the directory /tmp/. Then, issue the following in terminal –

tar xzvf wordpress-6.1.1.tar.gz

tar command extracts the downloaded file.

Now, we have to copy the wp-config-sample.php file as wp-config.php in the same folder –

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

Once done, copy the entire WordPress directory to /var/www/html/ directory.

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

Next, modify ownership of the all copied files (to make plugins and themes editable) to the Apache Web Server through chown command,

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

Lastly, update the file wp-config.php file with following data –

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

and, edit the following entries with relevant ones created in the STEP – 3.

define( 'DB_NAME', 'wp_database' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'password' );

Save and exit. Remove index.html file from /var/www/html/ directory –

sudo rm /var/www/html/index.html

Open your Web Browser and enter the following URL in address bar –

http://localhost

and, provide relevant details including your username and password for WordPress login. Once, successfully done you will be taken to WordPress login prompt.

For some reason, if you are still unable to edit themes and plugins then you need to append /var/www/html/wp-config.php file with the following –

define( 'FS_Method', 'direct' );

In conclusion, we have covered here how to install WordPress in Ubuntu 19.04 release.

Similar Posts