PHP环境搭建(8)----nginx安装与配置

本文介绍了如何在CentOS 6系统中安装Nginx 1.10.3版本,并提供了基本的配置示例。首先,通过编辑nginx.repo文件添加Nginx的yum源,然后使用yum命令安装指定版本的Nginx。接着,查看安装的Nginx版本并编辑主配置文件nginx.conf,设置worker_processes的数量。最后,启动、停止或检查Nginx服务状态。
摘要由CSDN通过智能技术生成

1.# vim /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/6/$basearch/

gpgcheck=0

enabled=1

保存退出

2.#yum install nginx-1.10.3(安装指定版本)

3.#nginx –v(查看版本)

4.#vim /etc/nginx/nginx.conf

user work

worker process数目根据实际cpu来填写

5.#service nginx start|stop|status|restart


配置样例一
nginx.conf

user  work;
worker_processes  16;


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  65;


    #gzip  on;


    include /etc/nginx/conf.d/*.conf;
}


sdxf.conf

server {
    listen       80;
    server_name  localhost;


    root /home/work/sdxf/server/web;
    index index.php index.html index.htm;
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;


    location / {
try_files $uri $uri/ /index.html;
if (!-e $request_filename){
rewrite  ^/(.*) /index.php;
}
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
    }


location ~ \.php$ {
fastcgi_split_path_info ^(.&#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值