How to install your website on a server

How to install your website on a server

16.12.2021
Author: HostZealot Team
2 min.
1703

An empty dedicated server is not suitable for website installation. In this article, we will tell you how to prepare the basic software, and how to configure the control panel of the server and the sites it hosts.

How to prepare your server

First of all, you need to deploy LAMP complex on the server, which consists of 4 most important components:

  1. Linux - meaning any current distribution: Ubuntu, Debian, СentOS, etc.
  2. Apache is a free web server with flexible configuration and a built-in virtual host mechanism that supports modularity. Modules can significantly extend existing functions and add new ones, they can be used to enhance security, fix bugs, add support for new programming languages etc. Most Apache modules are developed by the Apache Software Foundation, but the repositories also contain a wide range of modules from open source developers.
  3. MariaDB/MySQL are database management systems. DBMS provides security, reliability and integrity of data and keeps a log of all changes to the file system.

PHP is the most popular scripting language used to develop web applications and create pages.

Manual configuration of the dedicated server or VPS for a website begins with the deployment of LAMP, as all these components are needed to ensure the functioning of dynamic sites and applications.

Installing LAMP components

We will show, using Ubuntu as an example, how to configure and prepare everything for a server in manual mode via the console. After installing the OS, the first thing you should do is to create and configure a user profile with non-root access rights.

Step two - install the Apache web server

On Ubuntu, this is done through the package manager apt using commands:


$    sudo apt update

$    sudo apt install apache2


The sudo command will initiate the assigned tasks with root-level access, so you will need to enter a password to confirm the operation. You will then get a message telling you which Apache modules will be installed and how much storage space is required. To confirm, type Y and press Enter.

How to configure the firewall and allow web traffic

After installing Apache, you need to make sure that your firewall will pass HTTP and HTTPS traffic correctly. The first thing to do is to check and make sure that the UFW firewall has a profile for the Apache web server:


$    sudo ufw app list


The command line should give us this:


Available applications:

  Apache

  Apache Full

  Apache Secure

  OpenSSH


Finally, initiate a check of the Apache Full profile settings to make sure that traffic is allowed on the two key ports: 443 and 80. To do this we enter two commands one after another:


$    sudo ufw app info "Apache Full"


Next:


$    sudo ufw allow in "Apache Full"


Now you can check if everything working by opening the public IP address of your server in a web browser. If this address is unknown to you, it can be found using the iproute2 tool. Enter the command:


$    ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'


After that, you’ll receive the lines from the command line, which will be the address of your server.

Step three - install MySQL

Let's install the DBMS, which will help us organize access to the databases and convenient storage of all the information from the site. To do this, we again need the installation complex advanced packaging tool. Enter the command:


$ sudo apt install mysql-server


After that, you will see a list of packages before you install them and how much disk space they will require. As in the previous case, enter Y and press Enter. Next, you will have to configure password validation and set the security level for each password. Ideally, choose a value of 2 and choose a password that contains numbers, upper and lower case letters, and special characters. The more complex the password, the better.

Step Four - install PHP

The most important component for displaying dynamic content and executing all scripts. We install it again with the package manager apt. Enter the command:


$ sudo apt install php libapache2-mod-php php-mysql


After that, the component will be installed without any hitches, and you can install the site on the VPS. But this was a manual way to install LAMP components, and it is not the easiest one. It is much easier to do it through the Dedicated Server Control Panel:

  1. In the VPS list, select "Create Server".
  2. Specify the server name and leave a comment if necessary.
  3. Choose target OS and software - in our case Ubuntu distribution and LAMP components.
  4. Specify the optimal configuration of the dedicated server.
  5. Add SSH key - if you don't have one, create one beforehand.
  6. Activate DDoS attack protection.
  7. Pay for the pricing plan.

After these manipulations, you will be able to start hosting your web projects on a server or VPS.

HostZealot offers an even simpler way - when selecting the appropriate pricing plan, you just need to tick the "Install LAMP when creating a VPS" option. The components will be installed on the server by default.

how to install your website on a server

Manually installing the site on a server

