centos7.3+nginx1.8+php7.1+mysql5.7 安装(一安装nginx)

前端之家收集整理的这篇文章主要介绍了centos7.3+nginx1.8+php7.1+mysql5.7 安装(一安装nginx)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、先卸载老版本

[plain] view plain copy
  1. yumremoveNginx


2、编辑Nginx的yum源配置

copy

    vi/etc/yum.repos.d/Nginx.repo

往里面写入

copy
    [Nginx]
  1. name=Nginxrepo
  2. baseurl=http://Nginx.org/packages/centos/7/x86_64/
  3. @H_403_85@ gpgcheck=0
  4. enabled=1

3、安装

copy
    yuminstallNginx


启动

service Nginx start
systemctl enable Nginx


查看Nginx 版本 Nginx -v

查看进程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_102_301@vi /etc/hosts

原文链接:https://www.f2er.com/centos/377233.html

猜你在找的CentOS相关文章