1,安装方式
#yum 安装
yum install -y nginx
2,配置
find / -name nginx.conf vi /etc/nginx/nginx.conf 找到 38 行左右 server 如下配置server {listen 80;#端口listen [::]:80;#端口server_name _;root /var/www/html/; #根目录# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;index index.php index.html index.htmerror_page 404 /404.html;location = /404.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}location / {try_files $uri $uri/ /index.php?$query_string;}location ~ \.php$ {root /var/www/html/;fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}
3,php-fpm
启动 nginx 前确保开启php-fpm
ps -ef | grep php-fpm
#没有开启 执行下面命令
systemctl enable php-fpm #开机启动
service php-fpm start #开启php-pfm
4,启动nginx
systemctl restart nginx
systemctl enable nginx