sudo apt update sudo apt install nginx ps -aux | grep nginx nginx -v sudo ufw allow 'Nginx HTTP' sudo ufw status curl localhost sudo apt install mysql-server-5.7 sudo mysql_secure_installation xhs@xhs:~$ sudo apt install php-fpm Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php-fpm apt-cache search fpm 换成阿里云的源装了个php5-fpm 打算再换回官方的源装php7-mysql 转念一想,fpm或cgi都只是nginx和php的通讯工具,装哪个都可以 就还是装php7-cgi sudo apt remove php5-fpm 转来转去,还是要安装 fpm 先添加源 add-apt-repository ppa:ondrej/php apt update 后终于有php-fpm了 但依赖有点问题 xhs@xhs:/etc/nginx$ sudo apt install php7.2-fpm Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: php7.2-fpm : Depends: php7.2-common (= 7.2.9-1+ubuntu18.04.1+deb.sury.org+1) but 7.2.10-0ubuntu0.18.04.1 is to be installed E: Unable to correct problems, you have held broken packages. 先卸载之前的吧 dpkg -l | grep php 没理解提示信息,卸载了还是装不上,又update了一下 看到有php7.3版本的,试着安装 sudo apt install php7.3-fpm 可以了 xhs@xhs:/etc/nginx$ systemctl restart php7.3-fpm.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to restart 'php7.3-fpm.service'. Authenticating as: xhs Password: ==== AUTHENTICATION COMPLETE === xhs@xhs:/etc/nginx$ sudo netstat -pantu | grep 9000 xhs@xhs:/etc/nginx$ sudo netstat -pantu | grep 9000 xhs@xhs:/etc/nginx$ systemctl status php php5-fpm.service php7.3-fpm.service php-fpm.service phpsessionclean.service phpsessionclean.timer xhs@xhs:/etc/nginx$ systemctl status php php5-fpm.service php7.3-fpm.service php-fpm.service phpsessionclean.service phpsessionclean.timer xhs@xhs:/etc/nginx$ systemctl status php7.3-fpm.service ● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2018-09-27 10:24:05 UTC; 33s ago Docs: man:php-fpm7.3(8) Main PID: 20140 (php-fpm7.3) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 3 (limit: 2322) CGroup: /system.slice/php7.3-fpm.service ├─20140 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf) ├─20154 php-fpm: pool www └─20155 php-fpm: pool www Sep 27 10:24:05 xhs systemd[1]: Stopped The PHP 7.3 FastCGI Process Manager. Sep 27 10:24:05 xhs systemd[1]: Starting The PHP 7.3 FastCGI Process Manager... Sep 27 10:24:05 xhs systemd[1]: Started The PHP 7.3 FastCGI Process Manager. xhs@xhs:/etc/nginx$ 启动fpm systemctl restart php7.2-fpm #重启 其他相关命令 systemctl start php7.2-fpm #启动 systemctl stop php7.2-fpm #关闭 systemctl status php7.2-fpm #检查状态 接着修改nginx配置文件 ps -aux | grep 9000 查不到 fpm 9000 端口的开启信息 原来还有另一种方式连接,unix sock location ~ \.php$ { include snippets/fastcgi-php.conf; #With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; #With php-cgi (or other tcp sockets): #fastcgi_pass 127.0.0.1:9000; }