Search code examples
laravel-5redhat

run laravel application on red hat


I am trying to run laravel application on RHEL-7.3 for that I have installed apache and php I have uploaded the code inside /var/www/html folder I set the permission of laravel 777 and storage folder 777.

I can run the code using php artisan serve but in error log I get the error

[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

I don't know what permission do I need to put in order to run laravel in red hat.

ls -la inside 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

Solution

  • I found solution for this question it has nothing to do with linux permission. In redhat there is something called SElinux. I disabled SE linux in Redhat and it worked, for that I edited file :/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
    

    I edited SELINUX=disabled and then restart server and laravel will work.