500 Server Error when deploying laravel app in aws - laravel

I have been trying to resolve this error for 2 weeks but have not resolve yet.
I have used all answers related to this issue but have not find any suitable solution for my problem :(
used commands
chmod -R o+w laravel_blog/storage
sudo chmod -R 755 laravel_blog
php artisan key:generate
php artisan cache:clear
php artisan config:clear
sudo chown -R www-data:www-data ./storage
Please help me ||

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)
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

Related

I can see a Laravel 6 intallation in localhost

I was testing a clean Laravel 6 installation to migrate an old Laravel project in one Ubuntu 18.04 environment, no used with PHP projects before.
After install PHP, Apache, Mysql... I test one PHP page OK.
I set the permissioins to 777 in /var/www/html/ subdirectories.
I cloned my old Laravel App to migrate and did one clean Laravel 6 installation.
First, I loaded the default welcome page in Laravel 6. After, I put some routes and views from the old project and tried to load some of then, but I had errors of type:
page don't found
I checked the settings of Apache and if mod_rewrite was available... finally, I run the old project OK, but my Laravel 6 is dissapeared. I can see it in the disk, but if load the http://localhost/laravel/ directory I can't see it.
Edited
Content of /etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What i can suggest you to try is to define one Virtual Host for each project in this way:
Put this (with proper information) inside /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public"
ServerName yourProjectDomain.dev
<Directory "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And inside /etc/hosts put
127.0.0.1 yourProjectDomain.dev
Then check the permission on /var/www/html and each subdirectory (you can use cd /var/www/html && sudo chmod -R 777 * to set everything as readable, writable and executable).
Then clear the cache of the project (delete all the files inside the bootstrap/cache folder).
Then you should be able to access that project just using yourProjectDomain.dev on every browser inside your pc.

This site can't be reached (refussed to connect) laravel project on digitalocean

I install LAMP on my droplet in digital ocean, it did works good but now just tell "this site can't be reached, refused to connection" my IP is 157.230.139.112
My project worked well, however, from one day to the next, that simply appeared. I did not have anything important and decided to delete it and create a new droplet, however the same thing happens, I can make migrations and connect with the bd but only rejects the connection.
I did install composer, all the packages, configure my db and my etc/apache2/sites-enabled/000-default.conf and point to the public folder.
Am I doing something wrong?
Your apache server block might not be pointing to your laravel location correctly.
So, you might try configuring Apahce2 site configuration file for Laravel.
Run the command below to create a new configuration file called laravel.conf
sudo nano /etc/apache2/sites-available/laravel.conf
Copy paste the content below into the file and save it. Remember to replace 'Mywebsite' with your own domain name and directory root location.Remember to point to laravel public folder for security.
<VirtualHost *:80>
ServerAdmin admin#MyWebsite.com
DocumentRoot /var/www/html/MyWebsite/public
ServerName example.com
<Directory /var/www/html/MyWebsite/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the file and exit.
Enable the Laravel and Rewrite Module
Enable the VirtualHost by running ..
sudo a2ensite laravel.conf
sudo a2enmod rewrite
Alternatively, compare your localhost apache serverblock configuration with that on the server, ie. if you are running apache locally

Create a Vhost in Ubuntu 16.04

I have started working in laravel and using lampp. I have watched many tutorials that use a vhost to make user-friendly url. I want to do it on Ubuntu 16.04.
Following tutorial is not working for me:
https://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/basicwebsite/public"
ServerName mywebsite.dev
</VirtualHost>
Setup a virtual host for a Laravel project
First, copy the default configuration file and rename it:
$sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/myVhost
open myVhost.conf file using this command:
$sudo nano /etc/apache2/sites-available/myVhost.conf
Add the directives:
assuming that the Laravel project is in /var/www/html/
ServerAdmin webmaster#localhost
serverName www.myAwesomeLink.com
DocumentRoot /var/www/html/laravel-app/public
<Directory /var/www/html/laravel-app>
AllowOverride All
</Directory>
so now the file will look something like this:
save and close.
Now add an entry in the hosts file:
$sudo nano /etc/hosts
add this line:
127.0.0.1 www.myAwesomeLink.com
save and close.
Enable site and the rewrite mode:
$sudo a2enmod rewrite
$sudo a2ensite myVhost.conf
Restart the server:
$sudo service apache2 restart
Serve the Laravel project:
open the project folder
php artisan serve
this will serve on port 8000 by default
you can also specify the port
php artisan serve --port=4200
Open the browser:
http://www.myAwesomeLink.com:8000
or any other specified port.
Source.
Its not working because the browsers have updated their security terms and policies including SSL certificates over .dev domains. just change your extension from .dev to something else like .localhost or .test.
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/basicwebsite/public"
ServerName dev.mywebsite.test
</VirtualHost>
Also change the extension in /etc/hosts from .dev to .test.
127.0.0.1 dev.mywebsite.test
Also keep in mind to restart the service to load the new added virtual host i.e: restart the Apache server
Hope it helps.
I think you also need to add a host in /etc/hosts. Open the hosts file and add this line:
127.0.0.1 mywebsite.dev
You will need to restart server after this.
1.Create new file under this path /etc/apache2/sites-available/myweb.conf
2.Copy the following to the file
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/html/mywebsite/public
ServerName dev.mywebsite.test
<Directory "/var/www/html/mywebsite/public">
Options All
AllowOverride All
Allow from all
</Directory>
3.Run "sudo a2ensite myweb.conf"
4.Add this line "Listen 80" to file "/etc/apache2/ports.conf"
5.Restart apache server

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??
php artisan route:clear
php artisan config:clear
php artisan cache:clear
works for me!
This is a Duplicate of: see here
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)
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

Zend Framework 2.2.1 on XAMPP

I am trying to install ZendFramework latest version on XAMPP. I added XAMPP directory on environment variables.XAMPP server works properly on 8080 port. After that I installed git and ran below commands respectively:
git clone git://github.com/zendframework/ZendSkeletonApplication.git zendtest
cd zendtest
php composer.phar self-update
php composer.phar install
and I didn't get any error. After that I added these lines to C:\xampp\apache\conf\extra\http-vhosts.conf file:
<VirtualHost *:8080>
<DocumentRoot "C:/xampp/htdocs/zendtest/public"
ServerName www.zendtest.loc zendtest.loc
ServerAlias zendtest.loc
<Directory "C:/xampp/htdocs/zendtest/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
<DocumentRoot "C:\xampp\htdocs">
ServerName localhost
</VirtualHost>
And added this line to hosts file:
127.0.0.1:8080 zendtest.loc localhost
With these adjusments apache server on XAMPP doesn't work. When I press the start button for apache server, XAMPP application doesn't respond. Whenever I restore http-vhosts.conf file, XAMPP works properly. What am I doing wrong?
I am able to notice a typo error in the httpd-vhosts.conf file. Please replace this line <DocumentRoot "C:/xampp/htdocs/zendtest/public" with DocumentRoot "C:/xampp/htdocs/zendtest/public" (remove the preceding angular bracket).
I checked this in my local box Xampp was refusing to start but works fine after removing the angular bracket.

Resources