How to Install a Website on a Server: A Complete Step-by-Step Guide
Hosting a website on a server is a key step in its creation and publication. This article provides a detailed step-by-step guide on how to install a website on a server from scratch.
Step 1: Preparing the Server
Before installing the website, it is necessary to choose the appropriate type of server:- VPS/VDS — a flexible and powerful option for projects with medium load.
- Dedicated Server — for large projects with high resource requirements.
This guide covers the installation of the website on a clean VDS using the Lite 1 (1 core, 1 GB RAM, and 20 GB disk)
Step 2: Installing Web Server, PHP, and Database
To run the website, the following are required:- web server (Apache or Nginx)
- PHP interpreter
- MySQL or MariaDB database
For Ubuntu/Debian:
apt update && apt upgrade -y
apt install apache2 php php-mysql mysql-server unzip curl -y
For CentOS/AlmaLinux:
yum update -y
yum install httpd php php-mysqlnd mariadb-server unzip curl -y
After installation, start the services and configure them to start automatically:
# For Apache
systemctl start apache2 # Ubuntu/Debian
systemctl start httpd # CentOS/RHEL
systemctl enable apache2 # Ubuntu/Debian
systemctl enable httpd # CentOS/RHEL
# For MySQL/MariaDB
systemctl start mysql
systemctl enable mysql
Step 3: Configuring the Database
Connect to MySQL:mysql -u root -p
Then, create the database and user:
CREATE DATABASE mysite_db;
CREATE USER 'mysite_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON mysite_db.* TO 'mysite_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Uploading and Installing the Website
- Upload the website archive using FTP/SFTP (for example, via FileZilla) or SCP:
scp site.zip root@IP:/var/www/html/
- Extract the archive:
cd /var/www/html/
unzip site.zip
- Check the permissions:
chown -R www-data:www-data /var/www/html/ && chmod -R 755 /var/www/html/
Step 5: Linking the Domain
- Register the domain on the website
- In the DNS settings, specify the A-record with your server's IP address.
- Wait from 5 to 30 minutes for the changes to take effect.
Step 6: Installing SSL (HTTPS)
It is recommended to install a free SSL certificate from **Let’s Encrypt**.For Ubuntu/Debian:
apt install certbot python3-certbot-apache -y && certbot --apache
Follow the instructions to obtain and activate the certificate.
Step 7: Testing
Open the website in the browser at the address, for example: ``` https://example.com ```Check:
- Correct page display
- Database operation
- Presence of HTTPS and absence of errors
Conclusion
Installing a website on a server is a simple process with a clear guide. You can use a control panel or configure everything manually, depending on your goals and knowledge level.If difficulties arise during the process, the DiorHost team is ready to help —
contact them via a ticket on the website or via technical support in Telegram.