如何使用PHP在Amazon EC2 Linux AWS服务器上创建文件夹 [英] how to create folder on amazon ec2 linux aws server using php

查看:47
本文介绍了如何使用PHP在Amazon EC2 Linux AWS服务器上创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$structure = '/upload';
if (!mkdir($structure, 0, true)) {
    die('Failed to create folders...');
}

这是我的代码,但是我无法创建目录.它向我显示错误无法创建文件夹".

this is my code, but i m not been able to create directory.it shows me the error Failed to create folders.

推荐答案

我认为您无法使用PHP在根目录中创建文件夹,因为它没有这样做的权限.

I don't think you can create folders in the root directory with PHP as it does not have the permission to do that.

但是,您可能可以做的是通过ssh终端在根目录中创建一个文件夹,并将该文件夹用于您的应用程序

However, what you probably could do, is to create a folder in the root directory through an ssh terminal and use that folder for your application

sudo mkdir /myApp

下一步,设置myApp文件夹的写权限

Next, set write permissions to myApp folder

 sudo chmod -R 777 myApp

随后,您将可以在/myApp中创建上传"文件夹

subsequently, you would be able to create your "uploads" folder in /myApp

这篇关于如何使用PHP在Amazon EC2 Linux AWS服务器上创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