一) 和apache相比, 基于域名的虚拟主机。 基于ip的虚拟主机。 基于端口的虚拟主机。 二)用remi yum仓库安装 lnmp php 二种工作模式 listen=127.0.0.1:9000 listen=/run/php-fpm.sock 1.14.174.227 G46D~V{n-7P2.`v 2.1) 配置epel仓库, 配置remi仓库 two factor authorized/auth双因子认证。 curl -LO / wget -c 断点续传 / ariac ##下载的命令 Wizard 巫师 向导。 deprecated 放弃的 / legacy 古老的 旧的 YUM/DNF 包管理工具 yum dnf # fedora dnf cdn content delivery network 网站加速。 地理位置上靠近 客户。 网站备案前,80端口是不能被访问的。 rm -rf .nginx.conf.swp ## vi编辑文件,ssh中间断开,导致文件打开没有关闭。 spare /idle 空闲 同一台机器之内,进程之间通信,unix socket文件,或者通过 ip:端口 (localhost:port 127.0.0.1:9000) sshd usedns netstat -tunlp tcpdump -nni ens33 traceroute -n [root@VM-48-13-centos yum.repos.d]# ll |grep remi -rw-r--r-- 1 root root 1314 Oct 16 10:00 remi-php74.repo -rw-r--r-- 1 root root 2605 Nov 28 2023 remi.repo -rw-r--r-- 1 root root 750 Nov 28 2023 remi-safe.repo yum -y install php php-fpm php-common php-pear \ php-pdo php-mysql php-pgsql php-pecl-memcache \ php-gd php-mbstring php-mcrypt php-xml location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } #### 默认根目录 /usr/share/nginx/html /etc/php.ini 主配置文件 /etc/php-fpm.conf ## include 目录 /etc/php-fpm.d vi /etc/php-fpm.d/www.conf ## 这个用户,与nginx或者apache用户相同。 chown -R nginx:nginx /usr/share/nginx/html ## 指网站根目录的属主 属组权限。 24 user = nginx 26 group = nginx 38 listen = 127.0.0.1:9000 # 可以配置为局域网其他 ip:900 36 ; '/path/to/unix/socket' - to listen on a unix socket. 37 ; Note: This value is mandatory. 38 ;listen = 127.0.0.1:9000 39 listen = /run/php-fpm.sock ## listen = /tmp/php-fpm.sock 没有生成sock文件 ## 指的是socket文件的权限 52 listen.owner = nginx 53 listen.group = nginx 54 listen.mode = 0660 ### nginx去访问 unix sock 文件 50 location ~ \.php$ { 51 # fastcgi_pass 127.0.0.1:9000; 52 fastcgi_pass unix:/run/php-fpm.sock; 53 fastcgi_index index.php; 54 include fastcgi.conf; 55 } 2.3) nginx upstream ### 配置 在http段之内 1 server { 2 listen 80; 3 # server_name localhost qm123.com y5.com 1.1.1.1; 4 server_name www.qingmei.com; 5 #charset koi8-r; 6 7 #access_log logs/host.access.log main; 8 #error_page 404 /404.html; 9 location / { 10 proxy_pass http://backend_y5; 11 proxy_set_header Host $host; 12 proxy_set_header X-Real-IP $remote_addr; 13 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 14 proxy_set_header X-Forwarded-Proto $scheme; 15 } ## 整合后。 [root@www conf.d]# cat qm123.com.conf upstream backend_y5 { # 主服务器,权重高,处理更多流量 server 192.168.139.82:80 weight=3 max_fails=2 fail_timeout=30s; # 次级服务器,权重低 server 192.168.139.84:80 weight=1 max_fails=2 fail_timeout=30s; # 维护中的服务器,暂时不参与调度 # server 192.168.1.13:8080 down; } server { listen 80; # server_name localhost qm123.com y5.com 1.1.1.1; server_name www.qingmei.com; #charset koi8-r; #access_log logs/host.access.log main; #error_page 404 /404.html; location / { proxy_pass http://backend_y5; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }