Linux系统下Nginx服务器部署

Nginx安装步骤:html

1、相关组件nginx

        (1)    Nginx自己c++

下载地址:http://nginx.org/en/download.html;提供的安装包是Nginx-1.9.7版本。
正则表达式

(2)   Rewrite模块的正则表达式依赖库pcre服务器

下载地址:http://www.pcre.org;提供的安装包是pcre-8.38版本。ui

 

2、安装步骤spa

        (1)    安装pcre日志

tar -zxvf pcre-8.38.tar.gzhtm

cd pcre-8.38ip

./configure

make

make install

默认安装到/usr/local/lib下便可;安装完成后能够#ls -l /usr/local/lib/libpcre.so

         (2)    安装nginx

                    tar –zxvf nginx-1.9.7.tar.gz

                    cd nginx-1.9.7

                    ./configure

                    make

                    make install

 

、nginx配置

    配置文件默认在/usr/local/nginx目录下,主要的配置文件为conf目录下的nginx.conf。

    启动程序文件在/usr/sbin/nginx中。

    日志在/var/log/nginx中,分别是access.log和error.log。

            默认的虚拟主机的目录设置在了/usr/share/nginx/html中。

    常见配置以下:

    (1)  侦听80端口 (nginx默认监听80端口)

                       listen 80;

    (2)  服务器名称

                       Server_name localhost;

    (3)  默认主页目录在nginx安装目录的html子目录。

                       root html;

               index index.html index.html;

 

4、管理nginx

            (1)    启动

                        /usr/local/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)

            (2)    中止

                       /usr/local/nginx/sbin/nginx -s stop

             (3)    重启

                       /usr/local/nginx/sbin/nginx -s reload

             (4)    查看状态

                        netstat -autlp| grep nginx

             (5)  检查部署正确性

                        访问http://localhost/,查看是否正常启动。    

 

5、常见问题

(1)  缺乏pcre库:./configure: error: the HTTP rewrite module requires the PCRE library.

           解决方法:安装pcre。

(2)  缺乏openssl:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.

   解决方法:安装openssl-devel。

(3)  缺乏gcc-c++和libtool:The program 'libtool' is currently not installed. You can install it by typing:sudo apt-get install libtool

                  解决方法:安装libtool和gcc-c++。

        (4)    缺乏zlib:./configure: error: the HTTP gzip module requires the zlib library.

                   解决方法:安装zlib。

相关文章
相关标签/搜索