下载nginx 并创建用户和组 安装所需要的组件
[root@localhost ~]# wget http://nginx.org/download/nginx-1.6.2.tar.gz 稳定版
[root@localhost ~]# yum install pcre-devel -y 依赖perl扩展的正则表达式
[root@localhost ~]# groupadd -r -g 110 nginx 添加以个nginx组为系统组
[root@localhost ~]# useradd -r -u 110 -g 110 nginx 添加以个用户为系统用户 专门管理nginx
[root@localhost ~]# yum -y install cmake gcc gcc-c++ autoconf automake zlib* libxml* \
ncurses ncurses-devel libtool-ltdl-devel* make bison bison-devel libaio
[root@localhost ~]# tar xf nginx-1.6.2.tar.gz
[root@localhost ~]# cd nginx-1.6.2
[root@localhost nginx-1.6.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.6.2]#yum install openssl-devel gd-devel gd --库是图片过滤处理模块
开始编译:
第一种 : ./configure --prefix=/usr/local/nginx
第二种 :
.
/configure
\
--prefix=
/usr
\
--sbin-path=
/usr/sbin/nginx
\
--conf-path=
/etc/nginx/nginx
.conf \
--error-log-path=
/var/log/nginx/error
.log \
--http-log-path=
/var/log/nginx/access
.log \
--pid-path=
/var/run/nginx/nginx
.pid \
--lock-path=
/var/lock/nginx
.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=
/var/tmp/nginx/client/
\
--http-proxy-temp-path=
/var/tmp/nginx/proxy/
\
--http-fastcgi-temp-path=
/var/tmp/nginx/fcgi/
\
--http-uwsgi-temp-path=
/var/tmp/nginx/uwsgi
\
--http-scgi-temp-path=
/var/tmp/nginx/scgi
\
--with-pcre \
--with-
file
-aio \
--with-http_image_filter_module
make
&&
make
install
[root@localhost nginx-1.6.2]#nginx
检查是否启动成功
[root@localhost ~]# ps -ef |grep nginx
root 1086 1 0 18:12 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 1088 1086 0 18:12 ? 00:00:00 nginx: worker process
root 1142 1124 0 18:21 pts/0 00:00:00 grep nginx
[root@localhost ~]# service iptables stop #关闭防火墙
[root@localhost ~]# service iptables status #查看防火墙状态
iptables: Firewall is not running.
[root@localhost ~]#
最后测试是否成功 IE输入 http://ip
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
网站的目录
.
/configure
\
--prefix=
/usr
\----------------网站的目录
--sbin-path=
/usr/sbin/nginx
\
--conf-path=
/etc/nginx/nginx
.conf \
--error-log-path=
/var/log/nginx/error
.log \
--http-log-path=
/var/log/nginx/access
.log \
--pid-path=
/var/run/nginx/nginx
.pid \
--lock-path=
/var/lock/nginx
.lock \
--user=nginx \
根据安装显示 我们的安装目录在/usr
下面我看看。
[
root@localhost ~]# ls /usr
bin etc games html include lib lib64 libexec local sbin share src tmp
其中
html 默认站点的主目录
sbin 存放nginx的程序