Installing LAMP on Ubuntu

LAMP includes Linux, Apache, MySQL, PHP. Linux is installed on all VPS. Apache, MySQL and PHP are installed automatically when ordering a control panel.

You can install Apache, MySQL, PHP or other software by yourself when ordering VPS Linux without a panel.

Apache

To install a web server Apache run:

sudo apt update

sudo apt-get install apache2

To add Apache to startup run:

Sudo systemctl enable apache2

Run Apache:

sudo systemctl start apache2

To check if the installation is correct, enter the IP address of your server in your browser. If you see a welcome window Apache is ok.

Configuring virtual hosts

Apache allows you to create virtual hosts (virtual web servers). On each such virtual host, you can host a separate site. Several sites can be located and fully functional on one VPS.

If you do not plan to host more than one site on your virtual server yet, it is still better to use virtual hosts. If in the future you have to add one or more sites, this will not cause any difficulties.

1.    Create a site directory:

sudo mkdir /var/www/my_site

sudo mkdir /var/www/my_site/public_html

 my_site - the name of your site

2.    Set access rights:

sudo chmod -R 755/var/www

3.    Disable the standard configuration file (stored by default in Apache in the directory /etc/apache2/sites-available):

sudo a2dissite 000-default

4.    Create a config file for the new host:

sudo nano/etc/apache2/sites-available/my_site.conf

5.    Paste in this file:

<VirtualHost *: 80>

ServerName my_site.com

ServerAlias ​​www.my_site.com

ServerAdmin admin@localhost

DocumentRoot /var/www/my_site/public_html




<Directory/var/www/my_site/public_html>

AllowOverride All

Require all granted

</Directory>




ErrorLog /var/www/my_site/error.log

CustomLog /var/www/my_site/access.log combined

</VirtualHost>

6.    Save the configuration file for the new host.

  • VirtualHost includes the settings for this virtual host.
  • ServerName- domain name of your site (hostname).
  • ServerAlias - alternative domain name.
  • ServerAdmin - server administrator email.
  • DocumentRoot- the root directory where the site files are located.
  • Directory folder-specific settings (/var/www/my_site/public_html).
  • AllowOverride All- permission to allow the settings specified in .htaccess;
  • Require all granted- access to the folder allow for everyone.
  • ErrorLog- path to the file with error logs.
  • CustomLog - path to the file with access logs.

These settings are quite enough for the complete operation of the created virtual host. You can also see the full list of possible settings on the website Apache.

7.    Turn on the site:

sudo a2ensite my_site

8.    Restart Apache:

sudo systemctl restart apache2

9.    The virtual host has been created and configured.

Installing MySQL

1. Run the command:

sudo apt-get install mysql-server

2. Set the database superuser password and press Enter.

After that, re-enter the password 4 times in the dialog box.

3. Configuring basic security settings:

sudo mysql_secure_installation

4. Respond to all system queries.

  • Enter current password for root - database superuser password.
  • Would you like to setup VALIDATE PASSWORD plugin - a password validation plugin.

Press y, and passwords that do not match the security parameters (i.e. too short or too simple) will be rejected,

or press any other key and the plugin will not be installed.

  • Change the root password - n if you don't want to change the password.
  • Remove anonymous users - y to remove anonymous users.
  • Disallow root login remotely - y if you want to disable remote access for root.
  • Remove test database and access to it - y to remove the test database.
  • Reload privilege tables now - y to refresh the user privilege tables.

5. The MySQL database is installed.

Connect to database:

mysql -u root -p

Enter the root password. (root password for MySQL and VPS may be different).

Enter \q to exit.

PHP

Install PHP and core modules:

sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

Install additional modules:

 "apt-get install modul_name".

Get information on a module:

sudo apt show modul_name

The LAMP installation is complete.

If you have any questions, please create a ticket to technical support.