参考自 https://www.jianshu.com/p/9b2dd37a5af9  ;

【1】安装步骤

step1)安装nginx

 sudo yum install -y nginx

step2)启动nginx服务

-- 开机自启动 sudo systemctl enable nginx
-- 开启nginx 服务 sudo systemctl start nginx

step3)查看nginx状态

sudo systemctl status nginx

step4)查看本机ip地址

sudo hostname -I | awk '{print $1}'

如ip地址为 192.168.163.204 ;

step5)window机器上访问  192.168.163.204, 无法访问;

step6)显然防火墙关闭该端口被访问权限,需要打开

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload# 开通8080访问权限
firewall-cmd --zone=public --add-port=8080/tcp --permanent# 重载防火墙配置
firewall-cmd --reload

step7)再次访问成功

【2】nginx管理命令

  • 1)sudo systemctl status nginx : 查看nginx状态;
  • 2)sudo systemctl stop nginx : 关闭nginx服务;
  • 3) sudo systemctl start nginx : 启动或重启 nginx服务;
  • 4) sudo systemctl reload nginx : 若修改了配置,如反向代理,重新加载配配置而不必重启;
  • 5)sudo systemctl  disable nginx :禁止开机自启动;
  • 6)sudo systemctl enable nginx  : 开机自启动;

【补充】nginx安装完成后, 其配置文件在  /etc/nginx/nginx.conf

[root@localhost nginx]# pwd
/etc/nginx
[root@localhost nginx]# ls
conf.d                fastcgi_params          mime.types          scgi_params           win-utf
default.d             fastcgi_params.default  mime.types.default  scgi_params.default
fastcgi.conf          koi-utf                 nginx.conf          uwsgi_params
fastcgi.conf.default  koi-win                 nginx.conf.default  uwsgi_params.default

nginx可执行脚本在

[root@localhost sbin]# which nginx
/usr/sbin/nginx

【3】nginx脚本命令

[root@localhost sbin]# nginx -v  // 查看版本号
nginx version: nginx/1.14.1
[root@localhost sbin]# ps -ef | grep nginx  // 查看nginx进程是否开启
root       11913       1  0 22:21 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx      11921   11913  0 22:21 ?        00:00:00 nginx: worker process
nginx      11922   11913  0 22:21 ?        00:00:00 nginx: worker process
root       11984    1511  0 22:34 pts/0    00:00:00 grep --color=auto nginx
[root@localhost sbin]#
[root@localhost sbin]# nginx -s stop   // 关闭nginx 服务
[root@localhost sbin]#
[root@localhost sbin]# ps -ef | grep nginx
root       11991    1511  0 22:35 pts/0    00:00:00 grep --color=auto nginx
[root@localhost sbin]#
[root@localhost sbin]#
[root@localhost sbin]# nginx         // 启动nginx 服务
[root@localhost sbin]#
[root@localhost sbin]# ps -ef | grep nginx
root       11993       1  0 22:35 ?        00:00:00 nginx: master process nginx
nginx      11994   11993  0 22:35 ?        00:00:00 nginx: worker process
nginx      11995   11993  0 22:35 ?        00:00:00 nginx: worker process
root       11997    1511  0 22:35 pts/0    00:00:00 grep --color=auto nginx
[root@localhost sbin]#
[root@localhost sbin]# nginx -s reload   // 重新加载nginx配置
[root@localhost sbin]#
[root@localhost sbin]# 

【4】nginx结构说明

1)所有Nginx配置文件都位于/etc/nginx/目录中。
2)Nginx配置:主要配置文件是/etc/nginx/nginx.conf。为每个域创建一个单独的配置文件使服务器易于维护。Nginx服务器阻止文件必须以结尾.conf并存储在/etc/nginx/conf.d目录中。您可以根据需要拥有任意数量的服务器块。

[root@localhost local]# cd /etc/nginx/
[root@localhost nginx]# ls
conf.d                fastcgi_params.default  nginx.conf           uwsgi_params.default
default.d             koi-utf                 nginx.conf.default   win-utf
fastcgi.conf          koi-win                 scgi_params
fastcgi.conf.default  mime.types              scgi_params.default
fastcgi_params        mime.types.default      uwsgi_params
[root@localhost nginx]# ll
total 68
drwxr-xr-x. 2 root root    6 Oct  7  2019 conf.d
drwxr-xr-x. 2 root root    6 Oct  7  2019 default.d
-rw-r--r--. 1 root root 1077 Oct  7  2019 fastcgi.conf
-rw-r--r--. 1 root root 1077 Oct  7  2019 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 Oct  7  2019 fastcgi_params
-rw-r--r--. 1 root root 1007 Oct  7  2019 fastcgi_params.default
-rw-r--r--. 1 root root 2837 Oct  7  2019 koi-utf
-rw-r--r--. 1 root root 2223 Oct  7  2019 koi-win
-rw-r--r--. 1 root root 5170 Oct  7  2019 mime.types
-rw-r--r--. 1 root root 5170 Oct  7  2019 mime.types.default
-rw-r--r--. 1 root root 2469 Oct  7  2019 nginx.conf
-rw-r--r--. 1 root root 2656 Oct  7  2019 nginx.conf.default
-rw-r--r--. 1 root root  636 Oct  7  2019 scgi_params
-rw-r--r--. 1 root root  636 Oct  7  2019 scgi_params.default
-rw-r--r--. 1 root root  664 Oct  7  2019 uwsgi_params
-rw-r--r--. 1 root root  664 Oct  7  2019 uwsgi_params.default
-rw-r--r--. 1 root root 3610 Oct  7  2019 win-utf

