nginx服務

cftak發表於2024-10-30

IspSrv

服務

WEB服務
安裝nginx軟體包。
建立ispweb.chinaskills.cn站點。
配置檔名為ispweb.conf,放置在/etc/nginx/conf.d/目錄下。
網站根目錄為/mut/crypt(目錄不存在需建立)。
啟用FastCGI功能,讓nginx能夠解析php請求。
index.php內容使用Welcome to 2023 Computer Network Application contest!

安裝服務

apt install nginx php* -y

編輯nginx配置檔案

cp -p /etc/nginx/sites-enabled/default /etc/nginx/conf.d/ispweb.conf

vim /etc/nginx/conf.d/ispweb.conf

server {
	listen 80 ;
	listen 443 ssl;	#配置https,可選,下面需要證書檔案
	include snippets/snakeoil.conf; #配置https,證書檔案路徑目錄
	root /mut/crypt;
	index index.php;
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass  unix:/run/php/php7.3-fpm.sock;
	}
}

vim /etc/nginx/nginx.conf

64:# include /etc/nginx/sites-enabled/*;

https

AppSrv:
#傳遞http證書,需要ispsrv開啟ssh服務
scp /csk-rootca/httpd.* 81.6.63.100:/ca

vim /etc/nginx/snippets/snakeoil.conf
#新增
ssl_certificate /ca/httpd.pem;
ssl_certificate_key /ca/httpd.key;

編輯網頁檔案

mkdir -p /mut/crypt

echo "Welcome to 2023 Computer Network Application contest!" > /mut/crypt/index.php

啟動服務

systemctl start nginx
systemctl enable nginx

驗證

image-20241030210040797

相關文章