VPS is Virtual Private Server. Here virtual operating system resides within the parent server and provides dedicated resources to other virtual servers by using virtualization technology. VPS server copies the properties of a physical server with similar processes and functionality.
VPS hosting is in the middle of less expensive shared hosting and more expensive dedicated hosting. Instead of paying for a dedicated server, it’s more affordable to pay for VPS hosting. Here, the costs are split across several users but still, you can enjoy having a private allocation of resources.
Steps to Configure VPS Server
How to Configure VPS Server
The exact steps for configuring VPS will vary depending on the operating system.
Here, we will guide you to set up VPS on Linux.
Access the server via SSH
SSH is the network protocol that provides communications between client and server in an encrypted way.
If you’re accessing the server via SSH for the first time, you need to enter root login credentials.
This is the command you need to use:
ssh [root username]@[server IP]
After that provide the password. Now it will enter into the command line.
Update the Server
The first important thing you have to do is to update the server. By updating the server, new security patches and features will be installed.
The commands vary for different distributions.
For Ubuntu and other Debian-based distributions,
apt update
By this server checks the operating system’s software packages and displays the one which needs the update. To proceed with the updates use the below command
apt upgrade
For CentOS and RHEL,
yum check-update or dnf check-update
To proceed with the updates,
yum update or dnf update
It will take some time. After the update, you need to restart the server using the reboot command.
Create a new user
Till now you’re working as a server’s root user. It means you have all the privileges to the server without any restrictions. With the elevated privileges, even a small mistake makes a very big thing.
So create a second account with superuser permissions. With this, you can still configure important settings, but need to add sudo prefix to every command that requires administrative privileges.
Command to create a new user:
adduser [the new user’s username]
Now it will ask to pick a password and provide a few pieces of information. Next thing is, you have to assign this new user to the correct group.
usermod -aG sudo [the new user’s username]
To check this, you can delete the current session and log in with the new user account.
Change the default SSH port
The Default Listening Port is 22. The SSH users already know this, but the hackers also know this fact. To prevent hackers, you need your password should be strong. That’s enough for this.
It’s much better not to take any chances and try to change the SSH default listening port.
Take a backup before doing these changes. Because doing the above-mentioned is editing the SSH configuration file. So it is very useful to have a backup if something happens wrong.
Use the following command:
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_old
use nano – command to edit the SSH configuration File
nano /etc/ssh/sshd_config
Locate the line that says:
#Port 22
To change the SSh port, remove the # in the above line and replace 22 with any number between 1024 and 65535. While giving the new number, better to memorize the new port number. During the next login, you will need to use this new port number. Other Services can’t able to use the new SSH port.
Next, save the SSH configuration file and restart the SSh server to apply the changes.
Use the below command to restart the SSH service.
systemctl restart ssh
Use sudo prefix with the command, if you’re not logged in with the root access.
Generate SSH keys
Changing SSH’s default listening port protects your servers from automated scripts that randomly browse the internet and attempt to hack servers. To block the targeted attacks, it’s best to enable your authentication mechanism.
The Basic username and Password will be enough when it is a strong password. Moreover, SSh user public and private key for authentication.
For this, you have to first generate the SSH Key. You can easily generate the key using the PuTTYgen application with the SSH client.
Open the PuTTYgen app and click Generate. It will generate the keys for you (public and private). You can see the generated public key at the top of the box.
Before you go any further, you’ll need to create a passphrase that will work along with the key pair as a password.
To save the key to your computer, click Save Private Key. Now for the public one.
Log in to your server as root and open your account’s home directory with the following command,
su – [your username]
First, you have to create a folder to host your public key and also set the permissions allowing you to create the file in it.
The commands are:
mkdir ~/.ssh
chmod 700 ~/.ssh
To paste the generated public key, you will need to create a file for this.
Now you have to use the nano text editor once again,
nano ~/.ssh/authorized_keys
To use the key pair and connect to your account using PuTTY, open the SSH client settings and go to Connection > SSH > Auth. Use the Private Key File for Authentication field to select your private key and save the changes.
Next, to disable your account’s password authentication, you have to edit the SSh configuration file – etc/ssh/sshd_config. It is very easy. You have to change the PasswordAuthentication value from Yes to No.
Set up a firewall in VPS
A firewall is one of the important security measures for the server. It works as a security device for networks that monitor the incoming and outgoing traffic to find out which is safe or not safe for the network based on the rules which we added while setting up a firewall.
Most Linux distributions use a firewall called IPtables. It’s a rule-based firewall system that is normally pre-installed on the operating system. By default it is running without any rules, we can edit or create into it.
The default configuration tool for Ubuntu is UFW and CentOs is Firewalld.
1 ping google.com
2 ping 8.8.8.8
3 nano /etc/resolv.conf
4 nano /etc/ssh/ssh_config
5 ping google.com
6 systemctl restart sshd
7 systemctl restart ssh
8 systemctl restart ssh
9 nano /etc/ssh/ssh_config
10 service ssh restart
11 service sshd restart
12 apt update -y
13 apt upgrade -y
14 apt install open-ssh
15 apt install openssh-server
16 apt install openssh
17 nano /etc/ssh/ssh_config
18 apt update -y
19 apt upgrade -y
20 apt-get install openssh-server
21 nano /etc/apt/sources.list
22 apt-get install openssh-server
23 reload
24 reboot
26 pwd
apt install apache2 php8.2 php8.2-cli php-8.2{bz2,curl,mbstring,intl,sqlite3,php-xml,xmlreader} mariadb-client mariadb-server mc
36 hostname
38 ip addr
chown -R www-data:www-data /var/www/admission && chmod -R 777 /var/www/admission
75 nano /var/www/admission/index.html
76 a2ensite admission
77 a2enmod rewrite
78 systemctl restart apache2
79 nano /etc/apache2/sites-available/admission.conf
80 a2ensite admission
81 a2enmod rewrite
87 systemctl restart apache2
90 reboot
91 systemctl status apache2
Installing on Ubuntu / KB / Ajenti
How To Install the Ajenti Control Panel and Ajenti V on Ubuntu 14.04 | DigitalOcean
How install TinyCP in debian base linux:
sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv –fetch-keys http://repos.tinycp.com/ubuntu/conf/gpg.key
echo "deb http://repos.tinycp.com/ubuntu all main" | sudo tee /etc/apt/sources.list.d/tinycp.list
sudo apt update
apt install tinycp
Top 5 Free Web Hosting Control Panels To Manage VPS/Dedicated Servers
Web Hosting Control Panels
How to install TinyCP in Linux - GeeksforGeeks
/etc/apache2/apache2.conf
IncludeOptional /opt/tinycp/domains/*/apache.conf
IncludeOptional /opt/tinycp/etc/apache.conf
/opt/tinycp/etc/tinycp.conf
for change port
How to Enable/Disable SSL for Webmin Control Panel
Why & how we disable SSL in Webmin?
How to Install Virtualmin on Debian - Tony Teaches Tech
How to install Webmin on Debian 11 Bullseye Server Linux - Linux Shout
Connecting to Webmin | Webmin Administrator's Cookbook
apache 2.2 - How can I access Webmin without a port? - Server Fault
If you just want Webmin to be accessible via Apache gateway follow the steps below:
/etc/webmin/config
file and add the following line:referers=webmin.example.com
/etc/webmin/miniserv.conf
file, add the following lines and restart Webmin afterwards by calling /etc/webmin/restart
command:redirect_ssl=1 redirect_host=webmin.example.com
How To Use Apache as a Reverse Proxy with mod_proxy on Ubuntu 16.04 | DigitalOcean
mod_proxy - Apache HTTP Server Version 2.2
/etc/apache2/sites-available/webmin.conf
<VirtualHost *:80>
ServerName webmin.fadak.ir
ServerAlias webmin.fadak.ir
ProxyPass / http://localhost:10000/
ProxyPassReverse / http://localhost:10000/
<Proxy *>
Allow from all
</Proxy>
</VirtualHost>
FortiClient Linux Product Downloads Information
mysql - How to reset a Linux VPS to 0 in one command? - Stack Overflow
sudo apt update&&sudo apt install -y curl&& sudo bash -c "$(curl -Lfo- https://raw.githubusercontent.com/hiddify/hiddify-config/main/common/download_install.sh)"
All tutorials and videos · hiddify/hiddify-config Wiki · GitHub
راهنمای جامع پیکربندی | Hiddify
Install Hiddify using Docker · hiddify/Hiddify-Manager Wiki · GitHub
A connection with the server could not be established - Microsoft Q&A
linux - Allow access to Apache on both port 80 and 443 in Ubuntu 16.04 - Unix & Linux Stack Exchange
CrownCloud Wiki - How To Install PHP 8 2 Debian 11
How To Set Up a Firewall with UFW on Debian 11 | DigitalOcean
How to Check for Open Ports on Debian 11 - VITUX
میزبانی چند وب سایت روی یک وب سرور آپاچی (بخش اول)
Port Checker - Check Open Ports Online
How to set up Apache Virtual Hosts on Debian 11 – Its Linux FOSS
How to Install Ajenti Control Panel in Debian and Ubuntu
How to Do ISPConfig in Debian 11 - Distroid
apache - How to Set AllowOverride all - Stack Overflow
Access Control for Apache 2.4 (and 2.2) | .htaccess made easy
دوره آموزشی آپاچی وب سرور: مدیریت - Apache Web Server: Administration
apt-get -y install zfsutils-linux
apt-get -y install vsftpd
apt-get -y install libpam-pwdfile
apt-get -y install apache2-utils
apache2-utils libapr1 libaprutil1
apt-get -y install dnsutils
apt-get -y install lynx
apt install fcgiwrap
systemctl enable nginx
systemctl start nginx
HAProxy چیست؟ آشنایی با لود بالانسر قوی سرورها - پارس پک