zoukankan      html  css  js  c++  java
  • 在CentOS7上源码安装OpenResty

    您必须将这些库
    perl 5.6.1+
    libreadline
    libpcre
    libssl
    安装在您的电脑之中。

    对于 Linux来说, 您需要确认使用 ldconfig 命令,让其在您的系统环境路径中能找到它们。

    CentOS 7 安装OpenResty所需依赖:

    [root@snails ~]# yum -y install readline-devel pcre-devel openssl-devel gcc

    下载:

    [root@snails ~]# wget https://openresty.org/download/openresty-VERSION.tar.gz

    [root@snails ~]# tar xzvf ngx_openresty-VERSION.tar.gz

    编译安装:

    然后在进入 ngx_openresty-VERSION/
    目录, 然后输入以下命令配置:
    ./configure --prefix=/root/openresty

    默认, --prefix=/usr/local/openresty
    程序会被安装到/usr/local/openresty目录。

    ./configure
    --with-http_ssl_module
    --with-zlib=/root/zlib-1.2.8    #源码路径
    --with-http_gzip_static_module
    --with-pcre=/root/pcre-8.39
    --with-pcre-jit
    --with-http_flv_module
    --with-http_sub_module
    --with-http_stub_status_module
    --with-openssl=/root/openssl-1.0.2j
    --with-http_gunzip_module

    gmake

    gmake install

    make -j 4 && make install

    试着使用 ./configure --help 查看更多的选项。

    设置环境变量及文件软链接:

    [root@snails ~]# ln -s /usr/local/openresty/nginx /usr/local/nginx
    [root@snails ~]# vi /etc/profile
      export ORPATH=/usr/local/openresty
      export PATH=$PATH:$ORPATH/bin:$ORPATH/nginx/sbin
     

    配置用户及组:

    [root@snails nginx]# groupadd -f www
    [root@snails nginx]# useradd -r -s /sbin/nologin -g www www
    [root@snails nginx]# vi conf/nginx.conf user www www;

    验证:

    [root@snails nginx]# nginx

    [root@snails nginx]# curl -I localhost

    HTTP/1.1 200 OK

    Nginx开机自动启动脚本:

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

    [root@snails nginx]# cat >> /usr/lib/systemd/system/nginx.service  << EOF
    [Unit]
    Description=nginx - high performance web server
    Documentation=http://nginx.org/en/docs/
    After=network.target   
     
    [Service]
    Type=forking
    PIDFile=/usr/local/nginx/log/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true   
     
    [Install]
    WantedBy=multi-user.target
     
    EOF
     
    配置开机服务项:
    [root@snails src]# systemctl status nginx
     
    [root@snails src]# systemctl enable nginx
     
    [root@snails src]# systemctl start nginx
     
    [root@snails src]# systemctl reload nginx
  • 相关阅读:
    mysql启动错误
    maven环境变量配置
    记一次服务器Tomcat优化经历
    自动定时备份删除脚本
    Tomcat网页加载速度过慢的解决方法
    tomcat运行war包报错,找不到context-root文件
    maven下配置pom.xml
    [LeetCode]题解(python):116-Populating Next Right Pointers in Each Node
    [LeetCode]题解(python):115-Distinct Subsequences
    [LeetCode]题解(python):114-Flatten Binary Tree to Linked List
  • 原文地址:https://www.cnblogs.com/feixiablog/p/8410725.html
Copyright © 2011-2022 走看看