nginx配置FastDFS,提交静态页面

4 篇文章 0 订阅
4 篇文章 0 订阅

找到配置文件所在地址,进行编辑

/usr/local/nginx/conf$ sudo vim nginx.conf

在这里插入图片描述

在http部分中添加配置信息如下:

server {
            listen       8888;
            server_name  localhost;
            location ~/group[0-9]/ {
                ngx_fastdfs_module;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
            root   html;
            }
        }

在这里插入图片描述

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
	
		location /static{
			alias /home/ling/pytest/dailyfresh/static/;
		}


        location / {
            # root   html;
			root /home/ling/pytest/dailyfresh/static/;
            index  index.html index.htm;	# 默认页面
        }

启动nginx

启动nginx:sudo /usr/local/nginx/sbin/nginx
重新启动:sudo /usr/local/nginx/sbin/nginx -s reload
查看进程:ps -ef|grep nginx
杀死进程: kill -9 进程id

验证nginx配置文件是否正确

进入nginx安装目录sbin下,输入命令:

sudo ./nginx -t	# 此处不用root账户会报错
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful

在这里插入图片描述

看到如上显示,说明配置文件正确!

./nginx  #打开 nginx
nginx -s reload|reopen|stop|quit  #重新加载配置|重启|停止|退出 nginx
nginx -t   #测试配置是否有语法错误

nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

-?,-h           : 打开帮助信息
-v              : 显示版本信息并退出
-V              : 显示版本和配置选项信息,然后退出
-t              : 检测配置文件是否有语法错误,然后退出
-q              : 在检测配置文件期间屏蔽非错误信息
-s signal       : 给一个 nginx 主进程发送信号:stop(停止), quit(退出), reopen(重启), reload(重新加载配置文件)
-p prefix       : 设置前缀路径(默认是:/usr/local/nginx/)
-c filename     : 设置配置文件(默认是:/usr/local/nginx/conf/nginx.conf)
-g directives   : 设置配置文件外的全局指令
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值