Nginx负载均衡-linux服务器

    Nginx 是一款轻量级的 Web 服务器是由 C 语言开发,所以在linux中先要安装环境。

安装环境

#####安装 Nginx 的编译环境 gcc
yum install gcc-c++

#####安装 pcre pcre-devel,nginx 的 http 模块使用 pcre 解析正则表达式,所以安装 perl 兼容的正则#####表达式库
yum install -y pcre pcre-devel

#####安装 zlib,nginx 使用 zlib 对 http 包的内容进行 gzip
yum install -y zlib zlib-devel

#####安装 Open SSL,nginx 不仅支持 http 协议,还支持 https(即在 ssl 协议上传输 http),如果使用#####了 https ,需要安装 OpenSSL 库
yum install -y openssl openssl-devel

安装nginx

##1.解压
tar -zxvf nginx-1.15.2.tar.gz

##2.使用默认配置,nginx 被安装到 /usr/local/nginx 下。
cd nginx-1.15.2
./configure

##3.编译
make

##4.安装
make install

##5.配置环境变量
vim /etc/profile
键入下面内容
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin

##6.生效配置文件
source /etc/profile

nginx的常用操作

##1.nginx启动
nginx

##2.nginx查看进程
ps -ef | grep nginx

##3.nginx停止
nginx -s stop 

##4.nginx重启
nginx -s reload

##5.测试nginx配置文件是否正常
nginx -t

##6.nginx开机自启
打开vim /etc/rc.local
在 rc.local 文件中加入 /usr/local/nginx/sbin/nginx

##7.nginx指定配置文件启动
nginx -c /usr/local/nginx/conf/nginx.conf

猜你喜欢

转载自blog.csdn.net/zzwforbid_404/article/details/83054433