Installing Debian 9 (Stretch) LAMP Server v1.0

botond published 2019/06/21, p - 14:10 time

The 1. page content

 

Introductory

One is great for creating a development or test environment LAMP server quick compilation. For live websites, however, I would prefer a more serious server configuration, such as a perfect server configuration for Debian to 8 or the Debian to 9.

I have already made a description of the About installing Debian 8 (Jessie) LAMP server v1.0, and in this description we will install the LAMP server components on a Debian 9 (Stretch) operating system, which will consist of:

These components are all official Debian from your trunk will be installed in the versions indicated above. So later, you can easily update your packages at once APT package manager It helps.

As you can see, it used to be MySQL has been replaced by MariaDB, which acts as a full replacement for Debian 9 (Stretch) as the default database engine.

I will label this Debian 9 (Stretch) LAMP installation as version 1.0 because we will add many other add-ons later to make it even more useful and efficient.

 

 

 

basic Conditions

You need a Debian 9 (Stretch) is a minimal server because we will build this LAMP server there.
Of course, it can also be installed on a desktop computer with a graphical environment, the point is that the above components are now first installed on the machine for proper configuration and operation.

 

System Update

First, log in as root and update our repository database and packages as follows apt-get commands:

apt-get update
apt-get upgrade

 

Installing MariaDB

As mentioned above, the default database engine in Debian 9 (Stretch) is MariaDB instead of MySQL. MariaDB can be said to be fully compatible with MySQL, so it handles the databases of our websites without any problems. To install the server and client (remaining as root), enter the following command:

apt-get -y install mariadb-server mariadb-client

Securing your database

We can make our database server and databases more secure by making some settings. There is a separate command for these security settings that guides us through the necessary steps. To start, run mysql_secure_installation command:

mysql_secure_installation
Many of the commands, options, configurations use the "mysql" name to maintain compatibility, while running the MariaDB database engine in the background.

The command first asks us for the database root password:

Securing MariaDB - Requesting a root password

Press enter here, as no root password has been set yet.

You will then be asked if you want to set a root password:

MariaDB Secure - Set your root password

Here we choose yes. You will then be prompted for your new root password and a prompt. Enter a reasonably secure password, which is not very simple. Preferably include numbers, hyphens, etc.

 

 

If you have specified it both times, the next step will ask you to delete anonymous users:

MariaDB Secure - Delete anonymous users

The system provides these anonymous users for development and testing purposes, which we need to delete if we want to secure our database server. So let's choose yes.

The next step is to decide whether to enable or disable remote root access:

Secure MariaDB - Prevent remote root access

Remote logging here means that, for example, if you run a database management software on another machine (such as Windows, Navicat) we want to access the database server for this server as root.
Unlike web database management interfaces running on this server, such as the one below. phpMyAdmin are not considered remote logins because they run on the same server, so localhostlogged in. So here it is Yes If you choose to disable remote root access, you will be able to log in as root as needed from within phpMyAdmin wherever you need it.

So disable remote root access here with the "Y" option.

Then, for test purposes, we have to decide on the fate of the "test" database, which can be accessed by any user:

MariaDB Secure - Remove test database

Here again, select Y to remove the test database and its associated permissions.

Finally, you must reload the authorization tables to apply the changes. He asks us about this too, and here we go yes:

Securing MariaDB - Reloading and completing authorization tables

You then run the necessary background sections and let us know that our MariaDB database system is now secure, so it can be used in a live server environment.

 

 

Install Apache web server

To install Apache2, run the following:

apt-get -y install apache2

The default webroot directory is a / Var / www / html. So by default this is one virtualhoszt is configured during installation, whose configuration file is located here: /etc/apache2/sites-enabled/000-default.conf

cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

So if you want to migrate the web root directory, etc., you need to modify it in this file.

The main configuration file for Apache2 is: /etc/apache2/apache2.conf.

Testing Apache

We test its operation in a browser (for me, the 192.168.1.120 IP addresses):

Apache2 - Welcome Page

 

A next page continue installing PHP7 ...

 

 

Navigation

This description consists of several pages: