Almalinux 9 nginxのconf ファイルを設定する方法
環境
Almalinux 9.2
php 8.1
nginx 1.20
概要
1.rootディレクトリの指定
root /var/www/html;
2.アクセスログとエラーログの指定
access_log /var/log/nginx/example-com-access.log;
error_log /var/log/nginx/example-com-error.log;
3.fastcgi_passの指定
fastcgi_pass unix:/var/run/php-fpm/www.sock;
操作方法
server {
listen 80;
server_name example.com;
keepalive_timeout 5;
access_log /var/log/nginx/example-com-access.log;
error_log /var/log/nginx/example-com-error.log;
location / {
root /var/www/html;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
include /etc/nginx/mime.types;
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server {
listen 80;
server_name example.com;
keepalive_timeout 5;
access_log /var/log/nginx/example-com-access.log;
error_log /var/log/nginx/example-com-error.log;
location / {
root /var/www/html;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
include /etc/nginx/mime.types;
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server { listen 80; server_name example.com; keepalive_timeout 5; access_log /var/log/nginx/example-com-access.log; error_log /var/log/nginx/example-com-error.log; location / { root /var/www/html; index index.php index.html; try_files $uri $uri/ /index.php?$args; include /etc/nginx/mime.types; } location ~ \.php$ { root /var/www/html; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }