Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install WordPress Ubuntu Using LAMP Stack - DesignLinux

Aug 19 2021
designlinux 0 Comments

For those who cannot afford the hustles of developing websites from scratch, there are now several content management systems (CMSs) such as WordPress that you can take advantage of to set up blogs as well as complete websites with a few clicks.

WordPress is a powerful, free, and open-source, highly pluggable, and customizable CMS that is being used by millions around the world to run blogs and fully functional websites.

It is easy to install and learn, especially for persons who do not have prior website design and development knowledge. With millions of plugins and themes available, developed by an active and dedicated community of fellow users and developers, that you can utilize to tailor your blog or website to work and look just the way you want.

Requirements:

  • A dedicated Ubuntu server with a registered domain name, I suggest you go for Linode hosting, which offers $100 credit to try it for free.

In this post, we shall run through the various steps you can follow, to install the latest version of WordPress on Ubuntu 20.04, Ubuntu 18.04, and Ubuntu 16.04 with LAMP (Linux, Apache, MySQL, and PHP) stack.

Install LAMP Stack on Ubuntu Server

First, we shall uncover the various steps for the installation of the LAMP stack before progressing to install WordPress.

Step 1: Install Apache Web Server on Ubuntu

First, update and upgrade the software package list and then install the Apache webserver using the following commands.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install apache2 apache2-utils 
Install Apache in Ubuntu
Install Apache in Ubuntu

We need to enable the Apache2 web server to start at system boot time, as well as start the service and verify the status as follows:

$ sudo systemctl enable apache2
$ sudo systemctl start apache2
$ sudo systemctl status apache2
Check Apache Status in Ubuntu
Check Apache Status in Ubuntu

Once you’ve started Apache, you then need to allow HTTP traffic on your UFW firewall as shown.

$ sudo ufw allow in "Apache"
$ sudo ufw status
Open Apache Port on UFW Firewall
Open Apache Port on UFW Firewall

To test whether the Apache server is running, open your web browser and enter the following URL in the address bar.

http://server_address
OR
http://your-domain.com

The Apache2 default index page will be displayed in case the webserver is up and running.

Apache Default Page Under Ubuntu
Apache Default Page Under Ubuntu

Note: The Apache default root directory is /var/www/html, all your web files will be stored in this directory.

Step 2: Install MySQL Database Server

Next, we need to install the MySQL database server by running the command below:

$ sudo apt-get install mysql-client mysql-server
Install MySQL in Ubuntu
Install MySQL in Ubuntu

If you want to install MariaDB, you can install it using the following command.

$ sudo apt-get install mariadb-server mariadb-client
Install MariaDB in Ubuntu
Install MariaDB in Ubuntu

Once the database server is installed, it is strongly advised that you run a security script to remove insecure default settings and protect your database system.

$ sudo mysql_secure_installation 

Firstly, you will be asked to install the ‘validate_password’ plugin, so type in Y/Yes and press Enter and also choose the default password strength level.

Set MySQL Root Password in Ubuntu
Set MySQL Root Password in Ubuntu

For the remaining questions, press Y and hit the ENTER key at each prompt.

Secure MySQL in Ubuntu
Secure MySQL in Ubuntu

Step 3: Install PHP in Ubuntu

Last but not least, we shall install PHP and a few modules for it to work with the web and database servers using the command below:

$ sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip 
Install PHP in Ubuntu
Install PHP in Ubuntu

Once PHP and all required extensions are installed, you need to restart Apache to load these new extensions.

$ sudo systemctl restart apache2

Furthermore, to test if php is working in collaboration with the webserver, we need to create a info.php file inside /var/www/html.

$ sudo vi /var/www/html/info.php

And paste the code below into the file, save it, and exit.

<?php 
phpinfo();
?>

When that is done, open your web browser and type in the following URL in the address bar.

http://server_address/info.php
OR
http://your-domain.com/info.php

You should be able to view the php info page below as a confirmation.

Check PHP Info in Ubuntu
Check PHP Info in Ubuntu

Step 4: Install WordPress in Ubuntu

Download the latest version of the WordPress package and extract it by issuing the commands below on the terminal:

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

Then move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:

$ sudo mv wordpress/* /var/www/html/

Next, set the correct permissions on the website directory, that is give ownership of the WordPress files to the webserver as follows:

$ sudo chown -R www-data:www-data /var/www/html/
$ sudo chmod -R 755 /var/www/html/

Step 5: Create WordPress Database

Execute the command below and provide the root user password, then hit Enter to move to the mysql shell:

$ sudo mysql -u root -p 

At the mysql shell, type the following commands, pressing Enter after each line of a mysql command. Remember to use your own, valid values for database_name, database user, and also use a strong and secure password as databaseuser_password:

mysql> CREATE DATABASE wp_myblog;
mysql> CREATE USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> GRANT ALL ON wp_myblog.* TO 'username'@'%';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Create WordPress Database
Create WordPress Database

Go the /var/www/html/ directory and rename existing wp-config-sample.php to wp-config.php. Also, make sure to remove the default Apache index page.

$ cd /var/www/html/
$ sudo mv wp-config-sample.php wp-config.php
$ sudo rm -rf index.html

Then update it with your database information under the MySQL settings section (refer to the highlighted boxes in the image below):

WordPress MySQL Settings
WordPress MySQL Settings

Afterward, restart the web server and mysql service using the commands below:

$ sudo systemctl restart apache2.service 
$ sudo systemctl restart mysql.service 

Open your web browser, then enter your domain name or server address as shown.

http://server_address/info.php
OR
http://your-domain.com/info.php

You will get the welcome page below. Read through the page and click on “Let’s go!” to proceed further and fill in all requested on-screen information.

Choose WordPress Language
Choose WordPress Language
Set WordPress Details
Set WordPress Details
WordPress Dashboard
WordPress Dashboard

Hoping that everything went on just fine, you can now enjoy WordPress on your system. However, to express any concerns or ask questions concerning the steps above or even provide additional information that you think has not been included in this tutorial, you can use the feedback section below to get back to us.

Related

Tags: Apache Tips, Ubuntu Tips, WordPress Tips

How to Install KDE Plasma in Linux Desktop

Prev Post

Htop – An Interactive Process Viewer for Linux

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
  • 566
  • 1,055,338

DesignLinux.com © All rights reserved

Go to mobile version