Guide: Setting Up and Configuring WordPress on Ubuntu Server
Step 1: Update Your System
- Open the terminal and update the package list:
sudo apt update && sudo apt upgrade -y
Step 2: Install Apache Web Server
- Install Apache using the following command:
sudo apt install apache2 -y
- Enable Apache to start at boot:
sudo systemctl enable apache2
Step 3: Install MySQL
- Install MySQL server:
sudo apt install mysql-server -y
- Secure the MySQL installation:
sudo mysql_secure_installation
- Follow the prompts to set up a root password and secure MySQL.
Step 4: Install PHP
- Install PHP and required extensions:
sudo apt install php php-mysql libapache2-mod-php php-cli -y
- Verify the PHP installation:
php -v
Step 5: Create a MySQL Database for WordPress
- Log in to MySQL:
sudo mysql -u root -p
- Create a database for WordPress:
CREATE DATABASE wordpress;
- 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
- Download the latest WordPress package:
wget https://wordpress.org/latest.tar.gz
- Extract the package:
tar -xvzf latest.tar.gz
- Move WordPress files to the Apache root directory:
sudo mv wordpress /var/www/html/
- 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
- Create a new Apache configuration file:
sudo nano /etc/apache2/sites-available/wordpress.conf
- 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>
- Enable the site and mod_rewrite:
sudo a2ensite wordpress sudo a2enmod rewrite sudo systemctl restart apache2
Step 8: Complete WordPress Setup
- Open a web browser and navigate to
http://your-server-ip
. - 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.