标签:
nginx安装
相应下载页面:http://nginx.org/en/download.html
我这里使用nginx的yum在线安装
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装源库
chmod +x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装nginx
安装完成后
默认nginx配置文件: /etc/nginx/nginx.conf 【nginx主要的配置文件】
默认nginx的ssl配置文件: /etc/nginx/conf.d/ssl.conf 【配置SSL证书的,也可以并入到nginx.conf文件里】
默认nginx的虚拟主机配置文件: /etc/nginx/conf.d/virtual.conf 【如同Apache的虚拟主机配置,也可以并入到nginx.conf文件里】
默认的web_root文件夹路径: /usr/share/nginx/html 【web目录夹,放置Magento主程序】
配置iptables
iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
启动nginx
打开IP地址 可见“Welcome to nginx!”表示安装成功。
=============================================================
以下自己加的,非root启动nginx
先关闭默认启动的nginx
chkconfig --level 2345 nginx off
复制/etc/nginx/nginx.conf到别的地方
cp /etc/nginx/nginx.conf /home/user/etc/nginx/nginx.conf
启动
/usr/sbin/nginx -c /home/user/etc/nginx/nginx.conf
关闭
=======================================================
conf改成下如下
user nginx;
worker_processes 1;
error_log /home/user/log/nginx/error.log warn;
pid /home/user/log/nginx/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 /home/user/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /home/user/etc/nginx/conf.d/*.conf;
}
/home/user/etc/nginx/conf.d/default.conf;里面
server {
listen 8080;
注意:端口是1024以下,一定要root权限启动才可以绑定(这是Linux系统机制问题),否则非root启动会提示无法绑定端口
==========================================
非root用户启动,使用80端口:
发现:
-rwxr-xr-x. 1 root root 834352 Dec 12 00:57 nginx
按照网上的说法,给nginx添加s的权限:
再查看:
-rwsr-xr-x. 1 root root 834352 Dec 12 00:57 nginx
再次以非root启动:
root 1736 1 0 23:51 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /home/user/etc/nginx/nginx.conf
nginx 1737 1736 0 23:51 ? 00:00:00 nginx: worker process
主线程还是root。子线程不一定是root了
另外:
如果nginx设置目录在/home/user下面。
/home/user一定要给o+x的权限,否则会报403 forbidden
CentOS6.x安装配置nginx
标签:
原文地址:http://www.cnblogs.com/ihibin/p/5146429.html