美文网首页服务器
linux服务器安装nginx

linux服务器安装nginx

作者: 风不会停7 | 来源:发表于2018-09-04 13:53 被阅读74次

    1:检查80端口是否被占用。
    2:安装nginx

    给nginx配置安装目录,就是nginx存放的目录

    我一般安装软件都是安装在/usr/local下面的

    mkdir /usr/local/nginx

    进入nginx目录

    cd /usr/local/nginx

    使用wget命令下载nginx资源包

    wget http://nginx.org/download/nginx-1.12.2.tar.gz

    解压

    tar -zxvf nginx-1.5.9.tar.gz

    执行 ./configure命令

    cd nginx-1.5.9
    ./configure

    执行./configure可能会存在一下错误,如果出现请执行一下命令

    错误1

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

    解决方法

    安装pcre-devel解决问题

    yum -y install pcre-devel

    错误2

    ./configure: error: the HTTP cache module requires md5 functions
    from OpenSSL library. You can either disable the module by using
    --without-http-cache option, or install the OpenSSL library into the system,
    or build the OpenSSL library statically from the source with nginx by using
    --with-http_ssl_module --with-openssl=<path> options.

    解决办法:

    yum -y install openssl openssl-devel

    3.编译

    make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)

    cd /usr/local/nginx/nginx-1.5.9
    make

    4.make install安装

    make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)

    make install

    5.启动nginx服务

    cd /usr/local/nginx/sbin
    ./nginx

    6.看nginx服务是否启动

    ps -ef|grep nginx

    我们看到服务已经起来了,输入ip即可访问我们nginx目录下面的html文件夹下面的index.html文件

    =========================

    nginx -s reload :修改配置后重新加载生效

    nginx -s reopen :重新打开日志文件

    关闭nginx:
    nginx -s stop :快速停止nginx
    quit :完整有序的停止nginx

    其他的停止nginx 方式:

    ps -ef | grep nginx

    报错
    ./configure: error: the HTTP gzip module requires the zlib library.

    执行这句话

    yum install -y zlib-devel

    相关文章

      网友评论

        本文标题:linux服务器安装nginx

        本文链接:https://www.haomeiwen.com/subject/hxpgwftx.html