Guide: Setting Up and Configuring WordPress on Ubuntu Server

Step 1: Update Your System

  1. Open the terminal and update the package list:
    sudo apt update && sudo apt upgrade -y
    

 


Step 2: Install Apache Web Server

  1. Install Apache using the following command:
    sudo apt install apache2 -y
    
  2. Enable Apache to start at boot:
    sudo systemctl enable apache2
    

 


Step 3: Install MySQL

  1. Install MySQL server:
    sudo apt install mysql-server -y
    
  2. Secure the MySQL installation:
    sudo mysql_secure_installation
    
  3. Follow the prompts to set up a root password and secure MySQL.

 


Step 4: Install PHP

  1. Install PHP and required extensions:
    sudo apt install php php-mysql libapache2-mod-php php-cli -y
    
  2. Verify the PHP installation:
    php -v
    

 


Step 5: Create a MySQL Database for WordPress

  1. Log in to MySQL:
    sudo mysql -u root -p
    
  2. Create a database for WordPress:
    CREATE DATABASE wordpress;
    
  3. Create a user and grant privileges:
    CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    

 


Step 6: Download and Configure WordPress

  1. Download the latest WordPress package:
    wget https://wordpress.org/latest.tar.gz
    
  2. Extract the package:
    tar -xvzf latest.tar.gz
    
  3. Move WordPress files to the Apache root directory:
    sudo mv wordpress /var/www/html/
    
  4. Set permissions:
    sudo chown -R www-data:www-data /var/www/html/wordpress
    sudo chmod -R 755 /var/www/html/wordpress
    

 


Step 7: Configure Apache for WordPress

  1. Create a new Apache configuration file:
    sudo nano /etc/apache2/sites-available/wordpress.conf
    
  2. Add the following configuration:
    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/wordpress
        ServerName example.com
        ServerAlias www.example.com
    
        <Directory /var/www/html/wordpress>
            AllowOverride All
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
  3. Enable the site and mod_rewrite:
    sudo a2ensite wordpress
    sudo a2enmod rewrite
    sudo systemctl restart apache2
    

 


Step 8: Complete WordPress Setup

  1. Open a web browser and navigate to http://your-server-ip.
  2. Follow the on-screen instructions to select your language, configure the database connection, and set up an admin account.

 


Congratulations!

Your WordPress installation is now complete, and your site is ready for customization.

Was this answer helpful? 0 Users Found This Useful (0 Votes)