Full installation of Linux LAMP server, Apache, MySql, PHP Debian 11
This tutorial describes how to comprehensively install a LAMP server or Apache basic services, MySql, Php and phpmyadmin.
We will install all packages step by step.
First, we will install the Apache web server:
1 | apt-get install apache2 apache2-utils -y |
command:
1 | apache2 -v |
We can check the Apache version:
1 2 | Server version: Apache/2.4.48 (Debian) Server built: 2021-08-12T11:51:47 |
We run Apache with commands:
1 | systemctl start apache2 |
1 | systemctl enable apache2 |
After going to our ip address in the browser, we should see the Apache start page
The next step is to install the MariaDB database server
We install:
1 | apt-get install mariadb-server -y |
And we run:
1 | systemctl start mariadb |
1 | systemctl enable mariadb |
We can verify the operation status by issuing an order:
1 | systemctl status mariadb |
below the result:
1 2 3 4 5 6 7 8 9 10 11 | ? mariadb.service - MariaDB 10.3.31 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-08-21 04:13:25 UTC; 1min 36s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 1838 (mysqld) Status: "Taking your SQL requests now..." Tasks: 31 (limit: 2353) Memory: 66.1M CGroup: /system.slice/mariadb.service ??1838 /usr/sbin/mysqld |
We issue a command in the console:
1 | mysql_secure_installation |
And we do the initial configuration as below:
1 2 3 4 5 6 7 8 | Enter current password for root (enter for none): Change the root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y |
You can log into mysql by issuing a command:
1 | mysql -u root -p |
And by entering the password we have just set.
We can install PHP by issuing the command:
1 | apt-get install php libapache2-mod-php php-cli php-mysql php-zip php-curl php-xml -y |
We can check the php version by entering the command in the console:
1 | php -v |
the result of the:
1 2 3 4 | PHP 7.4.21 (cli) (built: Jul 2 2021 03:59:48) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies |
The last step is to create our domain vhost.
We create a directory of our domain:
1 | mkdir /var/www/html/domena.pl |
we grant powers:
1 | chown -R www-data:www-data /var/www/html/domena.pl |
We create the vhost configuration file by issuing the command:
1 | nano /etc/apache2/sites-available/domena.pl.conf |
The content:
1 2 3 4 5 6 7 | <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName domena.pl DocumentRoot /var/www/html/domena.pl ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> |
And we save the file.
We add our vhost to active:
1 | a2ensite domena.pl.conf |
1 | a2dissite 000-default |
We check the configuration:
1 | apache2ctl configtest |
And we're reloading the Apache server:
1 | systemctl reload apache2 |
The only thing left for us to do now is redirect the domain to the ip of our server.