当前位置 主页 > 服务器问题 > nginx问题汇总 >

    Linux 安装nginx服务器详细介绍

    栏目:nginx问题汇总 时间:2018-10-31 16:44

    这篇文章主要介绍了Linux 安装nginx服务器详细介绍的相关资料,需要的朋友可以参考下

    nginx依赖一些软件库,在安装之前请确保系统安装了gcc、ssl、pcre和gzip等软件,可以用rpm -q 命令查看软件是否安装。

    [root@RedHat1 ~]# rpm -q gcc
    gcc-4.1.2-44.el5

    依赖库信息如下:

    (1). gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )
    (2). rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/)
    (3). ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/)

    如安装pcre,下载pcre至目的目录下,这里选择的版本是pcre-8.38,下载完后执行以下操作

    tar -zxvf pcre-8.38.tar.gzcd pcre-8.38./configuremakemake install

    安装nginx,执行如下命令

           在默认情况下,经过编译安装的Nginx已经包含了大部分可用模块,可以通过“./configure  --help”选项设置各个模块的使用情况,例如对不需要的http_ssi模块,可通过“--without-http_ssi_module”参数关闭此模块;如果需要“http_perl”模块,则可以通过“--with-http_perl_module”参数安装此模块。执行以下操作进行安装。

    tar -zxvf nginx-1.11.1.tar.gzcd nginx-1.11.1./configure --with-pcre=../pcre-8.38 --prefix=/usr/local/nginxmakemake install

    检测是否安装成功,执行命令如下

    [root@RedHat1 sbin]# cd /usr/local/nginx/sbin
    [root@RedHat1 sbin]# ./nginx -t

    出现如下信息证明安装成功

    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    启动nginx

    [root@RedHat1 sbin]# ./nginx

    查看端口

    [root@RedHat1 sbin]# netstat -ntlp

    结果如下:

    Proto Recv-Q Send-Q Local Address     Foreign Address   State    PID/Program name
    tcp        0      0 127.0.0.1:2208    0.0.0.0:*         LISTEN   2993/hpiod
    tcp        0      0 0.0.0.0:834       0.0.0.0:*         LISTEN   2772/rpc.statd
    tcp        0      0 0.0.0.0:11111     0.0.0.0:*         LISTEN   3391/ricci
    tcp        0      0 0.0.0.0:111       0.0.0.0:*         LISTEN   2733/portmap
    tcp        0      0 0.0.0.0:80        0.0.0.0:*         LISTEN   3852/nginx