ecshop+mysql+配置文件_ecshop下配置linux和nginx.conf分析

最近在研究将ecshop转移到nginx下。是为了让ecshop在nginx下更加的发挥自己的特长。提高运行效率。上章我们讲述了如何安装php+mysql+nginx+fascgi。本章我们将结合ecshop+centos+nginx来谈谈如何在nginx下建立虚拟主机。首先我们来分析下nginx.conf

这个是nginx下面的主要配置文件。如果这个文件没配置好,那么nginx将运行不起来。我们修改了nginx.conf之后我们可以通过./nginx -t来测试下nginx是否生效了。

nginx.conf主要有以下几个方面组成。

user  nginx;这个指的是nginx下的用户组,默认是使用用户

如果我们需要在nginx下新增加虚拟主机怎么办,那么很简单。我们必须将server复制几个。把主要的数据填写进来。

server {

limit_conn addr 10;

listen       80;

server_name  _;

root /opt/www;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

# root   /usr/share/nginx/html;

index  index.html index.htm;

}

error_page  404              /404.html;

location = /404.html {

# root   /usr/share/nginx/html;

}

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

# root   /usr/share/nginx/html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

# root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# include        fastcgi_params;

include        fastcgi.conf;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

location ~ /\.ht {

deny  all;

}

}

首先要定义root目录。这个是工作目录,我们可以自己在所有的环节面前定义root /opt/www,然后其他环节里面的root都可以注释掉了。比如404页面,你也要在root里面定义。

error_page  404              /404.html;

location = /404.html {

# root   /usr/share/nginx/html;

}

如果想nginx执行fastcgi。就必须调用fastcgi.conf里面的变量。

include        fastcgi.conf;

我们通过以上方式就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值