1.安装依赖包
apt-get install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g zlib1g-dev
sudo apt-get install openssl
sudo apt-get install libssl-dev
2.安装nginx
cd /usr/local
mkdir nginx
cd nginx
tar -xvf nginx-1.21.6.tar.gz
3.编译nginx
```cobol
/usr/local/nginx/nginx-1.21.6
# 执行命令
./configure
./configure --prefix=/home/centos/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module
# 执行make命令
make
# 执行make install命令
make install
```
4.启动nginx
```cobol
cd /usr/local/nginx/sbin
# 启动nginx
./nginx
```
5.访问nginx
6.增加源地址
```
执行三条命令,添加php的源地址,更新,安装
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
```
7.安装php
nginx使用php的话要用到php7.1-fpm,所以要安装
```
sudo apt-get install php7.1-mysql php7.1-fpm php7.1-curl php7.1-xml php7.1-gd php7.1-mbstring php-memcached php7.1-zip
```
8.配置php-fpm
把监听端口改掉
```cobol
;listen = /run/php/php7.1-fpm.sock
listen = 127.0.0.1:9000
```
9.启动php-fpm
```cobol
sudo service php7.1-fpm start
netstat -lnt | grep 9000