zoukankan      html  css  js  c++  java
  • 二、nginx搭建图片服务器


    接上篇:Nginx安装手册
    cd /usr/local/nginx/conf/

    配置图片服务器

    方法一、在配置文件server{}中location /{} 修改配置:

     #默认请求
    location / {
       root  /home/ftpuser/www;#定义服务器的默认网站根目录位置
       index index.html index.php index.htm;#定义首页索引文件的名称
    }

    其中:/home/ftpuser/www;为创建FTP服务账户ftpuser的根目录下的www目录

    nignx.conf配置文件的第一行为#user nobody; 把注释去掉,改为root用户:user root,否则会出现无法访问403

    方法二、在http{}内配置新服务

    server {
            listen       8080;
            server_name  localhost;
    
            #charset utf-8;
    
            #access_log  logs/host.access.log  main;
    
            #默认请求
            location / {
                root  /home/ftpuser/www;#定义服务器的默认网站根目录位置
                index index.html index.php index.htm;#定义首页索引文件的名称
               }
            }

    因为需要开始端口号8080,所以要在防火墙中开启8080端口

    [root@localhost ]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT  
    [root@localhost ]# /etc/init.d/iptables save  
    [root@localhost ]# /etc/init.d/iptables restart 


    使用FileZilla进行连接服务器,不能上传图片的解决方式:

        1.将要上传到服务器上的文件夹的权限改为777,如chmod -R 777 /var/images

        2.打开vsftp.config(在home内)【vim /etc/vsftpd/vsftpd.conf】文件进行指定local_root=**(个人设置的路径如/var/images)

        3.server vsftpd restart重启即可

  • 相关阅读:
    android 学习
    android 学习
    阅读笔记《人月神话》1
    android 学习
    android 学习
    android 学习
    android 学习
    android 学习(家庭记账本的开发 6)
    每日日报
    每日日报
  • 原文地址:https://www.cnblogs.com/laoyeye/p/6623315.html
Copyright © 2011-2022 走看看