Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install WordPress with Apache in Ubuntu 20.04 - DesignLinux

May 29 2020
designlinux 0 Comments

WordPress is the most popular platform in the world for building websites, be it a blog, an e-commerce website, a business website, a portfolio website, an online business directory, and so on. It is free and open-source, easy to install, learn and use, highly pluggable and customizable too.

This guide shows how to install the latest version of WordPress with Apache in Ubuntu 20.04. It assumes that you have the LAMP stack installed and well configured for hosting websites, otherwise, see our guide:

  • How to Install LAMP Stack with PhpMyAdmin in Ubuntu 20.04

Installing WordPress in Ubuntu 20.04

1. Once the LAMP stack (Apache, MariaDB, and PHP) installed and configured on the Ubuntu 20.04 server, you can proceed further to download the latest version of WordPress using the following wget command.

$ wget -c http://wordpress.org/latest.tar.gz
Download WordPress in Ubuntu 20.04

Download WordPress in Ubuntu 20.04

2. Once the download is complete, extract the archived file using the tar command as shown.

$ tar -xzvf latest.tar.gz
Extract WordPress Files

Extract WordPress Files

3. Next, move the extracted WordPress directory into your document root i.e. /var/www/html/ and under your website as shown (replace mysite.com with your website’s name or domain name). The following command will create a mysite.com directory and move WordPress files under it.

$ ls -l
$ sudo cp -R wordpress /var/www/html/mysite.com
$ ls -l /var/www/html/
Setup WordPress on Website

Setup WordPress on Website

4. Now set appropriate permissions on the website (/var/www/html/mysite.com) directory. 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
Set Permissions on WordPress Files

Set Permissions on WordPress Files

Creating a WordPress Database for Website

5. To get started, log into your MariaDB database shell using the following 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.

$ sudo mysql -u root -p

6. After login, run the following commands to create your site’s database and a database user with privileges as shown. Remember to replace “mysite”, “mysiteadmin” and “[email protected]!” 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 '[email protected]!';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT
Create WordPress Database

Create a WordPress Database

7. Next, move into your website’s document root, create a wp-config.php file from the sample configuration file provided as shown.

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

8. Then open the wp-config.php configuration file for editing.

$ sudo vim wp-config.php

and update the database connection parameters (database name, database user, and the user’s password created above) as shown in the following screenshot.

Configure WordPress Database Settings

Configure WordPress Database Settings

Creating Apache VirtualHost for WordPress Website

9. Next, you need to configure Apache webserver to serve your WordPress site using your fully qualified domain name, by creating a Virtual Host for it under the Apache configuration.

To create and activate a new Virtual Host, create a new file under the /etc/apache2/sites-available/ directory. In this example, we will call the file mysite.com.conf (it should end with the .conf extension).

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

Then copy and paste the following configuration in it (replacing the ServerName and ServerAdmin emails with your values).

<VirtualHost *:80>
	ServerName mysite.com
	ServerAdmin [email protected]
	DocumentRoot /var/www/html/mysite.com
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Create WordPress Apache Virtual Host

Create WordPress Apache Virtual Host

Save the file and close it.

10. Then check the Apache configuration for syntax correctness. If the syntax is OK, enable the new site and reload the apache2 service to apply the new changes.

$ apache2ctl -t
$ sudo a2ensite mysite.com.conf
$ sudo systemctl reload apache2
Enable Website in Apache

Enable Website in Apache

11. Also, disable the default virtual host to allow your new site to load properly from a web browser.

$ sudo a2dissite 000-default.conf
$ sudo systemctl reload apache2
Disable Website in Apache

Disable Website in Apache

Completing the WordPress Installation via Web Interface

12. The final section demonstrates how to complete the WordPress installation using the web installer. So open your browser and navigate using your site’s domain name:

http://mysite.com.

Once the WordPress web installer loads, pick the language you wish to use for installation and click Continue.

Select WordPress Installation Language

Select WordPress Installation Language

13. Next, set your site’s title, administrative username, and password and an email for managing your site content. Then click Install WordPress.

Add WordPress Site Details

Add WordPress Site Details

14. Once the WordPress installation is complete, click on Log in to access your site’s administrative login page.

WordPress Installation Complete

WordPress Installation Complete

15. Now log into your new WordPress website using your administrative credentials (username and password created above) and start to customize your site from Dashboard.

WordPress Login

WordPress Login

WordPress Dashboard

WordPress Dashboard

In this article, we have explained how to install WordPress using Apache as a web server and MySQL as a database system for serving PHP websites.

Next, the crucial step is to secure your WordPress site with SSL. If you have deployed WordPress on a real domain, you can secure the site with Free Let’s Encrypt certificate. If you have deployed WordPress locally on a dummy website for testing or personal use, I suggest you to use a self-signed certificate instead.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: LAMP Guides, Ubuntu Tips, WordPress Tips

How to Compress Files Faster with Pigz Tool in Linux

Prev Post

How to Install and Configure Memcached on Ubuntu

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 1,031
  • 571,386

DesignLinux.com © All rights reserved

Go to mobile version