Content management systems today are extremely useful tools for creating sites. One such system is WordPress. It gained its popularity due to its simplicity and ease of use. This article describes how to install WordPress on Ubuntu.
In order for WordPress to be visible on the Internet, you need to use a web server. Here is an example of Apache, the most popular web server.
Installing Apache and all packages dependent on it can be done with the following command:
sudo apt install apache2
Turn it on and add it to startup:
sudo systemctl start apache2 sudo systemctl enable apache2
To verify that the web server is working, send several packets to localhost. They must not be lost.
Install and Configure the Database
WordPress stores information in a DB. In this case, it will be MariaDB. To install it, enter the line:
sudo apt install mariadb-server
Also, enable and add this DBMS to startup:
sudo systemctl start mariadb sudo systemctl enable mariadb
Execute the mysql-script, answering in the affirmative to all questions:
Next, log in to the DBMS as root:
mysql -u root -p
Input the new password that you created for root in the script above.
If a login error occurs at this point
then execute the lines:
sudo mysql use mysql; update user set plugin='' where User='root'; flush privileges; exit;
Now log in to the DBMS again as root.
The prompt string in the terminal will change. Create a new DB with any name (for example, wp_db). Please note that at the end of each line entered here you need to write a semicolon character “;”.
CREATE DATABASE wp_db;
Add a new user with a password to work with this database:
CREATE USER ‘wp_admin’@’localhost’ IDENTIFIED BY ‘new_admin_password’;
Give user all the privileges to interact with the database:
GRANT ALL ON wp_db.* TO ‘wp_admin’@’localhost’ IDENTIFIED BY ‘new_admin_password’ WITH GRANT OPTION;
Reload the permissions table:
FLUSH PRIVILEGES; Quit the DBMS: EXIT;
WordPress is written in PHP, so you need to install it. Standard repositories contain a stable version of the language.
sudo apt install php php-cli php-cgi php-gd php-mysql
Install and Configure WordPress
CMS provides a convenient link for downloading the latest version of the program:
wget -c http://wordpress.org/latest.tar.gz
Unzip the archive to the current folder. The wordpress directory will be created:
tar xzvf latest.tar.gz
Copy the contents of the WordPress directory to /var/www/html/:
sudo rsync -av wordpress/* /var/www/html/
Give the user www-data ownership of all the copied files with chown command:
sudo chown -R www-data:www-data /var/www/html/
Also, overwrite file permissions:
sudo chmod -R 755 /var/www/html/
Go to the directory with CMS:
Rename the configuration file to make it workable:
sudo mv wp-config-sample.php wp-config.php
Open the wp-config.php file and correct the constants in accordance with the database data created earlier:
Now restart Apache and MariaDB:
sudo systemctl restart apache2 sudo systemctl restart mariadb
It remains to delete the index.html file that was in this directory from the very beginning:
sudo rm index.html
This completes the installation of WordPress. To verify the success of the process, go to http://localhost. A welcome CMS window should appear.
It is worth noting that a similar instruction with the input data and the location of the CMS files are shown as examples. It is not recommended to be used in this form (except for the test). Details of setting up WordPress can be found on the official website.