q528 发表于 2018-11-11 13:17:46

nginx之nginx部署

  1.安装以下库:
  pcre、pcre-devel、zlib、zlib-devel、openssl、openssl-devel、gcc
  2.添加nginx使用的用户和组
  groupadd nginx
  useradd -g nginx nginx
  3.选定源码目录
  选定目录 /usr/local/
  cd/usr/local/
  4.安装PCRE库、zlib库、openssl
  4.1 cd /usr/local/
  wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
  tar -zxvf pcre-8.36.tar.gz
  cd pcre-8.36
  ./configure
  make && make install
  4.2.安装zlib库
  cd /usr/local/
  wget http://zlib.net/zlib-1.2.8.tar.gz
  tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
  ./configure
  make && make install
  4.3安装ssl
  cd /usr/local/
  wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
  tar -zxvf openssl-1.0.1c.tar.gz
  ./config
  make && make install
  5.安装nginx
  Nginx 一般有稳定版和开发版两个版本,可根据实际需求进行选择。
  cd /usr/local/
  wget http://nginx.org/download/nginx-1.2.8.tar.gz
  tar -zxvf nginx-1.2.8.tar.gz
  cd nginx-1.2.8
  ./configure --prefix=/opt/nginx
  make && make install
  6.启动nginx
  6.1 确保系统的 80 端口没被其他程序占用
  6.2 启动
  /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx/conf
  参数-c指定了配置文件的路径,如果不加-c,nginx会默认加载其安装目录中conf子目录中的nginx.conf文件。
  6.3检查是否启动成功
  netstat -ano|grep 80
  6.4检测
  打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。
  -------------------------------------------------------------------------------------------------------
  1.configure: error: You need a C++ compiler for C++ support
  解决方案:
  yum install -y gcc gcc-c++
  2.error while loading shared libraries: libpcre.so.1
  解决方案:
  cd /lib
  ls *pcre*
  find / -type f -name *libpcre.so.*
  添加软链接:
  ln -s /lib/libpcre.so.0.0.1   /lib/libpcre.so.1
  注: 在有的操作系统上面,安装pcre后,安装的位置为/usr/local/lib/*pcre*
  在redhat 64位机器上可能会有这样的情况.在redhat 64位机器上, nginx可能读取的pcre文件为/lib64/libpcre.so.1文件.
  所以改用下面的软连接即可:
  ln -s /usr/local/lib/libpcre.so.1 /lib64/

页: [1]
查看完整版本: nginx之nginx部署