Step by Step Guide How to Install WordPress on Ubuntu 24.04 and Secure MySQL Server
Introduction
In this detailed guide, we'll walk you through the process of installing WordPress on Ubuntu 24.04 and securing the MySQL server to ensure the safety of your website's data.
Prerequisites
Before getting started, ensure you have the following:
- Ubuntu 24.04 installed
- SSH access to your server
Installing WordPress
Follow these simple steps to install WordPress on your Ubuntu 24.04 server:
Update System Packages:
1sudo apt update && sudo apt upgradeInstall LAMP Stack:
1sudo apt install apache2 mysql-server php php-mysqlConfigure MySQL: Secure your MySQL installation:
1sudo mysql_secure_installationCreate MySQL Database and User for WordPress: Log in to the MySQL shell:
1mysql -u root -pExecute the following SQL commands to create a new database and user:
1CREATE DATABASE wordpress; 2CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password'; 3GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost'; 4FLUSH PRIVILEGES; 5EXIT;Download and Configure WordPress:
1cd /tmp 2wget -c https://wordpress.org/latest.tar.gz 3tar -xzvf latest.tar.gz 4sudo mv wordpress /var/www/html/ 5sudo chown -R www-data:www-data /var/www/html/wordpress 6sudo chmod -R 755 /var/www/html/wordpressComplete WordPress Installation: Open a web browser and navigate to your server's IP address or domain name. Follow the on-screen instructions to complete the WordPress installation.
Securing MySQL Server
Now, let's strengthen the security of your MySQL server:
Update MySQL Root Password:
1sudo mysql_secure_installationRemove Anonymous Users: Log in to the MySQL shell:
1mysql -u root -pExecute the following SQL command to remove anonymous users:
1DELETE FROM mysql.user WHERE User=''; 2FLUSH PRIVILEGES; 3EXIT;Disallow Root Login Remotely: Edit the MySQL configuration file:
1sudo nano /etc/mysql/mysql.conf.d/mysqld.cnfFind the line that says
bind-addressand change its value to127.0.0.1to allow connections only from localhost. Save and close the file, then restart MySQL:1sudo systemctl restart mysqlRemove Test Database and Privileges:
Log in to the MySQL shell:
1mysql -u root -pExecute the following SQL commands to remove the test database and associated privileges:
1 DROP DATABASE test;
2 DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
3 FLUSH PRIVILEGES;
4 EXIT;
Conclusion
Congratulations! You've successfully installed WordPress on Ubuntu 24.04 and fortified the security of your MySQL server. Your website is now ready for action, equipped with robust performance and protection against potential security threats.