Introduction
WordPress is an open-source software that can be downloaded and used for free. It is highly customizable and flexible, allowing users to create a wide range of websites, from simple blogs to complex e-commerce sites. WordPress is known for its user-friendly interface, which makes it easy for anyone to create and manage a website without any coding knowledge.
LAMP stack is a popular web development stack that stands for Linux, Apache, MySQL, and PHP. It is a combination of open-source software that is used to create dynamic web applications.
Prerequisites
You must following things to complete this tutorial.
- Ubutnu 22.04 LTS up and running.
- Root permission.
- Basic knowldged of linux commands.
- Familier with MariaDB database.
- Internet connecvity.
In this post, We will install WordPress on ubuntu 22.04 LTS along with LAMP Stack.
Step 1: Update Ubuntu Repository
We need to update 1st ubuntu repository and packages by using given command.
sudo apt-get update && sudo apt-get upgrade
Step 2: Installing Apache
To install apache web server, We need to execute given command, Apache repository already available with ubuntu 22.04 LTS.
sudo apt-get install apache2 -y
Step 3: Installing MySQL
Execute the given command in order to install MySQL server on ubuntu machine.
sudo apt-get install mysql-server -y
Step 4: Installing PHP with Modues
Given command can install PHP and some PHP’s module that’s enable PHP project to run.
sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc -y
Step 5: Create WordPress Database & User
Create database, user and apply their right permission for WordPress, Use the given command for the same.
To login MySQL Shell.
mysql -u root -p
Enter your MySQL root password when prompted.
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 6: Downloading & Extracting WordPress
To download the latest version from WordPress website, We need to execute the given command for the same.
cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
Step 7: Move the WordPress files
Moving wordpress file to the HTML documenting PATH in order to read by apache web server.
sudo mv /tmp/wordpress /var/www/html/
Step 8: Updating Permission
Updating permission to read the WordPress files from right web server system user.
Set the correct permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/
Step 9: Configure Virtualhost
Configure Apache to serve the WordPress site:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following lines to the file and save it:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/wordpress
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/wordpress>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the new site and disable the default site:
sudo a2ensite wordpress.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
Step 10: Accessing WordPress
Complete the WordPress installation by visiting your server’s IP address or domain name in a web browser and following the on-screen instructions.
Conclusion
We have successfully installed and setup the WordPress using the LAMP stack on Ubuntu. If you have any questions or issues, please leave a comment below.