nginx安装

nginx的官网:http://nginx.org/
 
相应下载页面: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

yum install 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

service nginx start

打开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

 
关闭

killall nginx

 
=======================================================
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端口:

cd /usr/sbin

发现:
-rwxr-xr-x. 1 root root  834352 Dec 12 00:57 nginx
按照网上的说法,给nginx添加s的权限:

chmod u+s nginx

再查看:
-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的更多相关文章

  1. centos6.5安装配置nginx+php+mysql+httpsqs+ttserver+redis

    一.准备 1.nginx, http://nginx.org/download/nginx-1.5.12.tar.gz 2.pcre, ftp://ftp.csx.cam.ac.uk/pub/soft ...

  2. CentOS-6.3安装配置Nginx

    安装说明 系统环境:CentOS-6.3软件:nginx-1.2.6.tar.gz安装方式:源码编译安装 安装位置:/usr/local/nginx 下载地址:http://nginx.org/en/ ...

  3. CentOS6.x安装配置nginx [转]

    博文来源:http://leyewen.blog.163.com/   nginx安装 nginx的官网:http://nginx.org/   相应下载页面:http://nginx.org/en/ ...

  4. CentOS-6.4安装配置Nginx

    在安装nginx前,需要确保系统安装了g++.gcc.openssl-devel.pcre-devel和zlib-devel软件.安装必须软件: [root@admin /]#yum install ...

  5. [转]Centos6.5安装配置keepalived

    参考博文: Centos6.5安装配置keepalived CentOS6.5 keepalived详解及实现Nginx服务的高可用性 CentOS6.5 LVS + KeepAlived搭建步骤 我 ...

  6. [转]CentOS-6.3安装配置cmake

    CentOS-6.3安装配置cmake   zhoulf 2013-02-03 原创 安装说明 安装环境:CentOS-6.3安装方式:源码编译安装 软件:cmake-2.8.10.2.tar.gz下 ...

  7. centos6.4安装配置vpn服务器步骤详解

      centos6.4安装配置vpn服务器步骤详解,从安装VPN到配置VPN服务器.配置VPN服务器的路由转发功能,每一步都很详细   一.VPN服务器环境说明 操作系统:CentOS release ...

  8. CentOS6.5安装配置Samba

    CentOS6.5安装配置Samba 本文的场景是虚拟机运行CentOS6.,本机是Win7,现欲把CentOS上的一个文件夹共享出来,Win的机器可以读写. Samba与window连接需要使用Ne ...

  9. ELK 6安装配置 nginx日志收集 kabana汉化

    #ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...

随机推荐

  1. [转]JAVA设计模式之单例模式

    原文地址:http://blog.csdn.net/jason0539/article/details/23297037 概念: java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主 ...

  2. java-通讯stocket插件mina实例

    mina是对nio的具体实现.是目前比较高效和流行的nio(非阻塞式I/O)框架 mina主要包括: 其中服务端为:NioSocketAcceptor 客户端为:NioSocketConnector ...

  3. mysql-窗口多表连接视图view

    create VIEW view_comment as (' as type FROM wei_comment_comment w) UNION ALL (' as type from review_ ...

  4. Fresco内存机制(Ashmem匿名共享内存)

    Fresco的内存机制 Fresco是Facebook出品的高性能图片加载库,采用了Ashmem匿名共享内存机制, 来解决图片加载中的OOM问题.这里不对Fresco做深入分析,只关注Fresco在A ...

  5. C#-WinForm-Timer控件

    比如在窗体中显示时间: 错误思路一:我在窗体结构函数中写入一个死循环,每隔一秒显示一次当前时间 public Form6() { InitializeComponent(); while (true) ...

  6. 【USACO 2.1】Sorting A Three-Valued Sequence

    /* TASK: sort3 LANG: C++ URL: http://train.usaco.org/usacoprob2?a=RkPIMxsFWzm&S=sort3 SOLVE: n个数 ...

  7. perl 箭头操作符

    箭头操作符有两种用法. 第一种用法是访问引用中的数据元素: #!/usr/bin/perl -w use strict; my @a = (5, 6, 7,9); my $aref = \@a; pr ...

  8. c# 读取嵌入式文件

    using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Reflect ...

  9. 面向对象_python

    面向对象_python 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公用的.类变量定 ...

  10. css-transition和transform实现图片悬浮移动动画

    今天在京东首页上看到一个效果,鼠标悬浮在图片上时,图片发生移动,鼠标移走时再移回,并且有一个过渡效果. 貌似很简单,自己做做试试吧 我首先使用的是jquery在鼠标悬浮到图片上给图片增加一个类,这个类 ...