CentOS 7.0 安装nginx

简介:

1、安装准备

1
2
3
4
5
6
7
yum -y  install  gcc-c++ pcre-devel zlib-devel unzip patch
groupadd -f www
useradd  -d  /var/cache/nginx  -s  /sbin/nologin  -g www nginx
mkdir  /var/log/nginx 
mkdir  /usr/local/nginx 
chown  -R nginx.www  /var/log/nginx
chown  -R nginx.www  /usr/local/nginx

2、安装nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
tar  zxf nginx-1.8.0. tar .gz
cd  nginx-1.8.0
patch -p1 <  /root/nginx_upstream_check_module-master/check_1 .7.5+.patch
. /configure  --prefix= /usr/local/nginx  \
--user=nginx \
--group=www \
--pid-path= /run/nginx .pid \
--error-log-path= /var/log/nginx/error .log \
--http-log-path= /var/log/nginx/access .log \
--add-module= /root/nginx_upstream_check_module-master
make  &&  make  install
ln  -s  /usr/local/nginx/sbin/nginx  /usr/sbin/nginx
vim  /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= /run/nginx .pid
ExecStartPre= /usr/sbin/nginx  -t -c  /usr/local/nginx/conf/nginx .conf
ExecStart= /usr/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

3、设置开机启动和启动nginx

1
2
systemctl  enable  nginx
systemctl start nginx

参考博文:http://soulful.blog.51cto.com/468033/1676442




     本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1741946,如需转载请自行联系原作者




相关文章
|
10天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
14 0
|
1天前
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
6 1
|
3天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
33 2
|
10天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
19 0
|
10天前
|
分布式计算 Hadoop Java
centos 部署Hadoop-3.0-高性能集群(一)安装
centos 部署Hadoop-3.0-高性能集群(一)安装
12 0
|
10天前
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
23 2
|
10天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
47 0
|
16天前
|
IDE Linux 开发工具
CentOS7.4+REDHAWK2.3.1安装教程——折腾篇
CentOS7.4+REDHAWK2.3.1安装教程——折腾篇
18 0
|
21天前
|
Linux Shell 开发工具
CentOS8中Docker安装及部署
CentOS8中Docker安装及部署
67 0
|
21天前
|
应用服务中间件 Linux PHP
Linux下安装php环境并且配置Nginx支持php-fpm模块
Linux下安装php环境并且配置Nginx支持php-fpm模块
18 0