源码安装Tengine

1、下载包

wget -c http://tengine.taobao.org/download/tengine-2.3.0.tar.gz

tar xf tengine-2.3.0.tar.gz -C /usr/local/src/
cd /usr/local/src/tengine-2.3.0/

2、编译安装

yum install gcc c++
yum install -y openssl-devel
yum install pcre-devel
./configure \
--prefix=/usr/share/nginx \
--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=/run/nginx.pid \
--lock-path=/run/lock/subsys/nginx \
--user=nginx --group=nginx \
--with-debug --with-file-aio \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_degradation_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-pcre --with-pcre-jit 
 
make

make install

3、写服务脚本

vim /usr/lib/systemd/system/nginx.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has 
the wrong
# SELinux context. This might happen when running `nginx -t` from th
e cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.targe

useradd -r -c "Nginx web server" -M -s /sbin/nologin nginx

4、测试脚本

systemctl daemon-reload
systemctl start nginx
systemctl status nginx

systemctl stop nginx
systemctl status nginx

 重新启动,在浏览器

基于用户访问控制

cd /etc/nginx/conf.d/
vim auth_user.conf
server{
        location / {
        root html;
        index index.html index.htm;
        auth_basic "Restricted";
        auth_basic_user_file /data/web2/webpass;
}
}


yum install -y http-tools


touch  /data/web2/webpass/
htpasswd -c /data/web2/webpass tom
New password: 
Re-type new password: 
Adding password for user tom
[root@localhost conf.d]# systemctl restart nginx

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值