dpzp5127 2015-05-01 22:15
浏览 157
已采纳

linux(ubuntu)apache www文件夹访问问题

I'm a newbie in Linux, just installed ubuntu 14.04 and wanted to install WAMP (MAMP), I followed a youtube tutorial to install php5, apache2, mysql and phpmyadmin. Installed successfully both http://localhost and http://localhost/phpmyadmin works fine logged in successfully.

now I wanted to add some files and folders to apache www folder which is located at /var/www but cant create files or folders. I'm a Windows user where I usually keep all my PHP work in www folder.

I would like to know if there is a way to use any-other folder as www folder or how to create folders and files in that www folder. I reckon its permission issues, since being a newbie don't know how to fix that.. please help

Regards

  • 写回答

2条回答 默认 最新

  • dongzhen4180 2015-05-01 22:23
    关注

    Ubuntu 14.04 runs apache as user www-data, you can change to this user using the command in terminal (shell)

    sudo su 
    

    This will make you root and have access to /var/www directory, and you will be able to create files and directories. Say you had a directory of images containing img1.jpg, img2.jpg, etc. in say /home/user1/images

    as root you could

    sudo su                      <- change to the document folder
    cd /var/www                  <- change to the document folder
    cp /home/user1/images/ .     <- copy what you need to copy
    chown -r www-data images/    <- give the web server read/write permission to the folder / files
    

    which will let you do access the images via a browser via the url

    http://localhost/images/img1.jpg
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!