在红色帽子上运行laravel应用程序

时间:2017-07-02 14:10:28

标签: laravel-5 redhat

我正在尝试在RHEL-7.3上运行laravel应用程序,因为我已经安装了apache和php我已经在/ var / www / html文件夹中上传了代码我设置了laravel 777和存储文件夹777的权限。

我可以使用php artisan serve运行代码,但在错误日志中我收到错误

[Sun Jul 02 09:15:19.810149 2017] [:error] [pid 10328] [client 182.72.84.254:58880] PHP Fatal
 error:  Uncaught UnexpectedValueException: The stream or file
  "/var/www/html/kyowebservice/storage/logs/laravel.log" could not be opened: failed to open
 stream: Permission denied in

我不知道我需要获得什么许可才能以红帽的方式运行laravel。

ls -la laravel:

 drwxr-xr-x.  5 root     root           98 Jul  2 08:59 .
 drwxrwxrwx.  4 root     root           33 Jul  2 08:59 ..
-rwxr-xr-x.  1 root     root           20 Jul  2 06:38 info.php
drwxr-xr-x. 12 ec2-user ec2-user     4096 Jul  2 08:47 kyolabdemo
-rwxr-xr-x.  1 ec2-user ec2-user 97966762 Jul  2 08:44 kyolabdemo.zip
drwxr-xr-x. 12 ec2-user ec2-user     4096 Jul  2 10:13 kyowebservice
drwxr-xr-x. 13 apache   apache       4096 Jul  2 08:55 laravel

ls -la insdie kyowebservice:

      drwxr-xr-x. 12 ec2-user ec2-user   4096 Jul  2 10:13 .
  drwxr-xr-x.  5 root     root         98 Jul  2 08:59 ..
  -rwxr-xr-x.  1 ec2-user ec2-user   1905 Jul  2 08:05 api
  drwxr-xr-x. 10 ec2-user ec2-user   4096 Jul  2 08:05 app
  -rwxr-xr-x.  1 ec2-user ec2-user   1646 Jul  2 08:05 artisan
  drwxr-xr-x.  3 ec2-user ec2-user     54 Jul  2 08:05 bootstrap
  -rwxr-xr-x.  1 ec2-user ec2-user   1305 Jul  2 08:05 composer.json
  -rwxr-xr-x.  1 ec2-user ec2-user 128082 Jul  2 08:05 composer.lock
  drwxr-xr-x.  2 ec2-user ec2-user    228 Jul  2 10:17 config
  drwxr-xr-x.  5 ec2-user ec2-user     72 Jul  2 08:05 database
  -rwxr-xr-x.  1 root     root        236 Jul  2 10:15 .env
  -rw-r--r--.  1 root     root         31 Jul  2 10:13 .env6
  drwxr-xr-x.  8 ec2-user ec2-user    163 Jul  2 08:05 .git
  -rwxr-xr-x.  1 ec2-user ec2-user     61 Jul  2 08:05 .gitattributes
  -rwxr-xr-x.  1 ec2-user ec2-user    103 Jul  2 08:05 .gitignore
  -rwxr-xr-x.  1 ec2-user ec2-user    503 Jul  2 08:05 gulpfile.js
  -rwxr-xr-x.  1 ec2-user ec2-user  69411 Jul  2 08:05 index.html
  -rwxr-xr-x.  1 ec2-user ec2-user  69411 Jul  2 08:05 index.html.1
  -rwxr-xr-x.  1 ec2-user ec2-user    212 Jul  2 08:05 package.json
  -rwxr-xr-x.  1 ec2-user ec2-user   1026 Jul  2 08:05 phpunit.xml
  drwxr-xr-x.  8 ec2-user ec2-user    191 Jul  2 08:05 public
  -rwxr-xr-x.  1 ec2-user ec2-user   1918 Jul  2 08:05 readme.md
  drwxr-xr-x.  5 ec2-user ec2-user     45 Jul  2 08:05 resources
  -rwxr-xr-x.  1 ec2-user ec2-user    567 Jul  2 08:05 server.php
  drwxr-xr-x.  5 ec2-user ec2-user     46 Jul  2 08:05 storage
  drwxr-xr-x.  2 ec2-user ec2-user     49 Jul  2 08:05 tests
  drwxr-xr-x. 29 ec2-user ec2-user   4096 Jul  2 08:06 vendor

1 个答案:

答案 0 :(得分:0)

我找到了这个问题的解决方案,它与linux权限无关。在redhat中有一种叫做SElinux的东西。我在Redhat中禁用了SE linux并且它工作正常,因为我编辑了文件:/ etc / selinux / config

      # This file controls the state of SELinux on the system.
  # SELINUX= can take one of these three values:
  #       enforcing - SELinux security policy is enforced.
  #       permissive - SELinux prints warnings instead of enforcing.
  #       disabled - No SELinux policy is loaded.
  SELINUX=disabled
  # SELINUXTYPE= can take one of these two values:
  #       targeted - Targeted processes are protected,
  #       mls - Multi Level Security protection.
  SELINUXTYPE=targeted

我编辑了SELINUX = disabled,然后重启服务器,laravel就可以了。