当前位置: 代码迷 >> 综合 >> nginx1.8安装及异常处理
  详细解决方案

nginx1.8安装及异常处理

热度:14   发布时间:2023-12-19 01:27:26.0

nginx安装

使用SecureCRT的SFTP方式上传nginx-1.8.0.tar.gz包到Linux虚拟机上时,
使用ll查看目录列表时出现乱码
解决方法:选择SecureCRT的菜单栏中选项->会话选项->外观->字符编码 UTF-8

安装nginx之前需要保证有gcc环境
验证Linux下是否安装好gcc环境:gcc -v

解压
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0

./configure \
–prefix=/usr/local/nginx \
–pid-path=/var/run/nginx/nginx.pid \
–lock-path=/var/lock/nginx.lock \
–error-log-path=/var/log/nginx/error.log \
–http-log-path=/var/log/nginx/access.log \
–with-http_gzip_static_module \
–http-client-body-temp-path=/var/temp/nginx/client \
–http-proxy-temp-path=/var/temp/nginx/proxy \
–http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
–http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
–http-scgi-temp-path=/var/temp/nginx/scgi

注意:
./configure –help查询详细参数(参考本教程附录部分:nginx编译参数)
上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre= option.

yum -y install pcre-devel
yum -y install openssl openssl-devel

编译安装
make
make install

报错 make: * 没有规则可以创建“default”需要的目标“build”。 停止。

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib= option.

yum install -y zlib

./configure 查看日志 ,日志的末尾有相应的报错信息,如果正确安装,就会显示已经配置好的参数信息。

cd /usr/local/ngnix
如果nginx编译安装成功,就可以看到conf,html,sbin三个目录
这里写图片描述