Omneya el-meligy
Omneya el-meligy

Reputation: 103

deploying laravel error on shared host

I am deploying my laravel 5.4 project on a shared host using subdomain I installed composer, changed paths of index.php , vendor paths , DB host, username , etc..

I am getting the following error

Fatal error: Uncaught UnexpectedValueException: There is no existing directory at "/storage/logs" and its not buildable: Permission denied in /vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:171

I tried the following commands : php artisan cache:clear php artisan clear-compiled sudo chmod -R 777 storage/ -R

but (composer dump-autoload ) gives an error because php -v is 5 although I am choosing it to be 7 in the cpanel

I tried also setenforce 0

but nothing happened .. can any one help please??

Upvotes: 0

Views: 1746

Answers (2)

Daniel Juric
Daniel Juric

Reputation: 148

This is a Duplicate of: see here

  1. Check in laravel root folder your .env file :

a) Check if you have .env file , if not copy-paste .env.example to .env

b) APP_DEBUG = true (when deploying to a server, after checking your app - change on false)

c) APP_KEY = (these must be empty)

d) Save .env file

e) Run php artisan key:generate

f) Open your website (all another errors server return)

  1. Run composer install

This is my solution for apache2 on Ubuntu 20.4

I assume you already did the Steps from phwt & Taras. These are still necessary.

You need to change:

  • ServerName to your IP Address or Domain
  • DocumentRoot to the Path to your public Laravel directory
  • RewriteCond %{SERVER_NAME} = to your IP Address or Domain

File: /etc/apache2/sites-available/laravel.conf

<VirtualHost *:80>
   ServerName www.mylaravelproject.com
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/laravel/public/

   <Directory /var/www/laravel/public/>
       AllowOverride All
   </Directory>
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mylaravelproject.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

After Saving this run:

sudo a2ensite laravel.conf
sudo systemctl restart apache2

(Optional, but recommended) If you want to use an SSL Cert do: sudo certbot and follow the instructions

Upvotes: 0

bluesky
bluesky

Reputation: 286

php artisan route:clear

php artisan config:clear

php artisan cache:clear

works for me!

Upvotes: 1

Related Questions