#####################################
# 1. Définir le nom du serveur
#####################################
hostnamectl set-hostname Meissa
####################################
#Installation des packet necessaire
dnf -y update #pour mettre à jour les paquets
dnf -y install epel-release
dnf install -y dhcp-server net-tools zip cockpit bind bind-utils nginx php php-
fpm php-mysqlnd php-mbstring php-xml mariadb-server samba phpMyAdmin wget unzip
dnf install dhcp-server -y
#####################################
# 2. Configurer l'adresse IP statique
#####################################
nmcli con show # Liste les connexions disponibles
nmcli con mod enp0s3 ipv4.addresses 172.16.16.1/24
nmcli con mod enp0s3 ipv4.gateway 172.16.16.254
nmcli con mod enp0s3 ipv4.dns 172.16.16.1
nmcli con mod enp0s3 ipv4.method manual
nmcli con up enp0s3 # Appliquer la configuration
Systemctl restart network-online.target
vim /etc/selinux/config
SELINUX=disabled
reboot
ip a
#####################################
# 3. Configuration du service SSH
#####################################
vi /etc/ssh/sshd_config
# Modifier ou ajouter les lignes suivantes :
# Port 22
# PermitRootLogin yes
# PasswordAuthentication yes
systemctl restart sshd # Redémarrer le service SSH
#####################################
# 4. Configuration du serveur DHCP
#####################################
cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf # apres mon
y pour ecraser puis modifier
avec la ligne suivante
vim /etc/dhcp/dhcpd.conf
# Ajouter la configuration suivante :
subnet 172.16.16.0 netmask 255.255.255.0 {
range 172.16.16.10 172.16.16.100;
option domain-name-servers 172.16.16.1;
option domain-name "ndiaye.com";
option routers 172.16.16.254;
option broadcast-address 172.16.16.255;
# default-lease-time 600;
# max-lease-time 7200;
}
Firewall-cmd --add-service=dhcp --permanent # activer le parefeux
Firewall-cmd --reload # redemarrer le parefeux
Systemctl restart dhcpd
Systemctl status dhcpd
systemctl enable --now dhcpd # Activer et démarrer DHCP
#####################################
# 5. Configuration d’un serveur DNS avec BIND
#####################################
vi /etc/named.conf
# Modifier ces lignes :
# listen-on port 53 { any; };
# allow-query { any; };
zone "meissa.com" IN {
type master;
file "/var/named/meissa.com";
};
zone "produit.com" IN {
type master;
file "/var/named/produit.com";
};
zone "examen.com" IN {
type master;
file "/var/named/examen.com.";
};
zone "16.16.172.in-addr.arpa" IN {
type master;
file "inverse";
};
########################################################################"
apres on entre dans cd /var/named
# Ajouter à la fin :
pour www.meissa.com
tee /var/named/meissa.com << 'EOF'
$TTL 86400
@ IN SOA ndiaye.meissa.com. root.meissa.com. (
2024060201
3600
1800
1209600
86400
)
@ IN NS ndiaye.meissa.com.
www IN CNAME 172.16.16.1
ndiaye IN A 172.16.16.1
EOF
pour www.produit.com
tee /var/named/produit.com<< 'EOF'
$TTL 86400
@ IN SOA ndiaye.produit.com. root.produit.com. (
2024060201
3600
1800
1209600
86400
)
@ IN NS ndiaye.produit.com.
www IN CNAME 172.16.16.2
ndiaye IN A 172.16.16.1
EOF
pour www.examen.com
sudo tee /var/named/examen.com.<< 'EOF'
$TTL 86400
@ IN SOA ndiaye.examen.com. root.examen.com. (
2024060201
3600
1800
1209600
86400
)
@ IN NS ndiaye.examen.com.
www IN CNAME 172.16.16.3
ndiaye IN A 172.16.16.1
EOF
cp meissa.com inverse
vim inverse
ligne7
IN NS server.suffixedns.
server IN NS adresse server
dernier octet d'address IN PTR server.suffixedns.
pour les deux restants
systemctl enable --now named # Démarrer le DNS
#####################################
# 7. Gestion du serveur web (NGINX)
#####################################
systemctl enable --now nginx
# Placer vos fichiers dans /var/www/html
et puis modifier dans vim /etc/nginx/nginx.conf
ensuite à la ligne 42 mettez le chemin /var/www/html
et ajouter à la ligne 43 index nom de votre site "perso:index.html"
#####################################
# 7-configuration site web avec mariadb-server
#pour www.produit.com
-- Connexion à MariaDB
sudo mysql -u root -p
-- Création de la base de données
CREATE DATABASE produit_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Création de l'utilisateur
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'passer';
GRANT ALL PRIVILEGES ON produit_db.* TO 'admin'@'localhost';
-- Création de la table produits
USE produit_db;
CREATE TABLE produits (
id INT AUTO_INCREMENT PRIMARY KEY,
nom_produit VARCHAR(255) NOT NULL,
quantite INT NOT NULL,
prix DECIMAL(10,2) NOT NULL,
date_creation TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
EXIT;
#Demarrer les services
sudo systemctl enable --now nginx
sudo systemctl enable --now php-fpm
sudo systemctl enable --now mariadb
#configuration du server /etc/nginx/conf.d/produit.com.conf
server {
listen 80;
server_name www.produit.com;
root /var/www/produit.com/html/;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
#pour www.examen.com
creation de base de donnée-------
CREATE DATABASE wordpress;
CREATE USER 'admine'@localhost IDENTIFIED BY 'passer';
GRANT ALL PRIVILEGES ON *.* TO 'admine'@localhost;
EXIT;
#montage wordpress voir video
#modification fichier php-fpm deja fait
#creation d'un fichier de configuration
vim /etc/nginx/conf.d/wordpress.conf
###script
server {
listen 80;
server_name meissa.com www.meissa.com;
root /var/www/html/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location ~ /\.ht {
deny all;
}
}
###modification wp-config.php
vim /var/www/html/wordpress/wp-config.php
on redemarre les service nginx,maria etphp-fpm