---
title: Installing LAMP on Ubuntu
description: 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 sof
---

[Skip to content](https://help.ishosting.com/en/installing-lamp-on-ubuntu#main-content)

- [English](https://help.ishosting.com/en/installing-lamp-on-ubuntu)
- [Русский](https://help.ishosting.com/ru/installing-lamp-on-ubuntu)

English

Show submenu for translations

[![is\*hosting](https://help.ishosting.com/hubfs/Logo_Ishosting_mono-1.svg)](https://help.ishosting.com/en)

- [Blog](https://blog.ishosting.com/en)
- [Support](https://my.ishosting.com/en/tickets)

Open main navigation

Close main navigation

- [Blog](https://blog.ishosting.com/en)
- [Support](https://my.ishosting.com/en/tickets)
- - [English](https://help.ishosting.com/en/installing-lamp-on-ubuntu)
    - [Русский](https://help.ishosting.com/ru/installing-lamp-on-ubuntu)

  English
  
  Show submenu for translations
- [Go to ishosting.com](https://ishosting.com/)

[Go to ishosting.com](https://ishosting.com/)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://help.ishosting.com/en)
2. [Server Administration](https://help.ishosting.com/en/server-administration)
3. [UNIX Instructions](https://help.ishosting.com/en/server-administration#unix-instructions)

# 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 updatesudo 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_sitesudo 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.comServerAlias ​​www.my_site.comServerAdmin admin@localhostDocumentRoot /var/www/my_site/public_html<Directory/var/www/my_site/public_html>AllowOverride AllRequire all granted</Directory>ErrorLog /var/www/my_site/error.logCustomLog /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](https://httpd.apache.org/docs/2.4/mod/core.html).

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**](https://ishosting.com/en/support).

- [Virtual Private Servers](https://help.ishosting.com/en/virtual-private-servers#main-content)

    - [Getting Started](https://help.ishosting.com/en/virtual-private-servers#getting-started)
    - [Working with VPS](https://help.ishosting.com/en/virtual-private-servers#working-with-vps)
    - [Software](https://help.ishosting.com/en/virtual-private-servers#software)
    - [Backup and Data Storage](https://help.ishosting.com/en/virtual-private-servers#backup-and-data-storage)
    - [Additional Services](https://help.ishosting.com/en/virtual-private-servers#additional-services)
    - [VPS Load](https://help.ishosting.com/en/virtual-private-servers#vps-load)
    - [Other Issues](https://help.ishosting.com/en/virtual-private-servers#other-issues)
- [Dedicated Servers](https://help.ishosting.com/en/dedicated-servers#main-content)

    - [Getting Started](https://help.ishosting.com/en/dedicated-servers#getting-started)
    - [Working with Dedicated Server](https://help.ishosting.com/en/dedicated-servers#working-with-dedicated-server)
    - [Additional Services](https://help.ishosting.com/en/dedicated-servers#additional-services)
    - [Other Issues](https://help.ishosting.com/en/dedicated-servers#other-issues)
- [Server Administration](https://help.ishosting.com/en/server-administration#main-content)

    - [API](https://help.ishosting.com/en/server-administration#api)
    - [Windows Instructions](https://help.ishosting.com/en/server-administration#windows-instructions)
    - [UNIX Instructions](https://help.ishosting.com/en/server-administration#unix-instructions)
    - [ispmanager](https://help.ishosting.com/en/server-administration#ispmanager)
    - [VestaCP](https://help.ishosting.com/en/server-administration#vestacp)
    - [DirectAdmin](https://help.ishosting.com/en/server-administration#directadmin)
    - [BitrixVM](https://help.ishosting.com/en/server-administration#bitrixvm)
    - [Security](https://help.ishosting.com/en/server-administration#security)
    - [DDoS Protection](https://help.ishosting.com/en/server-administration#ddos-protection)
    - [Working with Files](https://help.ishosting.com/en/server-administration#working-with-files)
    - [Databases](https://help.ishosting.com/en/server-administration#databases)
    - [PHP](https://help.ishosting.com/en/server-administration#php)
    - [Logs and Statistics](https://help.ishosting.com/en/server-administration#logs-and-statistics)
    - [Diagnostics and Troubleshooting](https://help.ishosting.com/en/server-administration#diagnostics-and-troubleshooting)
    - [HestiaCP](https://help.ishosting.com/en/server-administration#hestiacp)
    - [cPanel](https://help.ishosting.com/en/server-administration#cpanel)
    - [aaPanel](https://help.ishosting.com/en/server-administration#aapanel)
    - [FastPanel](https://help.ishosting.com/en/server-administration#fastpanel)
    - [Other](https://help.ishosting.com/en/server-administration#other)
- [Mail](https://help.ishosting.com/en/mail#main-content)

    - [Getting Started](https://help.ishosting.com/en/mail#getting-started)
    - [ispmanager](https://help.ishosting.com/en/mail#ispmanager)
    - [DirectAdmin](https://help.ishosting.com/en/mail#directadmin)
    - [VestaCP](https://help.ishosting.com/en/mail#vestacp)
    - [Other Issues](https://help.ishosting.com/en/mail#other-issues)
- [VPN](https://help.ishosting.com/en/vpn#main-content)

    - [Getting Started](https://help.ishosting.com/en/vpn#getting-started)
    - [Android](https://help.ishosting.com/en/vpn#android)
    - [iOS](https://help.ishosting.com/en/vpn#ios)
    - [macOS](https://help.ishosting.com/en/vpn#macos)
    - [Mikrotik](https://help.ishosting.com/en/vpn#mikrotik)
    - [Linux](https://help.ishosting.com/en/vpn#linux)
    - [Windows](https://help.ishosting.com/en/vpn#windows)
    - [Amnezia VPN](https://help.ishosting.com/en/vpn#amnezia-vpn)
    - [Hysteria](https://help.ishosting.com/en/vpn#hysteria)
- [Data Storage](https://help.ishosting.com/en/data-storage#main-content)

    - [Getting Started](https://help.ishosting.com/en/data-storage#getting-started)
    - [Backups](https://help.ishosting.com/en/data-storage#backups)
    - [Other](https://help.ishosting.com/en/data-storage#other)
- [SSL Certificates](https://help.ishosting.com/en/ssl-certificates#main-content)

    - [Getting Started](https://help.ishosting.com/en/ssl-certificates#getting-started)
    - [Install](https://help.ishosting.com/en/ssl-certificates#install)
- [Affiliate Program](https://help.ishosting.com/en/affiliate-program)
- [​​Additional Services​](https://help.ishosting.com/en/additional-services#main-content)

    - [Additional IP](https://help.ishosting.com/en/additional-services#additional-ip)
    - [Control Panels](https://help.ishosting.com/en/additional-services#control-panels)
    - [Antivirus](https://help.ishosting.com/en/additional-services#antivirus)
- [Client Area](https://help.ishosting.com/en/client-area#main-content)

    - [Balance History](https://help.ishosting.com/en/client-area#balance-history)
- [Payment for Services](https://help.ishosting.com/en/payment-for-services#main-content)

    - [Getting Started](https://help.ishosting.com/en/payment-for-services#getting-started)
    - [My Account](https://help.ishosting.com/en/payment-for-services#my-account)
    - [Payments](https://help.ishosting.com/en/payment-for-services#payments)
    - [Other Issues](https://help.ishosting.com/en/payment-for-services#other-issues)
- [Documents and Policies](https://help.ishosting.com/en/documents-and-policies#main-content)

    - [General](https://help.ishosting.com/en/documents-and-policies#general)
    - [Company](https://help.ishosting.com/en/documents-and-policies#company)
- [Questions and Answers](https://help.ishosting.com/en/questions-and-answers#main-content)

    - [Control Panels](https://help.ishosting.com/en/questions-and-answers#control-panels)
    - [ispmanager](https://help.ishosting.com/en/questions-and-answers#ispmanager)
    - [Windows](https://help.ishosting.com/en/questions-and-answers#windows)
    - [Linux](https://help.ishosting.com/en/questions-and-answers#linux)
    - [Mail](https://help.ishosting.com/en/questions-and-answers#mail)
    - [Other](https://help.ishosting.com/en/questions-and-answers#other)
- [Special Offers](https://help.ishosting.com/en/special-offers)
- [is\*smart](https://help.ishosting.com/en/issmart#main-content)

    - [General Info](https://help.ishosting.com/en/issmart#general-info)
    - [Getting Started](https://help.ishosting.com/en/issmart#getting-started)
    - [API](https://help.ishosting.com/en/issmart#api)
    - [AI Models](https://help.ishosting.com/en/issmart#ai-models)
- [List of Apps](https://help.ishosting.com/en/list-of-apps)

[![is\*hosting](https://help.ishosting.com/hubfs/ishosting-logo-black.svg "is*hosting")](https://ishosting.com)

<https://www.facebook.com/ishostingcom> <https://twitter.com/ishostingcom> <https://www.instagram.com/is.hosting> <https://www.youtube.com/@ishosting> <https://www.linkedin.com/company/is-hosting>

Copyright © 2025, © Webrain OÜ