WordPress is a free and open-source content management system (CMS) with a plugin architecture and customizable themes. The PHP-based platform is usually paired with a MySQL or MariaDB database and was originally designed for publishing blogs. It is available for free and considered easy to install, configure, and uses. This article explains how to install WordPress on Ubuntu.
- A root or non-root user with
- A Ubuntu LAMP stack includes the Linux operating system, the Apache web server, MySQL, and the PHP programming language.
If the LAMP stack is not installed, then just follow the below steps to install LAMP on Ubuntu.
- Run the below command on the terminal to install apache.
apt install apache2
- To confirm that Apache is installed on a system, run the following command.
systemctl status apache2
- You can install MySQL on Ubuntu via this link How to install Mysql on Ubuntu
- Run the below command on the terminal to install PHP and its dependencies
apt install php php-mysql
- To confirm that PHP is installed, created an info.php file at the
- Append the following lines
Open a browser and append /info.php to the server’s URL
After fully configuring the LAMP. now the system is ready to install and configure the WordPress follow the below instruction to download and install WordPress.
- Run the below command on the terminal to download
- Run the following command to Uncompress the tarball which will generate a folder called
tar -xvf latest.tar.gz
- Copy the
wordpressfolder to the
cp -R wordpress /var/www/html/
- Next, create a
wp-config.phpfile by copying the
sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
- Run commands to change file permissions of the
chown -R www-data:www-data /var/www/html/
chmod 755 -R /var/www/html/
- Create an ‘uploads’ directory.
- change permissions of the ‘uploads’ directory.
chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads/
- Create WordPress Database.
WordPress uses MySQL to manage and store site and user information so need to create a database and user for WordPress.
Login into MySQL shell using the below command
mysql -u root -p
Create a database for a WordPress installation.
CREATE DATABASE wordpress;
Create a new database user and assign it a password
CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
Now, grant the user full rights to the new WordPress database.
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password'
- Flush the privileges
- Exit from MySQL
- After creating the database and user for WordPress configure the database details in the wpconfig.php file. Run the below command to open the
wp-config.phpfile and update the DB_NAME, DB_USER, DB_PASSWORD fields as show in below image.
- Next, access the wp-config file and update the database details.
- Restart the apache server.
systemctl restart apache2
- Open your browser and go to the server’s URL and replace "server-ip" with your system IP in the below URL.
- Follow the on-screen instructions to create a WordPress user.
- Once the WordPress installation is complete, click on login to access your site’s administrative login page.
- Authenticate with the user credentials and start accessing WordPress.