3)遵循标准命名约定是一个好习惯。例如,如果域名是,mydomain.com则配置文件应命名为mydomain.com.conf;如果在域服务器块中使用可重复的配置段,则最好将这些段重构为片段。
4)Nginx日志:日志文件(access.log和error.log)位于/var/log/nginx/目录中。建议有不同access和error日志文件每个服务器模块。
5)您可以将域文档的根目录设置为所需的任何位置。webroot的最常见位置包括:

  • /home/<user_name>/<site_name>  :
  • /var/www/<site_name>  : 存储不同网站的资源 ;
  • /var/www/html/<site_name>  :存放静态资源 html,css,js;
  • /opt/<site_name>  :
  • /usr/share/nginx/html  : 静态html文件的位置;

centos8上安装nginx相关推荐

  1. 如何在 CentOS 7 上安装 Nginx

    本文首发:开发指南:如何在 CentOS 7 上安装 Nginx Nginx 读作 engine x, 是一个免费的.开源的.高性能的 HTTP 和反向代理服务,主要负责负载一些访问量比较大的站点. ...

  2. Ubuntu上安装nginx步骤及问题记录

    在Ubuntu上安装nginx,步骤如下:      1. 向/etc/apt/sources.list增加Nginx的源      2.执行sudo apt-get update更新软件源     ...

  3. 如何在 FreeBSD 10.2 上安装 Nginx 作为 Apache 的反向代理

    如何在 FreeBSD 10.2 上安装 Nginx 作为 Apache 的反向代理 Nginx 是一款自由开源的 HTTP 和反向代理服务器,也可以用作 POP3/IMAP 的邮件代理服务器.Ngi ...

  4. centos 6.5 php nginx,CentOS6.5上安装nginx与php5.5

    CentOS6.5上安装nginx与php5.5 2014年04月08日 1. 安装必要的包 # rpm -Uvh http://download.fedoraproject.org/pub/epel ...

  5. 在Ubuntu 18.04上安装Nginx

    NGINX pronounced as engine-x is an open source and popular HTTP server and can be configured to act ...

  6. 在Centos8上安装漏洞扫描软件Nessus

    本文摘要:简单叙述了在Centos8上安装Nessus扫描器的过程 Nessus 是目前全世界最多人使用的系统漏洞扫描与分析软件,Nessus的用户界面是基于Web界面来访问Nessus漏洞扫描器的, ...

  7. 阿里云服务器上安装nginx

    转自:https://blog.csdn.net/u014209205/article/details/78921870 在阿里云服务器上安装nginx中遇到一些问题,现将步骤罗列下, 环境是:cen ...

  8. 在CentOS上安装nginx服务器

    一.环境描述 1. 虚拟机配置 CPU:单核 内存:2 GB 硬盘:120 GB IP:10.24.17.108 2. 操作系统 版本:CentOS 6.6 x86_64 安装方式:Minimal 3 ...

  9. Centos7上安装Nginx两种方法

    源码编译安装 http://nginx.org/en/download.html 到官网下载,然后用XFTP上传到root目录 把文件解压出来 tar -zxvf nginx-1.16.0.tar.g ...

最新文章

  1. java decodeurl,java decodeURIComponent
  2. 武汉理工java_Java语言程序设计E
  3. Markdown创建页面和目录?
  4. 【Demo】改变SO项目状态并取消拒绝原因实现
  5. EF 实现自定义数据库字符串
  6. LeetCode 457. 环形数组循环(暴力+快慢指针)
  7. php如何封装类内乡通南阳的_PHP类(三)-类的封装
  8. 08-05 性能测试--定时器场景
  9. A Byte of Python 笔记(12)python 标准库:sys、os,更多内容
  10. c#Code Contracts代码协定
  11. linux安装mysql5.7.24_下载安装 Ubuntu 19.04 “Disco Dingo” | Linux 中国
  12. Java Se 、JavaEE、JavaME区别
  13. 计算机网络波特率定义,传输速率——比特率和波特率
  14. 计算机等级考试二级C语言考试环境VS2010学习版以及免费题库
  15. C#开发工厂ERP生产管理系统源码
  16. 谷歌地图打不开怎么办?
  17. [十大排序]有的人图画着画着就疯了(1.5w字详细分析+动图+源码)
  18. 企业如何选择一个好的网站设计公司?
  19. 外推法的matlab程序
  20. 豆瓣上征婚交友的小姐姐们

热门文章

  1. CF623E Transforming Sequence(多项式/倍增fft/动态规划)
  2. Educational Codeforces Round 112 (Rated for Div. 2)
  3. Joy of Handcraft Gym - 102822J(线段树或差分)
  4. 【HDU-2376】Average distance
  5. 牛客题霸 [二叉树的之字形层序遍历] C++题解/答案
  6. 2020牛客国庆集训派对day2 AKU NEGARAKU
  7. 三角形周长和【牛客网】牛客网练习赛60
  8. Educational Codeforces Round 119 (Rated for Div. 2)
  9. [CQOI2015]选数(数论分块+杜教筛)
  10. 数据结构之线段树合并——永无乡,Lomsat gelral,Tree Rotations,Tree Rotations Escape Through Leaf