centos平台编译环境使用如下指令
安装make:
安装g++:
一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
1.选定源码目录
4.安装ssl(某些vps默认没装ssl)
7、启动成功





11、 Nginx负载均衡配置
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++
下面正式开始
一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
1.选定源码目录
可以是任何目录,本文选定的是/usr/local/src
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
tar -zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure
make
make install
3.安装zlib库
使用下面命令下载编译和安装 zlib包:
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
4.安装ssl(某些vps默认没装ssl)
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz
tar -zxvf openssl-1.1.0g.tar.gz
5.安装nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure && make && make install
6.启动nginx
先找一下nginx安装到什么位置上了
进入nginx目录并启动
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查看状态
[root@localhost nginx]# whereis libpcre.so.1
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx
[root@localhost nginx]# ps -aux | grep nginx
7、启动成功
进入Linux系统的图形界面,打开浏览器输入localhost会看到下图,说明nginx启动成功
或者打开浏览器,输入虚拟机ip,
8、
nginx的基本操作
启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
停止/重启
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop(quit、reload)
命令帮助
[root@localhost ~]# /usr/local/nginx/sbin/nginx -h
验证配置文件
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
配置文件
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
9、简单配置nginx
10、开启外网访问
11、 Nginx负载均衡配置
12、上面的内容是抄袭过来的,实际操作时遇到的问题:
1》我配置了域名:nginx.test1.com,并且修改了nginx配置文件,两个tomcat,但是,输入ip和端口号可以轮询成功,
输入 server_name 访问为什么总是出现nginx的欢迎页面呢?????
参考:https://www.cnblogs.com/taiyonghai/p/6728707.html
http://www.nginx.cn/install