Cet article a été vérifié avec RedHat Enterprise Linux, CentOS et Alma Linux
yum install nginx
dnf install nginx
dnf module list nginx
dnf module install nginx:1.18
systemctl enable --now nginx
firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }
server_tokens off; server_names_hash_max_size 512; server_names_hash_bucket_size 128; server_name_in_redirect off;
nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl reload nginx
yum install php-fpm
dnf install php-fpm
yum install php-mysql php-pdo php-gd
dnf install php-mysql php-pdo php-gd
location / {
}
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
vi /etc/php-fpm.d/www.conf
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
systemctl enable --now php-fpm
server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; server_name _; root /usr/share/nginx/html; ssl_certificate "/etc/ssl/nginx/srvwww.linuxtricks.lan.crt"; ssl_certificate_key "/etc/ssl/nginx/srvwww.linuxtricks.lan.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers PROFILE=SYSTEM; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
vi /etc/nginx/conf.d/vhost.conf
server { listen 80; server_name vhost155-1.linuxtricks.lan; location / { root /var/www/vhost155-1/; index index.html index.htm; } } server { listen 80; server_name vhost155-2.linuxtricks.lan; location / { root /var/www/vhost155-2/; index index.html index.htm; } }
server { listen 80; server_name vhost155-2.linuxtricks.lan; location / { root /var/www/vhost155-2/; index index.html index.htm; } }
server { listen 443 ssl http2; server_name vhost155-2.linuxtricks.lan; ssl_certificate "/etc/ssl/nginx/vhost155-2.linuxtricks.lan.crt"; ssl_certificate_key "/etc/ssl/nginx/vhost155-2.linuxtricks.lan.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers PROFILE=SYSTEM; ssl_prefer_server_ciphers on; location / { root /var/www/vhost155-2/; index index.html index.htm; } }
server { listen 80; server_name vhost155-2.linuxtricks.lan; return 301 https://$server_name$request_uri; }