linux基础-第十八单元_nginx部署
一、基本环境配置
1.1、安装常用软件
yum install wget -y
1.2、Install yum repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
1.3、close firewalld
systemctl disable firewalld
systemctl disable NetworkManager and sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
1.4、安装常用软件
yum install net-tools vim lrzsz screen lsof tcpdump nc mtr nmap -y
yum update -y && reboot
二、安装nginx
官网地址:http://nginx.org/en/download.html
2.1、yum方式安装:
yum install nginx -y
2.2、配置nginx
#配置nginx
[root@nulige ~]# vi /etc/nginx/nginx.conf
#指定配置文件: root /usr/share/nginx/html
#网站存放路径
[root@nulige html]# cd /usr/share/nginx/html
[root@nulige html]# ll
total 24
-rw-r--r-- 1 root root 3650 Mar 6 17:26 404.html
-rw-r--r-- 1 root root 3693 Mar 6 17:26 50x.html
-rw-r--r-- 1 root root 14 Jun 18 16:28 index.html
-rw-r--r-- 1 root root 3700 Mar 6 17:26 index.html.bak
-rw-r--r-- 1 root root 368 Mar 6 17:26 nginx-logo.png
-rw-r--r-- 1 root root 2811 Mar 6 17:26 poweredby.png
#改写主页
[root@nulige html]# echo "welcome nginx" >index.html
[root@nulige html]# cat index.html
welcome nginx
#启动服务
[root@nulige html]# systemctl restart nginx
[root@nulige html]# systemctl status nginx
#访问网站
http://192.168.56.33/
welcome nginx
#配置负载均衡
参考官网:
http://nginx.org/en/docs/http/load_balancing.html
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
} server {
listen 80; location / {
proxy_pass http://myapp1;
}
}
}
#重启服务
systemc reload nginx
3、编译安装nginx
参考峰哥:http://www.cnblogs.com/linhaifeng/articles/6045600.html#_label19
源码安装: yum install gcc-* glibc-* openssl openssl-devel pcre pcre-devel zlib zlib-devel -y
ls
tar xvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
ls
./configure
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --without-http_rewrite_module #--without-http_rewrite_module代表不使用重写功能,即不会引用pcre库,如果安装过程中出现pcre相关问题,可以指定该参数
make
make install
#所有模块
参考:http://nginx.org/en/docs/
最新文章
- JavaScript(四)——DOM操作——Window.document对象
- Web前端开发基础 第四课(CSS小技巧1)
- 生成元(Digit Generator ,ACM/ICPC Seoul 2005 ,UVa 1583)
- Android之jni深入
- MySql拾遗
- 重新开始学习javase_集合_List
- android脚步---跟随手指动的小球
- slf4j入门
- Spark大型电商项目实战-及其改良(2) RDD优化效果不稳定的真正原因
- 【转载】SQL Server中的Merge关键字
- 使用Laya引擎开发微信小游戏(下)
- CSS魔法(五)项目实战
- zabbix安装(Ubuntu)
- C#——性能计数器
- Linux-TCP 出现 RST 的几种情况
- [py]python自省工具
- nginx 配置记录 上传文件大小 size client
- E - Water Distribution
- GCD汇总
- stm32基本定时器timer6的原理与使用
热门文章
- VC6.0显示行号的插件
- 【mysql优化】语句优化
- 【git】git提交忽略不必要的文件或文件夹
- python3 uper(),继承实现原理,封装
- [MySQL] 一致性读分析
- Oracle基础 08 用户角色 user/role
- Oracle基础 07 参数文件 pfile/spfile
- Selenium2+python自动化-窗口多标签处理方法总结(转载)
- 使用python获取整月每一天的系统监控数据生成报表
- [libgdx游戏开发教程]使用Libgdx进行游戏开发(2)-游戏框架搭建