To install WordPress on Ubuntu, you can follow these steps:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php
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.
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress/* .
sudo rmdir wordpress
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
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.
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo service apache2 restart
That’s it! You have successfully installed WordPress on Ubuntu.