11

解决Ubuntu配置nginx出现的问题

 3 years ago
source link: https://segmentfault.com/a/1190000038247421
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ubuntu18.04配置nginx出现的各种错误

  1. 缺少 pcre库

    编译nginx

    A3a2eiZ.png!mobile

出现错误

q2mqeeu.png!mobile

安装pcre库,出现错误

niuEzqQ.png!mobile

手动编译安装pcre库

(1)下载并解压pcre库

wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -xvf pcre-8.43.tar.gz

I7bQRn7.png!mobile

(2)编译安装pcre库

cd pcre-8.43
sudo ./configure
sudo make
sudo make install

重新编译nginx

#在nginx-1.12.2目录下
sudo ./configure --with-stream

命令执行成功

nUNF3m.png!mobile

  1. 出现"struct crypt_data"没有名为"current_salt"成员的错误

    执行make命令

    sudo make && make install

    出现"struct crypt_data"没有名为"current_salt"成员的错误

    fYru6zF.png!mobile

解决方案:进入相应路径,将源码的第36行注释

sudo vi src/os/unix/ngx_user.c

6rI3iqr.png!mobile

重新执行sudo make && make install命令

  1. 出现-Werror=cast-function-type错误

IjAraay.png!mobile

解决方案

#进入nginx-1.12.2目录下的objs目录
cd objs
#修改Makefile文件
sudo vi Makefile

eeAn6jJ.png!mobile

重新回到nginx-1.12.2目录下执行sudo make && make install命令

  1. make命令出现权限不够错误

    7BNR73Y.png!mobile

进入root模式执行命令

sudo su #进入root模式
make && make install
  1. nginx启动出现无法连接 pcre库 错误

    MVVFfiI.png!mobile

查看依赖库

yIBjUbI.png!mobile

到/usr/local/lib目录下查看

m6rIJzj.png!mobile

设置软连接

#回到nginx下的sbin目录
cd /usr/local/nginx/sbin
#设置软连接
ln -s /usr/local/lib/libpcre.so.1.2.11 libpcre.so.1
#设置LD_LIBRARY_PATH(注:这种方法,每次开启nginx都需要重新设置LD_LIBRARY_PATH)
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

重新启动nginx

./nginx
# 查看服务是否正常启动
netstat -tanp

MrMB3qz.png!mobile


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK