Introduction:
WordPress is a popular content management system that allows users to create and manage websites easily. In this tutorial, we will guide you through the process of installing WordPress on Ubuntu 22.04 using the command line. This method provides a flexible and efficient way to set up WordPress on your server.
Prerequisites:
Before you begin the installation process, make sure you have the following:
- A server running Ubuntu 22.04.
- SSH access to your server.
Step 1: Connect to Your Server:
Use an SSH client to connect to your Ubuntu 22.04 server. You can do this by entering the following command in your terminal:
ssh your_username@your_server_ip
Replace “your_username” with your actual username and “your_server_ip” with the IP address of your server.
Step 2: Update System Packages:
Ensure that your system is up to date by running the following commands:
sudo apt update
sudo apt upgrade
Step 3: Install LAMP Stack:
WordPress requires a web server, a database server, and PHP. Install the LAMP stack by executing the following commands:
sudo apt install apache2
sudo apt install mysql-server
sudo apt install php libapache2-mod-php php-mysql
During the MySQL installation, you’ll be prompted to set a password for the MySQL root user.
Step 4: Create a MySQL Database and User:
Log in to the MySQL server with the following command:
sudo mysql
Create a new database for WordPress:
CREATE DATABASE wordpress;
Create a user and grant privileges:
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace ‘your_password’ with a strong password.
Step 5: Download and Configure WordPress:
Navigate to the Apache web root directory:
cd /var/www/html
Download the latest WordPress release:
sudo wget https://wordpress.org/latest.tar.gz
Extract the archive:
sudo tar -zxvf latest.tar.gz
Move the WordPress files to the web root:
sudo mv wordpress/* .
Set the correct permissions:
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Step 6: Configure WordPress:
Copy the sample configuration file:
cp wp-config-sample.php wp-config.php
Open the configuration file in a text editor:
sudo nano wp-config.php
Update the database connection settings with the database name, user, and password you created earlier.
Save the file and exit the text editor.
Or, you can also browse the URL of your website, and complete the installation of WordPress according to the guide.
Step 7: Complete the Installation:
Open your web browser and navigate to your server’s IP address or domain. You will see the WordPress installation wizard. Follow the on-screen instructions to complete the installation, providing the necessary information such as site title, username, and password.
Conclusion:
Congratulations! You have successfully installed WordPress on Ubuntu 22.04 using the command line. This method allows for a streamlined and efficient setup, making it easier to manage and customize your WordPress site on your Ubuntu server.