赞
踩
# 查看zlib是否安装 dpkg -l | grep zlib # 解决依赖包openssl安装 sudo apt-get install openssl libssl-dev # 解决依赖包pcre安装 sudo apt-get install libpcre3 libpcre3-dev # 解决依赖包zlib安装 sudo apt-get install zlib1g-de #如果 zlib1-de安装不成功 $ sudo apt-get install zlib1g $ sudo apt-get install zlib1g.dev 直接输入上述命令复后还是不能安装。这就要制求我们先装ruby. 在ubuntu里,百zlib叫zlib1g,相应的zlib-devel叫zlib1g.dev。默认的安装源里没有度zlib1g.dev。要在packages.ubuntu.com上找。 $sudo apt-get install ruby 然后再装zlib1g-dev就可以了 $sudo apt-get install zlib1g-dev
# 下载nginx
wget http://nginx.org/download/nginx-1.13.1.tar.gz
# 解压nginx
tar -xzvf nginx-1.13.1.tar.gz
# 切换到 nginx目录
cd /usr/local/nginx-1.13.1
# 配置nginx
cd /usr/local/nginx
sudo ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
# 编译nginx
sudo make
# 安装nginx
sudo make install
上面可能出现问题
#没有安装 gcc
#一定要记得先update,不然找不到gcc
sudo apt-get update
#然后输入下述命令即可
sudo apt-get install gcc
#没有安装 make
sudo apt-get install make
cd /usr/local/nginx/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
# 方法1
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 方法2
cd /usr/local/nginx/sbin
./nginx
通过本地访问一下网站 127.0.0.1界面为
可能遇到的问题
1、软件源无法获取:
打开 sudo vim /etc/apt/source.list
东北大学
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirror.neu.edu.cn/ubuntu/ xenial universe deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse
清华大学
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse
sudo apt-get update更新一下就搞定
2、nginx: [emerg] getpwnam(“www”) failed错误
#/usr/sbin/groupadd -f www
#/usr/sbin/useradd -g www www
会出现 nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 错误
原因:Linux只有root用户可以使用1024一下的端口
解决办法:1.已root权限启动
2.将 /usr/local/nginx/conf/nginx.conf 文件中的80端口改为1024以上
server {
# listen 80
listen 8080
……
}
nginx: [alert] could not open error log file: open() “/usr/local/nginx/logs/error.log” failed (2: No such file or directory)
解决方法:
sudo chmod a+rwx -R logs
sudo chmod a+rwx -R /usr/local/nginx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。