12 - CentOS 7 上部署Nginx服务

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!!!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

红蓝安全

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值