1、安装Nginx环境
[root@bogon ~]# yum install pcre-devel zlib-devel -y
...
Complete!
[root@bogon ~]#
2、创建用户和组
#创建一个用户UID为249(1-1000是程序用户的范围),不创建家目录,不可以登陆的用户nginx
[root@bogon ~]# useradd -u 249 -M -s /sbin/nologin nginx
[root@bogon ~]# id nginx
uid=249(nginx) gid=1001(nginx) groups=1001(nginx)
[root@bogon ~]# grep "nginx" /etc/passwd
nginx:x:249:1001::/home/nginx:/sbin/nologin
[root@bogon ~]# ls /home
chiyupeng
[root@bogon ~]#
3、解压Nginx安装包
[root@bogon ~]# tar xf /root/Desktop/nginx-1.6.0.tar.gz
[root@bogon ~]# ls
anaconda-ks.cfg Downloads nginx-1.6.0 Templates
Desktop initial-setup-ks.cfg Pictures Videos
Documents Music Public
[root@bogon ~]# mv nginx-1.6.0/ /root/Desktop/
[root@bogon ~]# cd /root/Desktop/
[root@bogon Desktop]# ls
nginx-1.6.0 nginx-1.6.0.tar.gz snat.sh
4、编译安装Nginx
预编译配置
[root@bogon Desktop]# cd nginx-1.6.0/
[root@bogon nginx-1.6.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@bogon nginx-1.6.0]# ./configure --prefix=/usr/local/nginx_1.6.0 --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-openssl=/usr/bin/openssl
...
Configuration summary
+ using system PCRE library
+ using OpenSSL library: /usr/bin/openssl
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
nginx path prefix: "/usr/local/nginx_1.6.0"
nginx binary file: "/usr/local/nginx_1.6.0/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx_1.6.0/conf"
nginx configuration file: "/usr/local/nginx_1.6.0/conf/nginx.conf"
nginx pid file: "/usr/local/nginx_1.6.0/logs/nginx.pid"
nginx error log file: "/usr/local/nginx_1.6.0/logs/error.log"
nginx http access log file: "/usr/local/nginx_1.6.0/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@bogon nginx-1.6.0]#
规范模板
cd nginx-1.6.0/
./configure --prefix=/usr/local/nginx_1.6.0 --user=nginx --group=nginx
./configure --prefix=/usr/local/nginx_1.6.0 --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-openssl=/usr/bin/openssl
--with-file-aio 启用文件修改
--with-http_stub_status_module 启用状态统计
--with-http_gzip_static_module 启用gzip 静态压缩
--with-http_flv_module 启用flv 模块
--with-http_ssl_module 启用SSL 模块
5、编译安装
#是双与,所以是当第一个成功了,才会执行第二个,如果不成功,就不会执行第二个
make && make install
6、Nginx 服务管理
在前面第1.4步,预编译,已经指定了路径
开启Nginx服务
[root@bogon ~]# cd /usr/local/nginx_1.6.0/
[root@bogon nginx_1.6.0]# ls
conf html logs sbin
[root@bogon nginx_1.6.0]# cd sbin/
[root@bogon sbin]# ls
nginx
[root@bogon sbin]# ./nginx
查看nginx的命令,不能直接通过命令进行查看,需要使这个当前路径执行
7、使用浏览器访问Nginx
http://192.168.2.254
Success!!!
版权声明:本文为weixin_43586169原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。