Update the System
sudo apt update
sudo apt upgrade
Install Web Server
- Install Apache and set it to start automatically.
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
- Check installation status:
sudo systemctl status apache2
- Access
<http://your_vps_ip>
to see if you have the Apache2 Ubuntu Default Page.
Install MySQL
sudo apt install mysql-server
- Configure MySQL:
- Set a password for the MySQL root user (choose password conditions).
- Remove anonymous users.
- Disallow remote root login.
- Remove the test database.
- Reload the privilege table.
Install PHP
- Install PHP and Necessary PHP Modules
sudo apt install php libapache2-mod-php php-mysql
- Configure Apache:
sudo systemctl restart apache2
- Create a PHP test file:
sudo nano /var/www/html/info.php
- Type in the editor
<?php phpinfo(); ?>
- Save and exit (press
Ctrl + X
, thenY
, thenEnter
). - Check if the PHP page is displayed
- Visit
<http://your_vps_ip/info.php>
- Visit
Install WordPress
- Download WordPress:
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
- Extract WordPress:
sudo tar xzvf latest.tar.gz
- Set WordPress permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress
- Create the WordPress configuration file:
sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
- Set up the database: (Change the PASSWORD)
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
- Configure WordPress:
sudo nano /var/www/html/wordpress/wp-config.php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'localhost');
- Complete the installation:
- Visit
http://your_vps_ip/wordpress
- Visit
(Optional) Install phpMyAdmin
phpMyAdmin is a convenient web interface tool for managing MySQL databases.
- Install phpMyAdmin:
sudo apt install phpmyadmin
- Choose apache2
- Configure phpMyAdmin:
- During installation, configure database use settings.
- Use the MySQL root user or other MySQL users (like
wordpressuser
).
- Integrate phpMyAdmin with Apache:
sudo nano /etc/apache2/apache2.conf
- Add
Include /etc/phpmyadmin/apache.conf
- Restart Apache:
sudo systemctl restart apache2
- Access phpMyAdmin:
http://<your_vps_ip>/phpmyadmin