nginx、PHP安装配置
1、安装nginx
sudo apt-get install nginx
可能会遇见一下错误:
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-full (<< 1.14.2-2+deb10u5.1~) | nginx-light (<< 1.14.2-2+deb10u5.1~) | nginx-extras (<< 1.14.2-2+deb10u5.1~); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-full (>= 1.14.2-2+deb10u5) | nginx-light (>= 1.14.2-2+deb10u5) | nginx-extras (>= 1.14.2-2+deb10u5); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
解决:
1.安装nginx-common:sudo apt-get install nginx-common
-
从 /etc/nginx/sites-enabled/default 中删除
listen [::]:80 default_server;
(我使用 root-user 进行了此操作)
3.sudo apt-get update
,然后是sudo apt-get upgrade
。
4.现在我终于调用了sudo apt-get install nginx-full
2、配置nginx
sudo vim /etc/nginx/sites-available/default
server
{
listen 80; # 443是https的端口,如果你用的是http就用‘80’代替‘443 ssl’
#server_name webofhu.com; #此处用你的域名代替webofhu.com
root /home/demo/myweb; #此处用网站的位置代替/a/b/c
index index.php index.html index.htm;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
切换到/usr/sbin 执行 sudo ./nginx -t 测试配置是否成功
sudo systemctl restart nginx.service
3、安装PHP
sudo apt-get install php-fpm
4、配置PHP
/etc/php/7.3/fpm/pool.d/www.conf
设置如下:
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现