Advance

How to install WordPress with Apache in Ubuntu 20.04

How to install WordPress with Apache in Ubuntu 20.04
1
(1)

previously, you learned about installing WordPress with Nginx. In this article, you will learn how to install WordPress with Apache in Ubuntu 20.04. Certainly, you know about WordPress, a free and open-source popular platform for building websites that are most used because of being easy to install, learn, and use, highly pluggable and customizable too.

 

How to install WordPress with Apache in Ubuntu 20.04

As we are going to present how to install the latest version of WordPress with Apache in Ubuntu 20.04, you need to have the LAMP stack installed and well configured for hosting websites. In case you have not installed it yet, see our guide:

Installing WordPress in Ubuntu 20.04

After installing the LAMP (ApacheMariaDB, and PHP) stack begin to download the latest version of WordPress

wget -c http://wordpress.org/latest.tar.gz  

Then, extract the archived file.

tar -xzvf latest.tar.gz

Once, you extracted WordPress directory, move it into your document root i.e. /var/www/html/ and under your website. To create a mysite.com directory and move WordPress files under it, run the following command.

Note: Replace mysite.com with your website’s name or domain name.

ls -l  sudo cp -R wordpress /var/www/html/mysite.com  ls -l /var/www/html/

Now, you can set appropriate permissions on the website (/var/www/html/mysite.com) directory.

Note: It should be owned by the Apache2 user and group called www-data.

sudo chown -R www-data:www-data /var/www/html/mysite.com  sudo chmod -R 775 /var/www/html/mysite.com

Creating a WordPress database for website

In this step, by using the MySQL command with -u flag to supply the username which should be root and -p to enter a password that you set for the MySQL root account when you installed the MariaDB software, log into MariaDB database shell.

sudo mysql -u root -p  

To create your site’s database and a database user with privileges, after login in, run the below command.

Note: Replace “mysite”, “mysiteadmin” and “SecureP@ssHere!” with your database name, database username, and the user’s password

MariaDB [(none)]> CREATE DATABASE mysite;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mysite.* TO 'mysiteadmin'@'localhost' IDENTIFIED BY 'SecureP@ssHere!';  
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Now, create a wp-config.php file from the sample configuration file provided, by moving into your website’s document root.

cd /var/www/html/mysite.com  sudo mv wp-config-sample.php wp-config.php

Next, open the wp-config.php configuration file for editing.

sudo vim wp-config.php

Then, you need to update the parameters of the database name, database user, and the user’s password created above.

 

 Update the database connection parameters

Buy Linux Virtual Private Server

 

Creating Apache VirtualHost for WordPress Website

It is Time to configure Apache webserver to serve your WordPress site. You need to create a Virtual Host for it under the Apache configuration. it should be with your fully qualified domain name.

In the following, to create a new file under the /etc/apache2/sites-available/ directory, create and activate a new Virtual Host.

Note: in this tutorial, you will call the file mysite.com.conf and it should end with the .conf extension)

sudo vim /etc/apache2/sites-available/mysite.com.conf

Then, replace the ServerName and ServerAdmin emails with your values and copy and paste the following configuration in it.

<VirtualHost *:80>  	ServerName mysite.com  	ServerAdmin webmaster@localhost  	DocumentRoot /var/www/html/mysite.com  	ErrorLog ${APACHE_LOG_DIR}/error.log  	CustomLog ${APACHE_LOG_DIR}/access.log combined  </VirtualHost>    

Apache WordPress virtual host

You can save and close it now.

Then to be able to enable the new site and reload the apache2 service to apply the new changes, you should check if the Apache configuration is correct for syntax or not.

apache2ctl -t  sudo a2ensite mysite.com.conf  sudo systemctl reload apache2

We should also mention that, to let your new site load properly from a web browser, you need to disable the default, virtual host.

sudo a2dissite 000-default.conf  sudo systemctl reload apache2      

Completing the WordPress installation via the web interface

Now, you will learn how to complete the WordPress installation using the web installer. Open your browser and navigate using your site’s domain name.

http://mysite.com.

The next you can do after loading the WordPress web installer is to pick the language you wish to use for installation and click Continue.

Now, you can set your site’s title (administrative username, password, and an email) for managing your site content. Then click Install WordPress.

So clear that you will click on Log in to access your site’s administrative login page, after installing the WordPress.

Finally, you would be able to log into your new WordPress website, by using your administrative credentials and start to customize your site from Dashboard.

 

 

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day