• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

【Linux运维架构】Nginx基础之部署及搭建nginx服务

Linux架构 lixian 4年前 (2020-02-20) 1038次浏览 3个评论 扫描二维码
文章目录[隐藏]

源码安装NGINX

1)下载安装包

[root@web01 ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz

2)解压安装包

[root@web01 ~]# tar xf nginx-1.16.1.tar.gz

3)创建用户

[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666

4)安装依赖包

[root@web01 ~]# yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake httpd-tools openssl-devel

5)编译安装

[root@web01 ~]# cd nginx-1.16.1
[root@web01 nginx-1.16.1]# ./configure --prefix=/usr/local/nginx-1.16.1 --user=www --group=www --with-http_addition_module --with-http_auth_request_module 
[root@web01 nginx-1.16.1]# make && make install
[root@web01 nginx-1.16.1]# ln -s /usr/local/nginx-1.16.1 /usr/local/nginx

6)启动

第一种:使用/usr/local/nginx/sbin/nginx启动
第二种:使用systemctl管理启动

[root@web01 local]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

nginx版本升级

#升级版本
[root@web01 ~]# wget http://nginx.org/download/nginx-1.17.8.tar.gz
[root@web01 ~]# tar xf nginx-1.17.8.tar.gz 
[root@web01 ~]# cd nginx-1.17.8/
[root@web01 nginx-1.17.8]# ./configure --prefix=/usr/local/nginx-1.17.8 --user=www --group=www --with-http_addition_module --with-http_auth_request_module
[root@web01 nginx-1.17.8]# make && make install
[root@web01 nginx-1.17.8]# rm -rf /usr/local/nginx && ln -s /usr/local/nginx-1.17.8 /usr/local/nginx

nginx添加模块

#添加模块
[root@web01 ~]# cd nginx-1.16.1/
[root@web01 nginx-1.16.1]# ./configure --prefix=/usr/local/nginx-new-1.16.1 --user=www --group=www --with-http_addition_module --with-http_auth_request_module --with-http_mp4_module
[root@web01 nginx-1.16.1]# make && make install
[root@web01 nginx-1.16.1]# rm -rf /usr/local/nginx && ln -s /usr/local/nginx-new-1.16.1 /usr/local/nginx

【Linux运维架构】Nginx基础之部署及搭建nginx服务


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:【Linux运维架构】Nginx基础之部署及搭建nginx服务
喜欢 (1)

您必须 登录 才能发表评论!

(3)个小伙伴在吐槽
  1. I don't think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
  2. 讲的不错
    匿名2020-03-02 15:37
  3. Great content! Super high-quality! Keep it up! :)