1、先卸载老版本
2、编辑Nginx的yum源配置
copy
service Nginx start
systemctl enable Nginx
查看进程ps aux|grep Nginx
说明:如果想要安装其他版本的只要修改Nginx的yum源配置重安装即可具体版本支持请参考官方文档
http://Nginx.org/en/linux_packages.html#stable
二、配置Nginx
配置Nginx解析PHP
vi /etc/Nginx/Nginx.conf;
user Nginx;
worker_processes 2;
error_log /var/log/Nginx/error.log warn;
pid /var/run/Nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/Nginx/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 /var/log/Nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 300;
#gzip on;
proxy_read_timeout 3s;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
client_max_body_size 256m;
fastcgi_buffer_size 256k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256m;
fastcgi_temp_file_write_size 256m;
include /etc/Nginx/conf.d/*.conf;
}
cd /etc/Nginx/conf.d
ls
vi default.conf
server {
listen 80;
server_name www.xxx.com;
set $root_path /www/apps/project/public;
root $root_path;
index index.PHP index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.PHP?_url=/$1;
}
location ~ \.PHP {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.PHP;
fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
# root $root_path;
# }
location ~ /\.ht {
deny all;
}
}
三。虚拟主机
@H_915_301@vi /etc/hosts