centos7.3+nginx1.8+php7.1+mysql5.7 安裝(一安裝nginx)
1、先解除安裝老版本
- yum remove nginx
2、編輯nginx的yum源配置
- vi /etc/yum.repos.d/nginx.repo
往裡面寫入
- [nginx]
- name=nginx repo
- baseurl=http://nginx.org/packages/centos/7/x86_64/
- gpgcheck=0
- enabled=1
3、安裝
- yum install nginx
service nginx start
systemctl enable nginx
檢視nginx 版本 nginx -v
檢視程序 ps aux|grep nginx
具體版本支援請參考官方文件
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;
}
}
三。虛擬主機
vi /etc/hosts