
How to Set Up Multiple WordPress Sites on a Single Ubuntu VPS
Are you looking to host multiple WordPress sites without breaking the bank? A Virtual Private Server (VPS) can be a powerful solution for managing multiple projects while keeping costs down. In this post, we’ll guide you through the steps to set up multiple WordPress sites on a single Ubuntu VPS.
Why Choose a VPS for Multiple WordPress Sites?
Using a VPS offers several advantages:
- Cost-Effective: Instead of paying for multiple hosting plans, a single VPS can host several websites.
- Full Control: You have root access, allowing you to customize the environment to suit your needs.
- Resource Allocation: With a VPS, you can allocate resources based on the requirements of each site.
Now, let’s dive into the steps of setting up multiple WordPress sites on your Ubuntu VPS.
Step 1: Prepare Your VPS
1. Update Your System
Start by updating your package list and upgrading the installed packages.
sudo apt update
sudo apt upgrade -y
2. Install Required Software
You’ll need to install a few packages to set up your server. We will install Apache, MySQL, PHP, and necessary PHP extensions.
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli php-curl php-xml php-mbstring -y
3. Start and Enable Services
Make sure Apache and MySQL are running and enabled to start on boot.
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mysql
sudo systemctl enable mysql
Step 2: Configure MySQL for WordPress
1. Secure MySQL Installation
Run the following command to secure your MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and remove anonymous users.
2. Create Databases and Users
For each WordPress site, you’ll need to create a separate database and user. Here’s how to do it:
sudo mysql -u root -p
Once in the MySQL shell, run the following commands (replace dbname
, dbuser
, and dbpassword
with your desired values):
CREATE DATABASE dbname;
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'dbpassword';
GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Repeat this process for each WordPress site you plan to set up.
Step 3: Install WordPress
1. Download WordPress
Navigate to the web directory and download the latest version of WordPress.
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xvzf latest.tar.gz
sudo mv wordpress/* ./
2. Configure Apache for Multiple Sites
You need to create a new configuration file for each WordPress site. For example, let’s create a configuration for site1.com
:
sudo nano /etc/apache2/sites-available/site1.com.conf
Add the following configuration:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/site1_error.log
CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
3. Enable the Site and Rewrite Module
Enable the new site and the Apache rewrite module:
sudo a2ensite site1.com.conf
sudo a2enmod rewrite
4. Repeat for Additional Sites
Repeat the process for each additional site, changing the server name and appropriate directory.
Step 4: Finalize WordPress Installation
1. Configure Permissions
Set the correct permissions for your WordPress directory:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
2. Complete Installation via Browser
Now, open your browser and navigate to http://site1.com
(or your configured domain). You’ll be greeted with the WordPress installation wizard. Follow the prompts to complete the setup using the database credentials you created earlier.
3. Repeat for Additional Sites
Access the other sites in the same way to set up each WordPress installation.
Conclusion
Setting up multiple WordPress sites on a single Ubuntu VPS is a cost-effective and efficient way to manage your online presence. By following these steps, you can have your sites up and running while maintaining full control over your server environment.
If you have any questions or need further assistance, don’t hesitate to reach out to us at Greenhost.cloud. Happy hosting!