How to install WordPress on Ubuntu
To install WordPress on Ubuntu, you can follow these steps:
- Update your Ubuntu system by running the following commands in your terminal:
sudo apt-get update
sudo apt-get upgrade
- Install Apache web server, MySQL database server and PHP on your Ubuntu system by running the following command:
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php
- Once the installation is complete, create a MySQL database and user for WordPress. You can do this by logging into MySQL as the root user and running the following commands:
mysql -u root -p
Enter the root password when prompted, and then run the following commands to create a new database and user:
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Replace “password” with a strong password of your choice.
- Download and extract the latest version of WordPress by running the following commands:
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress/* .
sudo rmdir wordpress
- Set the correct file permissions by running the following commands:
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
- Create a new virtual host configuration file for Apache:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following lines to the file:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Replace “example.com” with your own domain name or IP address.
- Enable the virtual host configuration and the Apache rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
- Restart Apache:
sudo service apache2 restart
- Complete the WordPress installation by accessing your website in a web browser and following the on-screen instructions.
That’s it! You have successfully installed WordPress on Ubuntu.