linux配置nginx

  1. 下载
  2. 安装
  3. 配置

1.下载

    [[email protected] src]# wget http://nginx.org/download/nginx-1.10.2.tar.gz
    省略安装内容...
    [[email protected] src]# wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
    省略安装内容...
    [[email protected] src]# wget http://zlib.net/zlib-1.2.11.tar.gz
    省略安装内容...
    [[email protected] src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

安装c++编译环境,如已安装可略过

    [[email protected] src]# yum install gcc-c++
    //省略安装内容...
    //期间会有确认提示输入y回车
    Is this ok [y/N]:y
    //省略安装内容...

2.安装

安装openssl

  [[email protected] src]# tar zxvf openssl-fips-2.0.10.tar.gz
  省略安装内容...
  [[email protected] src]# cd openssl-fips-2.0.10
  [[email protected] openssl-fips-2.0.10]# ./config && make && make install
  省略安装内容...

安装zlib

  [[email protected] src]# tar zxvf zlib-1.2.11.tar.gz
  省略安装内容...
  [[email protected] src]# cd zlib-1.2.11
  [[email protected] zlib-1.2.11]# ./configure && make && make install
  省略安装内容...

安装pcre

  [[email protected] src]# tar zxvf pcre-8.40.tar.gz
  省略安装内容...
  [[email protected] src]# cd pcre-8.40
  [[email protected] pcre-8.40]# ./configure && make && make install
  省略安装内容...

安装nginx

 [[email protected] src]# tar zxvf nginx-1.10.2.tar.gz
 省略安装内容...
 [[email protected] src]# cd nginx-1.10.2
 [[email protected] nginx-1.10.2]# ./configure && make && make install
 省略安装内容...

3.配置

//查找nginx安装位置
whereis nginx
注释:一般位置为/usr/local/
//启动nginx
//1.进入/usr/local/nginx/sbin/
cd /usr/local/nginx/sbin/
//2.{./}为启动
./nginx

4.注意

启动报错了,error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,

按照下面方式解决

1.用whereis libpcre.so.1命令找到libpcre.so.1在哪里
2.用ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了
3.用sbin/nginx启动Nginx
4.用ps -aux | grep nginx查看状态

[[email protected] nginx]# whereis libpcre.so.1
[[email protected] nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[[email protected] nginx]# sbin/nginx
[[email protected] nginx]# ps -aux | grep nginx
配置web 站点

linux配置nginx

负载均衡

linux配置nginx