Centos7 源码安装nginx

1、官方自行下载nginx源码

2、切换到解压后的nginx目录中执行:

      ./configure –prefix=/opt/demo/nginx –add-module=/home/fastdfs-nginx-module/src  –with-http_stub_status_module –with-http_ssl_module

      参数说明:

        –prefix 用于指定nginx编译后的安装目录

        –add-module 为添加的第三方模块,此次添加了fdfs的nginx模块

        –with…_module 表示启用的nginx模块,如此处启用了http_ssl_module模块

根据需要来自行选择,如下是我的执行脚本

./configure –prefix=/home/songxiaohu/nginx-1.16.0/nginx   –with-http_stub_status_module –with-http_ssl_module

3、

 可能出现的错误:

                             出现./configure: error: C compiler cc is not found

                                   解决办法:yum -y install gcc gcc-c++ autoconf automake make

        出现:./configure:  error: the HTTP rewrite module requires the PCRE library.

          解决方法:yum -y install pcre-devel

        出现:SSL modules require the OpenSSL library

          解决方法:yum install openssl-devel 

4、执行

         ./configure –prefix=/home/songxiaohu/nginx-1.16.0/nginx   –with-http_stub_status_module –with-http_ssl_module

5、编译

       执行make 进行编译,如果编译成功的话会在第一步中objs中出现一个nginx文件

6、安装

执行make install 进行安装,安装后–prefix 中指定的安装目录下(此处为:/home/songxiaohu/nginx-1.16.0/nginx)存在相关的文件

7、启动nginx

nginx的一些常用管理命令

                     启动:nginx –c ../conf/nginx.conf

      重启:nginx -s reload

      停止:nginx -s stop或者是通过kill nginx进程号

      查看版本:nginx –V

 

0

评论0

请先
显示验证码
没有账号?注册  忘记密码?