Step-by-step guide on how to setup your Linux server and host website on it

Written by prodigitalweb

Here in this article, you will get full instruction about setting up dedicated servers in Netherlands or any other location. Just follow all the instructions and you will easily customize everything and get key recommendations about the site’s hosting.

LAMP peculiarities and why is it needed?

If shortly, LAMP is a stack that is founded on MySQL, Apache, PHP, and Linux. Let’s start with a detailed step-by-step process of configuring this specific stack and hosting a website.

  1. Install Linux

In case you are reading this article, then it is obvious that you have already installed the needed OS. For those who have not yet, use the official platform for the installation.

  1. Install Apache

There are a couple of variants to install the web server and let’s discuss these options. First of all, you will need to install SSH but prior to that check whether there are all the upgrades and updates. For the installation and activating of SSH, you should type the following commands:

$ sudo apt install openssh-server

$ sudo systemctl enable –now ssh

After checking that SSH is functioning, you may proceed to the Apache installation. Start by typing the following command into the terminal window:

$ sudo apt-get install apache2

Once the installation process has finished, check it by entering http:// <IP> into the web browser. Instead of <IP> insert your real IP address. If everything is okay, you will enter the default page. If not, then you can try to config the firewall by UFM installation.

  1. Install MySQL

A database management sys is important for the web app so let’s describe the process of MySQL installation. Type the following command in the terminal:

$ sudo apt-get install mysql-server

After that, you will be prompted to create a pass for the root access of MySQL. The last thing will be to check the service status.

  1. Install PHP

The stable variant of this scripting language and additional modules are really important. So, start this process by opening a terminal window and using the following line:

$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-cgi php-curl php-json

After the completion of the process, you’d better check whether the latest version is available.

  1. Create a directory for the domain

Once you have successfully completed the LAMP installation, you may continue the setup of the hosting. For the creation of the site, there should be a specific place where all the files will be stored and it is called a directory.

Start by moving to /var/www directory with cd command, it should be:

$ cd /var/www

The directory is created by the following command where you should change into your site’s domain:
$ sudo mkdir -p /var/www/

The next step will be connected with the assignment of needed permissions and ownerships in the created directory.

  1. Testing with the sample page

Sample page can be created with Nano or any other available editors for these purposes. Begin with the following command:

$ nano /var/www/

After that add the next code to the chosen editor:



<title>Hello My Site</title>



<h1>Thank you for visiting!</h1>



That is it, the sample page is almost ready, now you close the editor and save changes.

  1. Creation of the virtual host file

If you have successfully completed all the above steps, the last thing is making your sample page accessible online. For completion of this step, it is needed to make a virtual host file in Apache.

$ sudo nano /etc/apache2/sites-available/

After that add the mentioned below lines to the conf file:

<VirtualHost *:80>

ServerAdmin (fill in your info)

ServerName (fill in your info)

ServerAlias (fill in your info)

DocumentRoot /var/www/(fill in your info)

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined


Once you have completed this process, exit an editor and enable config file. Don’t forget to disable the default file with a2dissite command. Restart Apache with the next command:

$ sudo systemctl restart apache2

  1. Testing the hosted website

The testing should start with the error search in the host conf. To perform this, type the following in the terminal window:

$ sudo apache2ctl configtest

In case, there are no problems and syntax shows okay then restart Apache. Now, you can proceed to enter your sample page. If you can access it via a web browser then the process is completed

Summing up

Now, you have a full guide about the setting up of the server and hosting a site. With the LAMP stack, you can locally host a site by following a simple procedure that we have discussed in the article. All you should do is a couple of installations, create the directory, sample page, and virtual host file. There should not be any challenges if you are doing everything step-by-step and following our instructions.

About the author