douyue9704 2017-08-21 12:26
浏览 80

PHP - mkdir许可在数字海洋上被拒绝

I have deployed my Laravel application on DigitalOcean (without any third party packge usage). The application is functioning fine, except for uploading of files by the users.

I have installed LEMP stack by following the guide of DevMarketer (YouTube playlist).

Scenario:

I want to upload the file and store in my public directory. But, doing so, I get the error as Permission Denied.

Here's the code of directory that will get created it if not exist:

$path = public_path() . '/email-attachments/';

if (! file_exists($path)) {
    mkdir($path, 0775, true);
}

On SSHing on to the server as root, I ran the following command to check the permission of the files and folders:

root@host-pc:~# ls -la /var/www/laravel
total 456
drwxrwsr-x 12 www-data www-data   4096 Aug 21 09:45 .
drwxrwsr-x  4 www-data www-data   4096 Aug 18 07:13 ..
-rwxrwxr-x  1 www-data www-data    665 Aug 21 08:23 .env
-rw-rwSr--  1 www-data www-data    521 Aug 21 09:45 .env.example
-rw-rwSr--  1 www-data www-data    111 Aug 21 09:45 .gitattributes
-rw-rwSr--  1 www-data www-data    157 Aug 21 09:45 .gitignore
drwxrwsr-x  8 www-data www-data   4096 Aug 21 09:45 app
-rw-rwSr--  1 www-data www-data   1646 Aug 21 09:45 artisan
drwxrwsr-x  3 www-data www-data   4096 Aug 21 09:45 bootstrap
-rw-rwSr--  1 www-data www-data   1496 Aug 21 09:45 composer.json
-rw-rwSr--  1 www-data www-data 150371 Aug 21 09:45 composer.lock
drwxrwsr-x  2 www-data www-data   4096 Aug 21 09:45 config
drwxrwsr-x  5 www-data www-data   4096 Aug 21 09:45 database
-rw-rwSr--  1 www-data www-data   1063 Aug 21 09:45 package.json
-rw-rwSr--  1 www-data www-data   1100 Aug 21 09:45 phpunit.xml
drwxrwsr-x 10 www-data www-data   4096 Aug 21 09:45 public
-rwxrwxr-x  1 www-data www-data    440 Aug 21 06:27 queue_worker.log
drwxrwsr-x  5 www-data www-data   4096 Aug 18 07:56 resources
drwxrwsr-x  2 www-data www-data   4096 Aug 21 09:45 routes
-rw-rwSr--  1 www-data www-data    563 Aug 21 09:45 server.php
drwxrwsr-x  6 www-data www-data   4096 Aug 18 07:56 storage
drwxrwsr-x  4 www-data www-data   4096 Aug 21 09:45 tests
drwxrwsr-x 39 www-data www-data   4096 Aug 21 05:58 vendor
-rw-rwSr--  1 www-data www-data   1439 Aug 21 09:45 webpack.mix.js
-rw-rwSr--  1 www-data www-data 212974 Aug 21 09:45 yarn.lock

Following is the result of ps -ef | grep nginx

root@host-pc:~# ps -ef | grep nginx
root     14862     1  0 11:45 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 14863 14862  0 11:45 ?        00:00:00 nginx: worker process
root     15489 12952  0 12:19 pts/0    00:00:00 grep --color=auto nginx

Following is the result of ps -ef | grep php

root@host-pc:~# ps -ef | grep php
root     10173  9901  0 05:05 ?        00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root     10174  9901  0 05:05 ?        00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root     10175  9901  0 05:05 ?        00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root     10176  9901  0 05:05 ?        00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root     10177  9901  0 05:05 ?        00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root     10178  9901  0 05:05 ?        00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root     10179  9901  0 05:05 ?        00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root     10180  9901  0 05:05 ?        00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root     15251     1  0 11:50 ?        00:00:00 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
www-data 15255 15251  0 11:50 ?        00:00:02 php-fpm: pool www
www-data 15256 15251  0 11:50 ?        00:00:02 php-fpm: pool www
root     15495 12952  0 12:21 pts/0    00:00:00 grep --color=auto php

I don't know what is the mistake that I am doing (I know it must be a silly one), but I couldn't find the solution yet.

Please help me out with this. Thanks.

  • 写回答

2条回答 默认 最新

  • dongtao6842 2017-08-21 12:47
    关注

    If you change this

    $path = public_path() . '/email-attachments/';
    

    To this

    $path = public_path('email-attachments/');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。