sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
步骤二:导入我们的 GPG 密钥:
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
步骤三:添加我们官方 APT 仓库。
对付 x86_64 或 amd64 系统,可以利用下面的命令:

echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" \ | sudo tee /etc/apt/sources.list.d/openresty.list
步骤四:更新 APT 索引:
sudo apt-get update
然后就可以像下面这样安装软件包,比如 openresty:
sudo apt-get -y install openresty
安装目录
默认安装目录 /usr/local/openresty
运行命令查看状态systemctl status openresty.service启动systemctl start openresty.service停滞systemctl stop openresty.service重载systemctl reload openresty.service在10.10.100.200做事器上安装PHP7.4在正式环境下,最好还是用源码或是yum安装吧,自定义比较方便,这里紧张是为了方便而已
设置软件源并更新(可选 )如果是新做事器,须要做以上的步骤,详细操作这 里不写了
安装php7.4 apt-get install php7.4
安装php7.4-fpm
apt-get install php7.4-fpm
运行命令查看状态systemctl status php7.4-fpm.service启动systemctl start php7.4-fpm.service停滞systemctl stop php7.4-fpm.serviceopenresty 和php的配置文件调度openresty配置文件如下配置文件目录
/usr/local/openresty/nginx/conf
nginx.conf配置文件
解释:这里由于 是本地环境,并没有做任何的优化设置,直接在nginx.conf里修正的,正式环境上自行调度吧
{ worker_processes 1; error_log logs/error.log info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; keepalive_timeout 65; #反向代理池,这里可以设置多个参数,这里省略了 upstream phppools { server 10.10.100.200:9000; } server { listen 80; server_name localhost; location / { root /wwwdata;#这个目录也必须要 在php做事器上有才可以 index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /wwwdata; } location ~ \.php$ { root /wwwdata;#这个目录也必须要 在php做事器上有才可以 fastcgi_pass phppools; #如果php做事器有多个,可以利用upstream来实现 #fastcgi_pass 10.10.100.200:9000; #如果php做事器只有一台,可以这样设置 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#如果访问涌现404时,试试改下这里 include fastcgi_params; } } }
php7.4-fpm配置修正如下配置目录
/etc/php/7.4/fpm/pool.d
www.conf配置文件
须要修正监听 地址 ,须要把127.0.0.1或socket的监听办法改成监听本地ip地址的 办法
listen=10.10.100.200:9000
php 做事器上也须要有与openrestry做事器上有同样的目录,便是 这个/wwwdatap目录,须要与openresty配置文件中的root参数中的目录保持一 样,这样往后你的php项目都是放在这个php做事器上的/wwwdata目录里就可以正常访问了