ubuntu下安装nginx及基本指令

来源:互联网 发布:js小球碰撞 编辑:程序博客网 时间:2024/05/08 00:55

1.安装步骤

  1. step1: 下载ninx

    $ cd ~/download/$ wget http://nginx.org/download/nginx-1.8.1.tar.gz

    不同版本的下载地址可从http://nginx.org/en/download.html获取。

  2. step2: 解压并安装

    $ tar -zxvf nginx-1.8.1.tar.gz $ cd nginx-1.8.1/$ ./configure$ make$ make install
  3. 查看是否安装成功

    查看/usr/local/目录下是否有nginx目录,有则安装成功。

2.文件说明

/usr/local/nginx/目录下的文件说明:

conf/  存放配置文件html/  存放一些网页文件logs/  存放一些日志sbin/  一些可执行文件

3. 安装时常见的一些问题

./configure的时候会报如下错误:

错误1:

error: the HTTP rewrite module requires the PCRE library.

解决办法:

$ apt-get -y install libpcre3 libpcre3-dev #安装库,之后重新./configure

错误2:

error: the HTTP gzip module requires the zlib library

解决办法:

$ apt-get -y install zlib1g zlib1g.dev #安装库,之后重新./configure

参考: http://www.jikexueyuan.com/course/1470_2.html?ss=1

4. 基本指令

配置nginx

$ vim /usr/local/nginx/conf/nginx.conf 

检查nginx配置有无错误

$ /usr/local/nginx/sbin/nginx -t

启动nginx

$ /usr/local/nginx/sbin/nginx

关闭nginx

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

重启nginx

$ /usr/local/nginx/sbin/nginx -s reload
0 0
原创粉丝点击