-1

I am setting up a server (instance as you please) in google computer engine; apache, php and composer are working, htaccess has already been activated and is working

The problem is not in php or htaccess, how do I know?

phpmyadmin and the like are working correctly. The htaccess I already tested works, so much that I can access without having to put / public / in the domain

I installed a clean laravel but it does not load on the server

  • 1
    It's `php artisan serve`, not `php artisan server` – brombeer Nov 21 '19 at 00:38
  • no, but this has nothing to do, it's on the web server, it's not locally – Macedo_Montalvão Nov 21 '19 at 00:42
  • this is probably there because I tried to run on the laravel server on another port, to know if the problem is on the apache server. but I tried with a clean laravel, that's not the problem. – Macedo_Montalvão Nov 21 '19 at 00:45
  • What do you mean, "_no_"? A bit confused, are you using Apache as server and it doesn't work? `public` should never appear in your URIs, it should be the `DocumentRoot` of your server/vhost. https://laravel.com/docs/master/installation#web-server-configuration – brombeer Nov 21 '19 at 00:45
  • 2
    But when does that error occur? Looks like you are trying to run a command... – porloscerros Ψ Nov 21 '19 at 00:45
  • public is the default folder for laravel. I installed a clean laravel to know if I messed up, set up htaccess to start in the public folder, but it seems to be just index.php, although php is working. – Macedo_Montalvão Nov 21 '19 at 00:50
  • The error occurs when you try to access index.php, so it says the server can't meet this demand, but I can run an html file, so I don't know what it can be. – Macedo_Montalvão Nov 21 '19 at 00:52
  • Did you set the permissions for /storage and /bootstrap/cache? do you have a .env file with APP_KEY? https://stackoverflow.com/questions/31543175/getting-a-500-internal-server-error-on-laravel-5-ubuntu-14-04 – porloscerros Ψ Nov 21 '19 at 01:01
  • yes, as a matter of conscience, I had already set all permissions, I decided to reset all the lamp stacks, to see what works, although I know that apache and php work – Macedo_Montalvão Nov 21 '19 at 01:09
  • can you post your vhost file /etc/apache2/sites-enabled ? – Chris Richardson Nov 21 '19 at 01:14
  • I can't, but it might not be necessary. Everything absolutely reinstalled (except the OS) had a lot of problems here with php and composer, but now laravel has given a sign of life (with some details). – Macedo_Montalvão Nov 21 '19 at 01:28
  • I gave permission 775 to the / storage folder, so he asked permission from / framework and then asked for / sessions. I gave permission but still requests permission for all other folders that are there! any solution to this (was permission 775 for real, I guarantee)? – Macedo_Montalvão Nov 21 '19 at 01:38
  • 1
    In addition to the permissions you have to set the user:group owners of those directories, www-data is usually the apache user name on ubuntu. Try with `sudo chown $USER:www-data ./storage -R` and `sudo chown $USER:www-data ./bootstrap/cache -R`, or run `ps aux | egrep '(apache|httpd)'` to show what apache is running as. – porloscerros Ψ Nov 21 '19 at 01:44
  • 1
    also not required to work but you want your files to be set to 644. along with @porloscerros comment that should fix things if its a file permission issue – Chris Richardson Nov 21 '19 at 01:49
  • I use these commands to change permissions, which work well for me. Maybe 755 for directories and 644 for files is enough too: `find ./storage -type d -exec chmod 775 {} \;`, `find ./storage -type f -exec chmod 664 {} \;` and `find ./bootstrap/cache -type d -exec chmod 775 {} \;` – porloscerros Ψ Nov 21 '19 at 01:49
  • Guys if logs are being written does that not mean permission to storage at the least is OK? – user3532758 Nov 21 '19 at 01:52
  • @Macedo_Montalvão you indicated on your second comment that the error might not be the most recent one. Can you perhaps share the most recent. On a different note, you might wanna check if APP_DEBUG is set to true in .env during development. Then you don't have to go through log file every time and the error presented on screen will be the current exception and sharing it would better enable us helping you. – user3532758 Nov 21 '19 at 02:00
  • Are the logs being written? The log you posted in the question keeps repeating itself? because that log doesn't seem to make sense. Did new logs appear later? – porloscerros Ψ Nov 21 '19 at 02:02
  • Thanks for the help of colleagues, I put in my answer everything I needed to do in ubunto and apache to solve the issue, if anyone has the same problems as me in the future, already know where to find the solution. – Macedo_Montalvão Nov 21 '19 at 03:27

1 Answers1

0

My problem was a little beyond permissions. the permissions were just part of the puzzle that I had to put together here, but in the end it worked

1º problem with paneil ajenti

I am particularly using the ajenti admin panel, because it is not possible to install cpanel on ubuntu, the fact is that ajenti was causing some clonflits in apache, the solution was to reinstall it with these commands:

sudo apt-get remove ajenti
sudo apt-get install python python-support python-lxml python-gevent openssl python-gevent-socketio python-psutil python-reconfigure python-daemon python-passlib python-requests python-dbus apt-show-versions python-catcher python-exconsole python-ldap python-pil

wget http://realrepo.ajenti.org:8888/ng/debian/pool/main/a/ajenti/ajenti_1.2.23.13_all.deb

sudo dpkg --ignore-depends=python-imaging -i ajenti_1.2.23.13_all.deb

2º problem with apache

Since I need to host multiple domains on ubuntu, with servers in different countries to slow down load times, I had several problems setting up apache. the files look like this:

  • remember to move your site to the / www folder

000-default.config

 <Directory "/www">
        AllowOverride All
 </Directory>

 ServerName 00.00.00.00 #ip

 ServerAdmin webmaster@mydomain.com

 DocumentRoot /www

default

SSLEngine on
SSLOptions  +ExportCertData +StrictRequire
SSLCertificateFile #paste here the certificate path
SSLCertificateKeyFile #paste here the path of the certificate key

<Directory /www>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>

enable mod_rewrite like this: sudo a2enmod rewrite

After the change, run the command on the terminal: sudo systemctl restart apache2.service

3º problem with php & composer

I had problems with php because the files were not interpreted by apache, this was the solution:

sudo apt-get purge php7.3 php7.3-cli libapache2-mod-php7.3 libapache2-mod-php php7.3-mysql phpmyadmin

sudo rm -rf /etc/php7.3

sudo apt-get install php7.2 libapache2-mod-php7.2 libapache2-mod-php php7.2-common php7.2-mysql php7.2-xml php7.2-xmlrpc php7.2-curl php7.2-gd php7.2-imagick php7.2-cli php7.2-dev php7.2-imap php7.2-mbstring php7.2-opcache php7.2-soap php7.2-zip php7.2-intl -y

sudo a2enmod php7.2
sudo systemctl restart apache2.service

In the case of the composer I had problems because I used sudo in the installation, follow solution:

 sudo chown -R $USER. ~
 sudo chown username:group /home/username/.composer
  • To find out which group you use: groups username

4º problem with permissions

the following commands resolved the issue with permission

php artisan cache:clear
sudo chmod -R 777 bootstrap/
sudo chmod -R 777 storage/
composer dump-autoload