To install WordPress on Ubuntu, follow these steps:
- Update your Ubuntu system: Run the following commands in your terminal:
sudo apt-get update
sudo apt-get upgrade
- Install Apache, MySQL, and PHP: Install the required packages by running:
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php
- Create a MySQL database and user for WordPress: Log in to MySQL:
mysql -u root -p
Enter your root password, then run the following commands:
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.
Need help with Linux?
Get a free strategy session with our experts — no commitment required.
- Download and extract WordPress: Run:
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 file permissions: Run:
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
- Create an Apache virtual host configuration:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following configuration:
<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 domain name or server IP address.
- Enable the virtual host and rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
- Restart Apache:
sudo service apache2 restart
- Complete the installation: Open your website in a browser and follow the WordPress setup instructions.
That’s it! You have successfully installed WordPress on Ubuntu.



