Laravel 4 application does not write to files

Asked

Viewed 20 times

0

I have an Apache server installed in the Centos 7 Operating System and an application built through the Laravel 4.2 Framework, I have already changed the permissions of the system directories with the command:

sudo chmod -R 777 /var/www

But still the application is not able to write in its directories, returning the following error:

Mensagem de erro ao rodar aplicação no navegador

I do not understand why it is not working, write permissions were given to directories.

inserir a descrição da imagem aqui

1 answer

2

I figured out what was blocking write access in directories, it’s about Selinux, an implementation of the architecture MAC (Mandatory Access Control) for Linux that provides security policies on all cases.

Then it is necessary inform at the Selinux the directory that Apache will be using with the command:

sudo chcon -R -t httpd_sys_rw_content_t /var/www/Questionnaire/app/storage

Apache should be able to write in the Storage directory smoothly.


Although unsaved (for security reasons), it is also possible to disable the Selinux, following the steps below:

01. Check the status of Selinux.

$ sestatus

02. Disable Selinux only in current session.

$ sudo setenforce 0

03. Disable Selinux permanently.

03.01. Open the Selinux configuration file for editing

$ sudo vi /etc/selinux/config

03.02. Change the definition SELINUX for disabled.

SELINUX=disabled

03.03. Save the file and restart the operating system

$ sudo shutdown -r now

03.04. After restarting check the status of Selinux, it should be listed as disabled.


References:

  1. https://linuxize.com/post/how-to-disable-selinux-on-centos-7/
  2. https://en.wikipedia.org/wiki/Security-Enhanced_Linux
  3. https://tecadmin.net/install-laravel-framework-on-centos/
  4. http://gesielbernardes.eti.br/configurar-selinux.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.