美文网首页
linux 系统nginx 安装

linux 系统nginx 安装

作者: 一蓑烟雨_龙哥 | 来源:发表于2020-09-07 14:05 被阅读0次

nginx 官网
http://nginx.org/en/download.html

image.png
yum 安装
image.png
选择centos 结合官网看。注意版本7 指的的centos 的版本,7或者7.x ,8或者8.x 都可以。
image.png
安装好后,查看版本。

[root@VM-0-2-centos ~]# nginx -v
nginx version: nginx/1.18.0

nginx -V 显示编译的参数。
[root@VM-0-2-centos ~]# nginx -V

image.png
yum 安装好nginx 后,用 rpm -ql nginx 查询安装的目录
[root@localhost yum.repos.d]# rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx

nginx 的启动,停止,重启

########关闭

service nginx stop
systemctl stop nginx

########启动

service nginx reload
systemctl restart nginx

#########随系统启动自动运行

systemctl enable nginx

#######禁止随系统启动自动运行

systemctl disable nginx

########

nginx 启动后,输入ip,如下表示 启动成功。

image.png
知识点扩展:

首先利用配置文件启动nginx。
[命令](https://www.linuxcool.com/ "命令"):


首先利用配置文件启动nginx。
[命令](https://www.linuxcool.com/ "命令"):

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

重启服务: service nginx restart

1. 快速停止或关闭Nginx:nginx -s stop

2. 正常停止或关闭Nginx:nginx -s quit

3. 配置文件修改重装载[命令](https://www.linuxcool.com/ "命令"):nginx -s reload
image.png
[root@VM-0-2-centos conf.d]# cat default.conf
#代表服务配置
server {
    listen       80; #端口配置
    server_name  localhost; #服务器名

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    #当用户访问http://ip:80/
    location / {
        root   /usr/share/nginx/html;  #当匹配到/这个规则时(因为location 后面是  /),指向目录/usr/share/nginx/html。
        index  index.html index.htm;   #当访问不指定具体页面时,默认显示的页面,类似于 web.xml 的 welcomefiles;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #当服务出现500的错误时,访问的页面。
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

相关文章

  • 编译安装PHP开发环境

    Linux 系统为 CentOS 7.2 1. 安装 Nginx 安装 Nginx 依赖包: 安装 Nginx: ...

  • Linux安装nginx

    Linux 配置 nginx Linux 配置 nginx 1) 安装nginx前首先要确认系统中安装了 2) 如...

  • Nginx超详细入门!

    本文介绍基于 Linux 系统的 nginx 安装以及简单使用 1、安装 1.1、安装 nginx 依赖的环境 使...

  • nginx 入门

    本文介绍基于 Linux 系统的 nginx 安装以及简单使用 1、安装 1.1、安装 nginx 依赖的环境 使...

  • 十分钟了解Nginx

    nginx 入门、安装、命令、配置、优化 操作系统:CentOS Linux 7Nginx版本:yum安装1.12...

  • Nginx的安装(Linux)

    Nginx的安装(Linux) 操作系统:CentOS6.4,Nginx源码包:nginx-1.8.0.tar.g...

  • linux如何安装nginx?

    linux如何安装nginx? 在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-d...

  • liunx下安装nginx

    linux下安装nginx linux系统为Centos 64位 第一步:从http://nginx.org/do...

  • LNMP环境配置

    Linux 系统环境:CentOs 7 Nginx 安装 一.源码安装(未实践) 1)新系统要安装编译工具$ yu...

  • 配置Nginx实现https协议,支持ATS

    前言 在CentOS版本的Linux系统下使用 yum install -y nginx直接安装。执行nginx ...

网友评论

      本文标题:linux 系统nginx 安装

      本文链接:https://www.haomeiwen.com/subject/webkektx.html