centos7 源码安装nginx
1. 安装编译所需要的工具包
- yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
2. 安装nginx
- # 下载nginx 安装包
- cd /usr/local/software
- wget http://nginx.org/download/nginx-1.15.12.tar.gz
- tar -xvf nginx-1.15.12.tar.gz
- cd nginx-1.15.12
- # 编译
- ./configure \
- --prefix=/usr/local/nginx \
- --pid-path=/var/run/nginx/nginx.pid \
- --lock-path=/var/lock/nginx.lock \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --with-http_gzip_static_module
- # 安装
make && make install
3. shell脚本启动nginx并设置为开机自启动
3.1 编写快速启动脚本
vim /etc/init.d/nginx
- #!/bin/bash
- # nginx Startup script for the Nginx HTTP Server
- # it is v.0.0. version.
- # chkconfig: -
- # description: Nginx is a high-performance web and proxy server.
- # It has a lot of features, but it's not for everyone.
- # processname: nginx
- # pidfile: /var/run/nginx.pid
- # config: /usr/local/nginx/conf/nginx.conf
- nginxd=/usr/local/nginx/sbin/nginx
- nginx_config=/usr/local/nginx/conf/nginx.conf
- nginx_pid=/var/run/nginx.pid
- RETVAL=
- prog="nginx"
- # Source function library.
- . /etc/rc.d/init.d/functions
- # Source networking configuration.
- . /etc/sysconfig/network
- # Check that networking is up.
- [ ${NETWORKING} = "no" ] && exit
- [ -x $nginxd ] || exit
- # Start nginx daemons functions.
- start() {
- if [ -e $nginx_pid ];then
- echo "nginx already running...."
- exit
- fi
- echo -n $"Starting $prog: "
- daemon $nginxd -c ${nginx_config}
- RETVAL=$?
- echo
- [ $RETVAL = ] && touch /var/lock/subsys/nginx
- return $RETVAL
- }
- # Stop nginx daemons functions.
- stop() {
- echo -n $"Stopping $prog: "
- killproc $nginxd
- RETVAL=$?
- echo
- [ $RETVAL = ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
- }
- # reload nginx service functions.
- reload() {
- echo -n $"Reloading $prog: "
- #kill -HUP `cat ${nginx_pid}`
- killproc $nginxd -HUP
- RETVAL=$?
- echo
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- reload)
- reload
- ;;
- restart)
- stop
- start
- ;;
- status)
- status $prog
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|reload|status|help}"
- exit
- esac
- exit $RETVAL
3.2 使用脚本并加入开机自启
- # shell脚本启动nginx
- chmod a+x /etc/init.d/nginx # 赋予执行权限
- service nginx start
- service nginx stop
- service nginx restart
- service nginx reload
- # 加入到rc.local文件中, 开机自启
- vim /etc/rc.local
- /etc/init.d/nginx start #加入进去
centos7 源码安装nginx的更多相关文章
- CentOS7源码安装Nginx
系统平台:腾讯云服务器 CentOS 7.3 64位 一.安装编译工具及库文件 [root@VM_0_5_centos ~]# yum install -y make zlib zlib-devel ...
- 源码安装nginx env
源码安装nginx 1. For ubuntu:18.04 apt -y install build-essential libtool libpcre3 libpcre3-dev zlib1g-de ...
- 源码安装nginx以及平滑升级
源码安装nginx以及平滑升级 ...
- Linux之源码安装nginx,并按照作业一描述的那样去测试使用
作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...
- 源码安装Nginx以及用systemctl管理
一.源码安装Nginx: 先安装gcc编译器(安装过的可以忽略) [root@localhost ~]# yum -y install gcc gcc-c++ wget 进入src目录 [root@l ...
- centos7源码安装Python3的前提条件
centos7源码安装Python3的前提条件: # yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline- ...
- linux源码安装nginx
任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...
- 工作笔记-- 源码安装nginx
源码安装nginx 1.安装nginx的依赖包 [root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pc ...
- 源码安装nginx 方法二
yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...
随机推荐
- Vue-CLI 3.x 部署项目至生产服务器
本文已同步到专业技术网站 www.sufaith.com, 该网站专注于前后端开发技术与经验分享, 包含Web开发.Nodejs.Python.Linux.IT资讯等板块. 本教程主要讲解的是 Vue ...
- 力软敏捷框架集成布局插件(ce-layout)
最近用力软的框架觉得框架在布局这块不是很友好特别是对像css不是很好的程序员来说,大部分大家都是后端程序员. 所以决定集成一个和力软敏捷框架风格比较一致的布局插件进来 插件ce-layout ,下载地 ...
- template_showpost
使用<a href='...'>name<\a>实现点击"name"与转向'...'网址的超链接操作 from django.shortcut import ...
- Python设计模式(8)-抽象工厂
# coding=utf-8 这种方式反倒把事情做复杂了 可取之处在于有了更高层次的抽象 class IEmployee: def insert_employee(self): pass class ...
- 多线程高并发编程(3) -- ReentrantLock源码分析AQS
背景: AbstractQueuedSynchronizer(AQS) public abstract class AbstractQueuedSynchronizer extends Abstrac ...
- PHP 语法引用使用及实现
说明 这里基于 php7.2.5 进行测试,php7 之后内部结构变化应该不是太大,但与 php5.X 有差别. 什么是引用 在 PHP 中引用是一种数据类型 (结构),是指 指向同一个类型的数据结构 ...
- push和appendChild的区别
概述:绑定事件(push和appendChild用法相似:但是一个是控制数组,一个是控制元素节点)用法:1.数组1的更改后的长度 = 数组1.push();//用来控制数组,在数组最后面插入项,返回数 ...
- Sentry实时应用错误跟踪系统在Kubernetes中私有化部署
应用错误跟踪系统:对软件系统运行过程中产生的错误日志进行收集从而实现监控告警. 虽然软件错误❌是不可避免的,但是可以降低错误数. 提高对错误的治理能力能让错误带来的损失降到最低
- 当文件目录变得杂乱不堪怎么办,python帮你轻松搞定
这几天和几个小伙伴,在一起合做一个ppt. 做ppt之前有原版的ppt,和一个word大纲,在制作过程中,又不断添加图片.视频等素材,最终,整个目录变得杂乱不堪(见下图-处理之前) 那我想,可不可以做 ...
- LCA基础 附例题(落谷)
https://www.luogu.org/problemnew/solution/P3379 LCA叫做最短公共祖先,用来求距离树上两个节点最近的公共点: 常用倍增算法: #include<i ...