安装nginx的依赖包(pcre-devel openssl-devel)
yum install -y gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel
pcre:兼容perl语言正则表达式,perl compatible regular expressions
      rewirte模块 参数信息(perl方式定义正则表达式)
openssl:ssh---openssh/openssl---https
总结:所有安装依赖软件,后面都要加上-devel
下载nginx软件
解压软件
tar -zxvf nginx-1.16.0.tar.gz
创建管理用户 www
useradd -M -s /sbin/nologin nginx
 nginx软件编译安装过程
 编译安装软件
1、配置软件,在软件的解压目录中
[root@web01 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx-1.16.0 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
编译参数说明:
 --prefix           表示指定软件安装到哪个目录中,指定目录不存在会自动创建
 --user/--group       nginx工作进程由哪个用户运行管理
 --with-http_stub_status_module   启动nginx状态模块功能(用户访问nginx的网络信息)
 --with-http_ssl_module           启动https功能模块
通过软件编译过程中的返回值是否正确,确认配置是否正确
# echo $? 0
   2、编译软件
# make
   3、编译安装
# make install
 验证是否安装成功
根据自己情况是否创建软连接
# ln -s /usr/local/nginx-1.16.0 /usr/local/nginx
# ll /usr/local/nginx/ ##查看nginx安装目录信息
total 4
drwxr-xr-x. 2 root root 4096 Jun 5 16:53 conf
drwxr-xr-x. 2 root root 40 Jun 5 16:53 html
drwxr-xr-x. 2 root root 6 Jun 5 16:53 logs
drwxr-xr-x. 2 root root 19 Jun 5 16:53 sbin
# /usr/local/nginx/sbin/nginx -V ###查看nginx安装版本等信息
nginx version: nginx/1.16.0
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: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
精简化nginx.conf 主配置文件内容
# egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf.default >/usr/local/nginx/conf/nginx.conf
启动程序
# /usr/local/nginx/sbin/nginx ###启动nginx
# ps -ef | grep nginx ###查看nginx是否启动成功
root 29602 1 0 16:57 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 29603 29602 0 16:57 ? 00:00:00 nginx: worker process
root 29605 20541 0 16:58 pts/0 00:00:00 grep --color=auto nginx
# netstat -lntup |grep 80 ###检查端口信息
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 29602/nginx: master
服务部署完成
至此软件安装完毕!
修改环境变量
echo 'export PATH=/usr/local/nginx/sbin:$PATH'>>/etc/profile source /etc/profile which nginx
创建一个nginx.service启动
一、创建一个nginx.service
在 /usr/lib/systemd/system/目录下面新建一个nginx.service文件。并赋予可执行的权限。
vim /usr/lib/systemd/system/nginx.service
二、编辑service内容
[Unit]
Description=nginx - high performance web server
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=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
三、启动服务
chmod +x /usr/lib/systemd/system/nginx.service
在启动服务之前,需要先重载systemctl命令
systemctl daemon-reload
systemctl start nginx.service
systemctl enable nginx.service

最新文章

  1. 【工具】VS2010常用调试技巧(1)
  2. AJAX避免服务器调用上个页面缓存的办法
  3. 天气预报API(四):全国城市代码列表(“新编码”)
  4. POJ 3519 Minimal Backgammon
  5. overlay-2
  6. 学习BigDecimal用法
  7. PED结构获取进程路径和命令行地址
  8. 十二、BOOL冒泡
  9. 【leetcode】Container With Most Water(middle)
  10. redhat系统安装部署
  11. JMeter基础概念
  12. ms sql 获取字符串首字母
  13. Android Game Examples
  14. iOS视频边下载边播放
  15. react native 左边固定,右边横向滑动左右自适应高度
  16. Jenkins + Ansible + Gitlab之ansible篇
  17. Windows10下安装VMware虚拟机并搭建CentOS系统环境
  18. [Kubernetes]安装和配置kubectl
  19. Jquery 图片延迟加载技术
  20. 使用jetty工具包处理url参数成map

热门文章

  1. nodejs 文件操作
  2. Linux驱动开发8——中断处理
  3. 十八、RF中selenium2library构造函数中参数解释
  4. 硬件-硬盘-SSD(固态硬盘):百科
  5. hadoop报错WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  6. cross appdomain access
  7. .net通用签名方法 webapi签名方法
  8. Java之类的继承
  9. 【Qt开发】Qt让线程休息一段时间
  10. kafka之config/server.properties配置参数说明