04.nginx使用
博客为日常工作学习积累总结:
1.安装依赖包
安装pcre :yum install pcre pcre-devel -y
安装openssl:yum install openssl openssl-devel -y
检查安装包:rpm -qa pcre pcre-devel
pcre-7.8-7.el6.x86_64
pcre-devel-7.8-7.el6.x86_64
切换至国内yum源:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
安装nginx:地址:http://nginx.org/download/nginx-1.14.2.tar.gz
创建安装用户:useradd oldboy passwd oldboy
放置路径:/home/oldboy/tools
网络下载:wget -q http://nginx.org/download/nginx-1.14.2.tar.gz
解压:tar xf nginx-1.14.2.tar.gz
ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
查看nginx安装包:yum list | grep nginx
为配置文件添加用户:useradd nginx
配置文件:./configure --prefix=/application/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_mp4_module --with-http_flv_module
./configure --help
编译:make (make & make install)
编译后安装:make install
将带版本的去掉创建软连接:ln -s /application/nginx-1.6.3/ /application/nginx
启动:/application/nginx/sbin/nginx
查询端口:netstat -lntup|grep 80 lsof -i :80
查看nginx版本:/application/nginx/sbin/nginx -V
优化去掉注释:egrep -v "#|^$" nginx.conf.default >nginx.conf
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -s reload
ln -n /application/nginx/sbin/nginx /usr/bin/nginx
2.设置开机自启动:
参考链接:https://www.cnblogs.com/jepson6669/p/9131217.html
进入到:cd /lib/systemd/system/
创建服务文件:vim nginx.service
[Unit]
Description=nginx service
After=network.target [Service]
Type=forking
ExecStart=/application/nginx/sbin/nginx
ExecReload=/application/nginx/sbin/nginx -s reload
ExecStop=application/nginx/sbin/nginx -s quit
PrivateTmp=true [Install]
WantedBy=multi-user.target
加入开机自启动:systemctl enable nginx
取消开机自启动:systemctl disable nginx
常用命令使用:
systemctl start nginx.service 启动nginx服务
systemctl stop nginx.service 停止服务
systemctl restart nginx.service 重新启动服务
systemctl list-units --type=service 查看所有已启动的服务
systemctl status nginx.service 查看服务当前状态
systemctl enable nginx.service 设置开机自启动
systemctl disable nginx.service 停止开机自启动
常见错误处理:systemctl daemon-reload
3.跑一个项目测试:
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
upstream ofmovie {
server 192.168.50.188:;
server 192.168.50.188:;
server 192.168.50.188:;
server 192.168.50.188:;
}
server {
listen ;
server_name ofmovie.flybird.com;
location / {
root html;
index index.html index.htm;
proxy_pass http://ofmovie;
}
}
}
运行自己做的项目:
[root@mould ~]# cd /data/movie/
nohup python manage.py runserver -h 192.168.50.188 -p 5001
nohup python manage.py runserver -h 192.168.50.188 -p 5002
nohup python manage.py runserver -h 192.168.50.188 -p 5003
nohup python manage.py runserver -h 192.168.50.188 -p 5004
04.nginx使用的更多相关文章
- Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程
Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程 1.先切换到root用户 sudo su 2.更新软件源 apt update apt-get upgrade 3. ...
- zabbix快速安装(Ubuntu18.04, Nginx)
ubuntu18.04快速安装zabbix4.0 https://blog.csdn.net/qq_33317586/article/details/83867756 需要安装的东西:nginx,ph ...
- 04 . Nginx的Rewrite重写
Rewrite简介 # Rewrite对应URL Rewrite,即URL重写,就是把传入web的请求重定向到其他URL的过程. # 当运维遇到要重写情况时,往往是要程序员把重写规则写好后,发给你,你 ...
- 阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问
参考页面: https://certbot.eff.org/#ubuntutrusty-nginx http://bbs.qcloud.com/thread-12059-1-1.html http:/ ...
- 04: nginx部署vue
1.1 基本配置 server { listen 9000; server_name 1.1.1.3; #access_log logs/access_example.log main; root / ...
- ubuntu14.04 +nginx+php5-fpm
一,安装Nginx apt-get install nginx 1,配置nginx nginx所有的配置在 /etc/nginx/nginx.conf中 nginx.conf配置里面包括了 inclu ...
- ubuntu 13.04 nginx.conf 配置详解
1.nginx.conf 文件,路径为:/etc/nginx/agin.conf #使用的用户和组 user www-data; #指定工作衍生进程数(一般等于CPU总核数或总核数的两倍) worke ...
- ubuntu16.04 nginx安装
.gcc.g++依赖库 apt-get install build-essential apt-get install libtool .安装 pcre依赖库(http://www.pcre.org/ ...
- 阿里云Ubuntu 14.04 + Nginx + .net core + MySql
前段时间帮朋友写了一个网站,现在做一个记录. .Net Core 安装: curl https://packages.microsoft.com/keys/microsoft.asc | gpg -- ...
随机推荐
- 基础架构之日志管理平台及钉钉&邮件告警通知
接上一篇,我们继续解释如何把ELK跟钉钉及发送邮件功能结合起来,让我们及时的了解重要日志并快速反馈. Sentinel 安装,项目介绍在https://github.com/sirensolution ...
- hdu 1159 Common Subsequence(最长公共子序列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Common Subsequence Time Limit: 2000/1000 MS (Jav ...
- atoi、itoa,strcpy,strcmp,memcpy等实现
原文:http://www.cnblogs.com/lpshou/archive/2012/06/05/2536799.html 1.memcpy.memmove.memset源码 link:http ...
- Kafka配额讨论(流量限制)
Kafka自0.9.0.0版本引入了配额管理(quota management),旨在broker端对clients发送请求进行限流(throttling).目前Kafka支持两大类配额管理: 网络带 ...
- QT 编译遇到重定义;不同的基类型&在QT中使用C++ lib库
最近在使用osg和qt开发,在集成osg时候因为我使用的qt版本为非opengl的版本,导致qt自己封了一遍opengl的一些基类变量如double 这时候就会跟osg中声明的opengl的类型冲突, ...
- vs2013 c# 中调用 c 编写的dll出错的可能错误
先说出错原因: 堆栈调用顺序 解决办法: 使用 __stdcall 或 使用C#属性 CallingConvention 起因是我想在c#中调用c函数结果出错了 如下 C 头文件 ...
- SiP封装成超越摩尔定律的要塞,日月光/安靠/长电科技谁将赢取IC封装的未来
来源:EEFOCUS 进入2017年,摩尔定律的脚步愈加沉重,"摩尔定律已死"的言论笼罩着整个半导体行业,超越摩尔定律发展的想法在半导体从业人员的脑海里更清晰了.在这样的大环境下, ...
- 微软智能云的核心DNA
你知道吗? 今天,微软智能云平台运行于全球30个区域,体量超过了两大云服务商亚马逊和谷歌的总和: 今天,在全球范围内超过85%的财富五百强企业都使用了微软Azure云服务,而中国部分的用户也达到了六万 ...
- c# 的传递参数值传递与传递引用的区别,ref与out区别
值传递 C#默认都是值传递的,就是复制变量的一个副本传递给方法,所以在退出方法后,对变量的修改无效. 但是要注意,当传递是引用类型时,因为引用类型是一个引用的地址,所以修改引用地址指向的对象时,一样会 ...
- TC9.0新增实用接口,用AutoHotkey获取当前选中文件等信息
TC9.0的history.txt里有几行更新说明(见文章末尾),可以用SendMessage命令获取信息, 消息号是WM_USER+50(即1074),wParam则是更新说明里的内容, 下面是我简 ...