How to install WordPress on Ubuntu

To install WordPress on Ubuntu, you can follow these steps:

  1. Update your Ubuntu system by running the following commands in your terminal:
    sudo apt-get update
    sudo apt-get upgrade

  2. 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
  3. 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';

    Replace “password” with a strong password of your choice.

  4. 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

  5. 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/

  6. 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
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Replace “example.com” with your own domain name or IP address.

  7. Enable the virtual host configuration and the Apache rewrite module:
    sudo a2ensite wordpress.conf
    sudo a2enmod rewrite

  8. Restart Apache:
    sudo service apache2 restart
  9. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *