Nginx¶
基础环境,在Debian12,通过apt安装nginx
基础信息¶
# 版本是1.22.0起,后续会更新
# 安装路径
/etc/nginx/
常用命令¶
#安装
sudo apt install nginx
# 启动
sudo systemctl start nginx
# 测试
nginx -t
# 重启
nginx -s reload
# 开机自启
sudo systemctl enable nginx
# 查看状态
sudo systemctl status nginx
# 查看端口占用,使用netstat命令,需安装net-tools: apt install net-tools
sudo netstat -tulnp | grep ':80'
# 建立用户组
groupadd www
useradd -g www -s /sbin/nologin www
id www
# 给权限
sudo chown -R www-data:www-data /data/wwwroot/default
sudo chmod -R 755 /data/wwwroot/default
连接php¶
location ~ [^/]\.php(/|$) {
#fastcgi_pass 127.0.0.1:9000;
# cat /etc/php/8.2/fpm/pool.d/www.conf | grep 'listen ='
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}