美文网首页
nginx(一)

nginx(一)

作者: 极客传 | 来源:发表于2019-01-26 22:45 被阅读0次

centos

安装nginx后,找到nginx目录,whereis nginx 命令查找名为 nginx 的目录或文件:

whereis nginx

nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

进入 /etc/nginx/conf.d/ 目录,编辑 nginx 的配置文件 —— default.conf,命令 vi default.conf 编辑 default.conf 文件。

vi default.conf

键入i 即可进行编辑。编辑完毕后,点击 esc 后,键入:wq! 并回车,即可保存回到命令行。

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        root   /mysite/resume;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    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;
"default.conf" 46L, 1125C

当访问服务器的 80 端口时,nginx 会进行代理,访问 /mysite/resume/ 目录下的 index.html。(访问服务器的ip时,默认访问80端口。)

查看 nginx 版本

[root@i~]# nginx -v
nginx version: nginx/1.14.1

相关文章

网友评论

      本文标题:nginx(一)

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