ps:一切从简

一、安装所需环境:

yum -y install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

二、下载及安装nginx

1.下载nginx:wget http://nginx.org/download/nginx-1.8.1.tar.gz

2.解压nginx: tar -xzf nginx-1.8.1.tar.gz

3.添加用户组:groupadd www、useradd -g www www

3.编译nginx:进入解压之后的目录执行 (这里prefix为安装目录)

./configure \--user=www \--group=www \--prefix=/usr/local/nginx \--with-http_ssl_module \--with-http_stub_status_module \--with-http_realip_module \--with-threads

4.安装nginx:make && make install

(安装完成之后:make[1]: Leaving directory `/usr/local/nginx-1.8.1')  无伤大雅

5.验证是否安装成功:/usr/local/nginx/sbin/nginx -V

输出:

nginx version: nginx/1.8.1

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

built with OpenSSL 1.0.2k-fips  26 Jan 2017

TLS SNI support enabled

configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-threads

三、配置nginx

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.confExecStart=/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

执行:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

启动nginx:

systemctl start nginx

设置开机启动:

systemctl enable nginx

最新文章

  1. Dubbo_异常_Service启动时默认将方法注册到内网IP
  2. oracle打补丁
  3. c++中的<<函义
  4. php 生成唯一id的几种解决方法
  5. NFS挂载启动
  6. libevent 定时器示例
  7. HDU1048The Hardest Problem Ever
  8. foreach的指针问题
  9. 软中断&tasklet&工作队列
  10. Bzoj 3831 [Poi2014]Little Bird
  11. 使用Windows2003创建DHCP服务器 - 进阶者系列 - 学习者系列文章
  12. JavaScript中国象棋程序(0) - 前言
  13. Scala 操作符与提取器
  14. 在Sublime中配置JsFormat
  15. MySQL InnoDB中的事务隔离级别和锁的关系
  16. trap实现跳板机
  17. elasticsearch系列四:搜索详解(搜索API、Query DSL)
  18. Python——包
  19. Leetcode题库——27.移除元素
  20. Linux 防火墙 iptables基本操作

热门文章

  1. 01:认识QT
  2. SpringBoot整合WEB开发--(七)注册拦截器
  3. 判断IE版本的HTML语句[if lte IE 9]……[endif]
  4. 【Unity|C#】基础篇(7)——属性(Property)/ 索引器(Indexer)
  5. python爬虫匹配实现步骤
  6. K3/Cloud点击按钮打开第三方URL
  7. MS yc
  8. 【NOIP2012普及组】质因数分解
  9. CentOS 7升级gcc版本
  10. SpringBoot+springDataJpa实现单表字段动态部分更新