duanjiagu0655 2012-02-07 17:54
浏览 115
已采纳

在var / www / image目录中启用写权限Ubuntu Server

I'm trying to get my php test upload script to work and was wondering what the command would be to allow files to be uploaded in ubuntu server in the var/www/image directory

  • 写回答

5条回答 默认 最新

  • duanbiao4035 2012-02-07 18:03
    关注
    cd /var/www/image
    

    For file like image you don't need execution permission :

    sudo chmod 664 *
    

    If you have directories inside image and you want to apply permission :

    sudo find . -type d -exec chmod 755 "{}" \;
    

    This will recursively search your directory and chmod 755 all directories only.

    Similarly, the following will chmod all files only (and ignore the directories):

    sudo find . -type f -exec chmod 644 "{}" \;
    

    File name with space case (thanks to Nicklas B)

    find . -type f -print0 | xargs -0 chmod 644
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • douju2012 2012-02-07 17:55
    关注

    cd /var/www

    sudo chmod 775 image

    You'll be prompted to enter the admin password - do so, and hit [return].

    评论
  • douye2020 2012-02-07 18:35
    关注

    What username will be uploading the files? Usually on Ubuntu the Apache web server username is www-data. You can check for sure by finding the web server process in a process list command and seeing which username under which it is running.

    ps aux | grep apache or ps aux | grep httpd should give you that answer.

    Then you will usually want to make that Apache username the owner of the directory and all files and directories within it:

    cd /var/www/image
    # recursively (all subdirs & files) set owner to www-data for current directory
    chown -R www-data .
    

    Ordinarily, the above should be enough, but if for some reason the directory, files or subdirectories do not have write permission for the owner username, that's easily fixed by changing the permissions to add that write access, like this:

    cd /var/www/image
    # recursively add "w"rite permissions for the "u"ser (owner) to current directory
    chmod -R u+w .
    
    评论
  • dounou9751 2014-08-31 18:14
    关注

    Change edit group to www-data

    chown -R (owner):www-data (folder)

    And folder permission to 775

    评论
  • donglu4633 2017-04-28 12:11
    关注

    Change edit group may solve most of the problems of permissions.

    Changing do www-data and set permission to 775.

    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 win10商店接入问题
  • ¥15 java 这种树形框吗
  • ¥40 找同学帮敲Python代码
  • ¥15 MYSQL 订单的商品明细重复计算问题
  • ¥15 微信实时共享位置修改
  • ¥100 TG的session协议号转成直登号号后客户端登录几分钟后自动退出设备
  • ¥50 共模反馈回路的小信号增益
  • ¥15 arduino ssd1306函数与tone函数放歌代码不兼容问题
  • ¥70 0.96版本hbase的row_key里含有双引号,无法deleteall
  • ¥15 诊断性META分析合并效能的检验