(转)Centos7 Nginx安装
场景:工作中使用的suse,因为系统可可查资料太少,且系统中一些功能的确实,导致很多集群中功能无法顺利测试通过,在Centos上面进行测试,能够更快的熟悉项目的架构过程!
1 安装准备
首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++、gcc、openssl-devel、pcre-devel和zlib-devel 所以执行如下命令安装
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
2 安装Nginx
安装之前,最好检查一下是否已经安装有nginx
find -name nginx
如果系统已经安装了nginx,那么就先卸载
yum remove nginx
首先进入/usr/local目录
cd /usr/local
从官网下载最新版的nginx
wget http://nginx.org/download/nginx-1.7.4.tar.gz
这里也可以直接下载,然后上传到指定的目录。
解压nginx压缩包
tar -zxvf nginx-1.7.4.tar.gz
会产生一个nginx-1.7.4 目录,这时进入nginx-1.7.4目录
cd nginx-1.7.4
接下来安装,使用--prefix参数指定nginx安装的目录,make、make install安装
#默认安装在/usr/local/nginx
./configure
make
make install
如果没有报错,顺利完成后,最好看一下nginx的安装目录
whereis nginx

安装完毕后,进入安装后目录(/usr/local/nginx)便可以启动或停止它了。
到此,使用CentOS安装nginx已经完成了,其实看看还是蛮简单的。
2 Nginx启动脚本
centos7使用systemd代替之前的systemv的启动脚本,可以说更简单。不再需要编写一长段脚本。
复制以下内容到/usr/lib/systemd/system/nginx.service
vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true [Install]
WantedBy=multi-user.target
即可使用systemctl start|stop|reload|restart nginx 进行启动重启等操作。
systemctl enable nginx即可实现开机启动。
systemctl disable nginx取消开机启动
(转)Centos7 Nginx安装的更多相关文章
- CentOS7 nginx安装与卸载
简明清晰,易操作,参照: CentOS7 nginx安装与卸载
- CentOS7 Nginx安装及配置反向代理
背景: Mono (Mono JIT compiler version 5.4.0.201 ) jexus-5.8.2-x64(<CentOS7 安装 jexus-5.8.2-x64>) ...
- CentOS7 nginx安装
1 nginx安装环境 nginx是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境. n gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没 ...
- centos7: nginx安装配置
centos平台编译环境使用如下指令 安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc ...
- linux centos7 nginx 安装部署和配置
1/什么是NginxNginx("enginex")是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器,在高连接并发的情况下Nginx是Apac ...
- centos7 nginx安装 及MySQL-python
1.pip install MySQL-python 出错问题 pip install -r requirement.txt 发现安装MySQL-python 出错,更新setuptools也没用 解 ...
- centos7 nginx安装/启动/进程状态/杀掉进程
1.安装 下载RPM:wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm ...
- Centos7 nginx安装过程
一.Centos版本: cat /etc/centos-release CentOS Linux release 7.1.1503 (Core) 二.nginx下载 官网:http://nginx.o ...
- Centos7 Nginx安装使用
一.Nginx简介 1.什么是nginx Nginx是一款使用C语言开发的高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.由俄罗斯的程序设计师Igor Sysoev ...
随机推荐
- javascript的八张图
- BOM(2)
Window 子对象 (1)Location 对象 Location 对象包含有关当前 URL(统一资源定位符) 的信息.(Uniform Resource Location) Location 对象 ...
- Log POST Data in Nginx
先编译Nginx的echo module: ./configure --add-module=./echo-nginx-module-0.54 make make install 可以在github上 ...
- 在windows下使用Qt5开发GTK3图形界面应用程序
首先,去MSYS2官网下载MSYS2环境并安装在C:/mysys64下,我安装的是64位的. 进入MSYS命令行执行: pacman -S mingw-w64-x86_64-gtk3 pacman - ...
- redis bitcount variable-precision swar算法
花了不到一周的时间看完了一本reids设计与实现的书,感觉整体的设计有些地方的确很巧妙,各个结构之间联系的非常紧密,但是很简单,逻辑性的没有太多,但是学到了一个bitcount计数1的方法比较巧妙,记 ...
- django ngRoute ui-router 开发环境下禁用缓存
问题描述: Python manage.py runserver ,禁用缓存,及时修改反馈到浏览器 解决办法: 使用dummy cache: Dummy caching (for developmen ...
- PHPCMS v9 自定义表单添加验证码
1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=&quo ...
- 基于FPGA的IIR滤波器
基于FPGA的IIR滤波器 by方阳 版权声明:本文为博主原创文章,转载请指明转载地址 ...
- 并归排序 (Java版本,时间复杂度为O(n))
自己上网查了一下并归排序的定义,把两个排序好的数组重新组成一个排序好的数组就是并归排序, 实现的方式有和多种,自己思考了一下,用java实现了一版本,思路如下,既然是排序好的,只需要依次比较两个数组, ...
- 如何在新浪sae服务器上面连接redis
1.创建php空应用 2.选择