MODOP – Installation Apache / Mysql / PHP/Firewall – Arch Linux

– Apache 2.4 –

1°) Installation Apache 2.4

[root@archlinux /]# pacman –Sy
[root@archlinux /]# pacman -S apache
[root@archlinux /]# systemctl enable --now httpd
[root@archlinux /]# httpd –v

Server version: Apache/2.4.48 (Unix)
Server built: May 28 2021 16:40:47

2°) Création de Multi-Site

Répertoire sites

[root@archlinux /]# mkdir -p {/var/www/site1,/var/www/site2}

Création Index sites

[root@archlinux /]# vi /var/www/site1/index.html

<html>
 <head>
 <title>site 1</title>
 </head>
 <body>
 <h1>Welcome sur le Site1</h1>
 </body>
</html>
[root@archlinux /]# vi /var/www/site2/index.html

<html>
 <head>
 <title>site 2</title>
 </head>
 <body>
 <h1>Welcome sur le Site2</h1>
 </body>
</html>

Rules Sites

[root@archlinux /]# chown -R http.http /var/www
[root@archlinux /]# chmod -R 755 /var/www

Configurer Apache Multi Host

[root@archlinux /]#vi /etc/httpd/conf/httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
[root@archlinux /]# vi /etc/httpd/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
 ServerAdmin chris@house.cpb
 DocumentRoot "/var/www/site1"
 ServerName house.cpb
 ServerAlias www-site1.house.cpb
 ErrorLog "/var/log/httpd/site1-error_log"
 CustomLog "/var/log/httpd/site1-access_log" common

<Directory /var/www/site1/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride all
 Require all granted
</Directory>

</VirtualHost>

<VirtualHost *:80>
 ServerAdmin chris@house.cpb
 DocumentRoot "/var/www/site2"
 ServerName house.cpb
 ServerAlias www-site2.house.cpb
 ErrorLog "/var/log/site2-error_log"
 CustomLog "/var/log/httpd/site2-access_log" common

<Directory /var/www/site2/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride all
 Require all granted
</Directory>

</VirtualHost>

Ajout des Hosts

[root@archlinux /]# echo "127.0.0.1 www-site1.house.cpb www-site2.house.cpb" >> /etc/hosts
[root@archlinux /]# systemctl restart httpd

Ajouter à vos DNS les site www-site1 et www-site2.

  • Si vous n’avez pas de DNS alors ajouter à votre Host Machine

Dans un navigateur

– PHP8 –

[root@archlinux modules]# pacman -S php
[root@archlinux ~]# pacman -S php-apache php-cgi php-fpm php-gd php-embed php-intl php-imap php-redis php-snmp
[root@archlinux /]# php -v

PHP 8.0.9 (cli) (built: Jul 31 2021 08:10:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
[root@archlinux /]# vi /etc/php/php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/Paris

Création Index PHP sites

[root@archlinux /]# vi /var/www/site1/index.php

<?php
echo "<center><h2> Site 1 </h2></center>";
phpinfo();
?>
[root@archlinux /]# vi /var/www/site2/index.php

<?php
echo "<center><h2> Site 2 </h2></center>";
phpinfo();
?>

Rules Sites

[root@archlinux /]# chown -R http.http /var/www
[root@archlinux /]# chmod -R 755 /var/www

Modification des fichiers de conf Apache

[root@archlinux ~]# vi /etc/httpd/conf/httpd.conf

Commenter

#LoadModule mpm_event_module modules/mod_mpm_event.so

Décommenter

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Ajouter
##Module PHP8

LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf
[root@archlinux ~]# systemctl stop httpd && systemctl start httpd

Dans un navigateur

– MariaDB –

Installation MariaDB

[root@archlinux ~]# pacman -S mariadb
[root@archlinux ~]# mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Démarrage Service

[root@archlinux ~]# systemctl enable mysqld
[root@archlinux ~]# systemctl start mysqld

Ajouter Credentials root

[root@archlinux ~]# mysql -u root –p

MariaDB [(none)]> select Host,User from mysql.user;

MariaDB [(none)]> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘bettyboop’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’localhost’;
MariaDB [(none)]> FLUSH PRIVILEGES;

– Firewall –

Installation firewall

[root@archlinux ~]# pacman -S firewalld

Démarrage du service

[root@archlinux ~]# systemctl enable firewalld
[root@archlinux ~]# systemctl start firewalld

A ce stade les deux sites ne sont plus accessible via des machines clientes.

Ajout des rules http

[root@archlinux ~]# firewall-cmd --list-service
dhcpv6-client ssh
[root@archlinux ~]# firewall-cmd --add-service=http --zone=public --permanent
[root@archlinux ~]# firewall-cmd --reload
[root@archlinux ~]# firewall-cmd --list-service
dhcpv6-client http ssh

Views: 67

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *