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 ...
随机推荐
- DataAnalysis-Pandas分组聚合
title: Pandas分组聚合 tags: 数据分析 python categories: DataAnalysis toc: true date: 2020-02-10 16:28:49 Des ...
- Google 浏览器 离线包下载方式
最近因工作需要,需要安装google浏览器,并且安装在系统固定目录,用360软件管理下载后发现默认安装在C:\Users\administrator\AppData\Local\Google\Chro ...
- 使用rem配置PC端自适应大屏
效果如下 使得大屏不论在什么宽高比例依然能展示全部数据 安装 npm install -S postcss-pxtorem rem配置思路 原先的rem函数是能解决大部分的问题的,如果展示不全,也可以 ...
- Pytest系列(21)- allure的特性,@allure.description()、@allure.title()的详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 前面介绍了两种allure的 ...
- AJ学IOS 之第一次打开Xcode_git配置,git简单学习
AJ分享,必须精品 一:错误 当第一次打开Xcode我们进行commit操作的时候会报错: The working copy “测试” failed to commit files. * Please ...
- Redis学习二:Redis高并发之主从模式
申明 本文章首发自本人公众号:壹枝花算不算浪漫,如若转载请标明来源! 感兴趣的小伙伴可关注个人公众号:壹枝花算不算浪漫 22.jpg 前言 前面已经学习了Redis的持久化方式,接下来开始学习Redi ...
- c语言中的引用使用
最近在写一个图像处理的程序时候,遇到一些传参的问题,最后发现引用的效率高一些,在此提醒各位道友,多多关注引用的应用及使用. 1.在引用的使用中,单纯给某个变量取个别名是毫无意义的,不要为了耍酷而乱用, ...
- 攻防世界Web新手解析
攻防世界入门的题目 view source 禁用右键,F12审查元素 get post hackbar进行post robots 直接访问robots.txt,发现f1ag_1s_h3re.ph文件, ...
- shiro:入门程序(一)
SpringMVC项目 1:pom引入相关依赖 <dependencies> <!--测试依赖--> <dependency> <groupId>jun ...
- SQLServer系统表使用简介(sysobjects、syscolumns、syscomments等)转载
sysobjects:记录了数据库中每一个表.视图.约束.存储过程等详细内容的表. 表中常用的字段如下 : 列名 数据类型 描述 name sysname 对象名 id int 对象标识号 xtype ...