Now to install the site, you need to download its data to the server drive. To do this, connect to the server using the SFTP protocol through the FTP-client WinSCP or FileZilla. Most administrators prefer the second one, because it is easier and more convenient. So, launch FileZilla client and do the following:

  1. In the "site manager" click the "New" button.
  2. Write down the name of the connection.
  3. Move your eyes to the right side of the window - there you will see a field "Host", in it you need to enter the IP address of the webserver.
  4. In the "Server Type" box select SFTP using SSH2.
  5. A little higher, you need to enter the port number. By default, it is 22, but if you change it to protect against DDoS, you must enter the actual port.
  6. As the preferred type of identification choose the usual.
  7. Fill in the "Username" field with the standard "root".
  8. Enter the password for a user with root privileges.
  9. Click on "Connect" in the lower left corner of the window.

This will take you to the root directory, and the site will need to be placed at /var/www/html. If the LAMP components were placed manually through the console, the target directory will be /var/www/site1/public_html.

The next step is to connect to the server via SSH. Use the console in the VDS control panel and enter the command:


mysql


Here you have to specify the name of the database, user name, and password. It is recommended to specify the data that are prescribed in the configuration of your site. Here, if necessary, you can also download the database dump via SFTP protocol to /var/www/, and then import it using the command:


mysql -u"login" name_DB -p"password" < /var/www/dump.sql


To work conveniently with all the server data, you can also install the web application phpMyAdmin, it will greatly ease your life.

Installation Guide in ISPmanager

ISPmanager is a web server control panel, which provides ample opportunities for managing the Apache software, DBMS MySQL, and mail server. First, create a new user to work with a limited set of rights - it's safer that way. To do this, do the following:

  1. In the section "Accounts" find the item "Users" and click on "Create".
  2. Enter your username and password, all other settings and parameters are left by default.
  3. Specify the domain name and create an FTP user for the connection.
  4. Click "Finish" to save all the changes.
  5. Return to the section "Users" and log in to the newly created account with the data you previously entered.

Next, we need to connect the domain, to do this go to the registrar's website and specify as the A-record of the server IP. If the domain was not previously added, do it now in the section "WWW domains". For successful completion you will need to specify a domain name and e-mail administrator, all other fields will be filled automatically, you do not need to change anything.

The third step is to upload the site files to the domain. To do this:

  1. Go to "WWW domains", highlight the desired domain and click on "Directory".
  2. Delete the file index.html, which was created by default.
  3. Download the archive with the site files.
  4. Extract the contents of the archive to the directory, which is specified by default.

Now it's a small thing - go to "Main", then to "Databases" and click on "Create". Here, specify the name of the database, user name, and password. Again, the data are written from the configuration file of the site, this is important. If you have an existing database, you can import it using the "Tools" section.

Installation Guide in VestaCP

The first thing we do is create a new user. To do this, in the USER section, click on the green label and fill in all the free fields marked with a red asterisk:

  • username;
  • WWW domain name;
  • IP-addresses;
  • email domain name.

Then connect the domain in the personal office on the website of the registrar, specifying the IP address of the server and its A-record. After that you should add domain to VestaCP. Do the following:

  1. Go to the WEB section.
  2. Click on the green plus sign.
  3. Enter the domain name and set its parameters.
  4. Go to advanced options and activate everything you need, from SSL support to analytics.

It is not necessary to change the default settings, but you can do so if necessary. If you are satisfied with the default values, just save the configuration.

The next important step is to create a database. This is done in the DB:

  • Add a new database using the green plus sign;
  • Write the necessary parameters;
  • Click on phpMyAdmin to import the database dump;
  • Change the configuration file of the site so that it contains the name of the database, login and password.

In the end, to install the site on a server, all that remains is to upload its files to the server via SFTP. We told you above how to do it with the help of the FileZilla tool.

Transferring a website to another server with the help of technical support

This instruction will be useful for those companies, whose website is already up and running and currently located in the capacities of a third-party hosting provider. In order to quickly move your website to another dedicated server, you will need the following:

  1. Gain access to the remote hosting via FTP or SSH.
  2. Analyze the remote site configuration: whether any kind of CMS is used, what kind of DBMS is used.
  3. Prepare the host dedicated or virtual server: create virtual hosts, work out the directory structure, create an empty database, and database user.
  4. Copy site files and database dump to the host server hardware.
  5. Correct the rights to the files, deploy the database dump, fix the configuration files (adding a new database user name, database name, if necessary, additional variables).
  6. Perform a basic check of the site health with the hosts’ file. If possible, this operation should be performed by the client.
  7. Redirect the domain to a new IP address (the client may need to participate).

The HostZealot Technical Support Team will assist you with all of this - feel free to contact us at any time to learn more details and arrange cooperation. Here we end our article and hope that it helped you to understand how to set up a website on a server without any assistance.

Related Articles