How to Set Up Your Own Web Server (Nginx + PHP + MySQL) on Ubuntu

Want to have your own website server without relying on hosting? In this article, you’ll learn how to set up your own web server on a VPS or Dedicated Server using Ubuntu with a combination of Nginx + PHP + MySQL. Perfect for those who just bought a VPS or Dedicated Server from KlikServer! What…

Setting up a web server with Nginx, PHP and MySQL on Ubuntu

Want to have your own website server without relying on hosting? In this article, you’ll learn how to set up your own web server on a VPS or Dedicated Server using Ubuntu with a combination of Nginx + PHP + MySQL. Perfect for those who just bought a VPS or Dedicated Server from KlikServer!

What Is a Web Server?

A web server is a system that serves website pages to visitors through a browser. To run a website like WordPress, you need three main components:

  • Nginx as the web server
  • PHP to run website scripts
  • MySQL as the website data storage

Let’s start from the beginning!

Step 1: Update the Server

First, log in to your VPS or Dedicated Server via SSH, then run:

sudo apt update && sudo apt upgrade -y

This will make sure your system is up to date.

Step 2: Install Nginx

Run the following command to install Nginx:

sudo apt install nginx -y

Then check if Nginx is active:

sudo systemctl status nginx

If it’s active, you can try opening your server’s IP address in a browser. You should see the default Nginx page.

Step 3: Install MySQL

Now, install the MySQL database:

sudo apt install mysql-server -y

After that, secure the installation:

sudo mysql_secure_installation

Just follow the instructions on screen. You can set a root password and remove the anonymous user.

Step 4: Install PHP and Its Modules

PHP is needed so the server can run websites such as WordPress.

Install it with the command below:

sudo apt install php-fpm php-mysql -y

The php-mysql module is required so PHP can connect to MySQL.


You have successfully completed the initial VPS setup and installed Nginx! In the next part, we’ll continue to database installation:

Next: How to Configure Nginx


Previous
Next

Leave a Reply

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

Chat on WhatsApp (opens in a new tab)