Laravel error page not showing when using virtual host - php

I install new laravel package through composer and everything is going fine (including the error page) when I use php artisan serve and access my project in http://localhost:8000. But when I use virtual hosts (for example: example.dev), the error page is not showing, just a blank page. I'm not sure if it has something to do with my virtual host configuration because if the code has no error, the page just load normally. And I have changed the permission of storage and bootstrap/cache folder to 777.
Is there any other configuration that have to do?

Which PHP version do you use on your server? Check the logs and see if you find something there.
Try giving the entire Laravel folder 755 permissions and then change the bootstrap/cache and storage folders.
Also try editing your .htaccess file, add something like:
RewriteEngine On RewriteBase /

Related

Laravel controllers not working in another computer

I just copied my laravel project from one pc into another. I changed the .env file accordingly for new domain url (it's in localhost bytheway).
However when I click the links, namely login, register, they say the requested URL not found on this server.
I tried to run php artisan serve command, but it says
[Error Exception] No such file for directory.
But the artisan file is there. I'm afraid the domain still pointing to previous one, hence the error.
Is there anywhere else I need to change the pointing url?
After copying the directory you should always run composer update secondly make sure you have.
i fixed it by enabling module rewrite option in apache extension in WAMP

Symfony deployment on heroku points to app folder

I am trying to deploy the symfony app on heroku and I am able to update the schema and all perfectly fine however when i try to access the site I get
Forbidden
You don't have permission to access / on this server.
So using the command heroku logs --num 10 i can see the error
Cannot serve directory /app/web/: No matching DirectoryIndex
(index.php,index.html,index.htm) found, and server-generated directory
index forbidden by Options directive
As you can see heroku is trying to access /app/web/ rather than just web, because of this even my assets are being access via app/web/css which is ofcourse wrong.
So how can i get rid of this app? I do not understand why Heroku is even pointing at that.
I have gone through the steps mentioned in Symfony documentation over and over and I cant seem to find out what I am missing?
The Procfile seems to be point to web so where is this app coming from?
web: vendor/bin/heroku-php-apache2 web/
I have gone through other articles online like the one as following but nothing seems to be fixing my problem.
Symfony on Heroku: 403 Forbidden You don't have permission to access / on this server
Any help will be really appreciated.
On Heroku you need to create the .Procfile and upload that or create the app.json Schema file and then based on that Heroku will create the .Procfile for you automatically, here you can see the app.json example for Symfony app.
Another thing that needs to be crossed checked is make sure in your public directory the .htaccess file was also uploaded. In Symfony the public directory is the web folder and in my case the .htaccess file was missing.
After making sure of the above two steps my app works perfectly fine on Heroku.
Use /web/ instead of web/: add the leading slash!
Your Procfile file should contain this:
web: vendor/bin/heroku-php-apache2 /web/
Note the leading / in the path to the web folder!

how to access the laravel project after installation?

I have installed the laravel 5 on my local machine.And made the changes in the database.php file in config folder.I have set my credential.Now I am accessing the folder http://localhost/laravel/public/ but it displays html page with this content. Whoops, looks like something went wrong.What configuration should I set apart from this database.php so that it works fine.
This will likely happen to you everytime you create a new Laravel project. The problem is that your webservice (apache/nginx) doesn't have read/write permissions for the storage folder. From the root of your installation perform a chmod 777 -R ./storage and that should get you to the welcome to Laravel screen you should expect for an installation, and from that point on you should now get the error reporting if you have debug mode set as true. If you are still having trouble, you may need to provide access to the ./public folder as well.
You can run laravel application when you have successfully installed in your machine, Add '/public' in url after root folder. Means you have installed app on www.firstlaravel.com and your root folder is 'first'.
So you can run app using like => www.firstlaravel.com/public

Laravel can't go to projects url when move it on live server

Maybe some one know the solution for my problem.
In localhost all works fine.
I bought vps server, install Ubuntu, and LAMP stack in it.
And now copy all files from localhost to live server, threw ftp.
I write ip/public in web browser and I see my projects mine path running well, but if I wanna go to url like ip/public/login it throws 404 error. (Now working only public address)
.htaccess in public folder is good.
Now I find If I write ip/public/index.php/login it works well, but I need that it work like in localhost
Try making a symbolic link to your public folder and using that as the URL of your project. For example, I have a project called inspections in my /var/www/html folder. If I try to access http://url/inspections I get an error:
403 Forbidden: You don't have permission to access /inspections/ on this server.
However, after calling this command:
ln -s /var/www/html/inspections/public /var/www/html/insp
And navigating to http://url/insp the page displays properly and everything works fine.
Another thing to keep in mind is that app/storage need to have write access (at least) in order for Laravel to work properly. I usually just do:
sudo chmod 777 -R app/storage
To activate all privileges and go from there. Hope that helps!
Also did you check if mod_rewrite is enabled on this server?
Maybe Overwrite is not defined for this folder?
Try:
<?php in_array('mod_rewrite', apache_get_modules()); ?>
Or this:
<?php die("Enabled: ". strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false); ?>
And check if Allowoverride is enabled in your virtual host file.
The location of the file depends on the operating system and structure.
It should look a little like this:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

Laravel setup on HostGator shared plan

I'm trying to setup Laravel on a HostGator shared plan. I've followed these instructions:
http://laravel.io/forum/02-13-2014-how-to-install-laravel-on-a-hostgator-shared-server
I created and uploaded the .bashrc and .bash_profile files as instructed, then I run:
source ~/.bashrc
in the terminal, but then when I run php -v I get
No such file or directoryphp
I also tried uploading an htaccess file with AddHandler application/x-httpd-php55 .php to the root directory. When I run phpinfo() now, it shows php version 5.5.10, but php -v (before I run the source command) still shows version 5.2.17.
Any idea what I'm doing wrong?
STEP 1 Copy your files
Copy your app in a non-public folder, example:
/home/foo/myapp
Move your public folder to a public folder, example:
/home/foo/public_html/public
Open your public/index.php file and change paths to reference your laravel non-public code, example:
require __DIR__.'/../../../myapp/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../../myapp/bootstrap/app.php';
STEP 2 Change php version in Cpanel
For laravel 5.2 you need at least php 5.5
https://laravel.com/docs/5.2/installation#server-requirements
this will add some lines in your .htaccess, for example, this will enable php7:
# Use PHP70 as default
AddHandler application/x-httpd-php70 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php70/lib
</IfModule>
STEP 3 Make artisan work
php command line may not work, run this command to check php version:
php -v
if it doesn't give you the correct version you may run your commands directly with php 5.6 binary, like this:
/opt/php56/bin/php artisan
STEP 4 clear caches
Sometimes you need to clear your cache, there's two ways:
With artisan:
/opt/php56/bin/php artisan optimize
Manually:
Delete this two files
bootstrap/cache/compiled.php
bootstrap/cache/services.json
How to use SSL
Hostgator shared servers have a shared SSL certificate
To use the shared SSL certificate you must access your public folder by the root of your server and your username like this:
https://gator1234.hostgator.com/~username
So for example, if you put your application in a folder called myapp it will become:
https://gator1234.hostgator.com/~username/myapp
this will mess the routes file, so you have to add this lines to your .htaccess
RewriteEngine On
RewriteBase /~username/myapp
I recently wrote an article on how I was able to host my laravel 5.5 on a shared host. (Hostgator)
https://www.5balloons.info/hosting-laravel-5-5-project-on-shared-hosting-hostgator/
So there is one simple step that seems to get overlooked with most of the issues of setting up a subdomain to host a Laravel App using HostGator's Shared Hosting plan.
HostGator Shared Server Hosting Plan
Scenario:
Domain: https://yardpenalty.com is pointing to the home/username/public_html folder which has a WordPress installation.
Subdomain: https://games.yardpenalty.com is pointing to the home/username/games/public folder which has a Laravel App installation.
Problem:
We want the Laravel App to be accessed at the Subdomain's root level...
URI at https://games.yardpenalty.com
NOT at https://games.yardpenalty.com/public.
Solution:
Step 1:
Under our HostGator Shared Server Hosting Plan we can access the tools we need using cPanel.
Step 2:
In our cPanel we go-to Domains->Subdomains and we enter a name for our Subdomain (in this instance its called games).
Step 3:
Then we select a Domain from the dropdown list and in this scenario it is yardpenalty.com which is pointing to my public_html folder.
Step 4:
Finally, under the Document Root / (a.k.a. home/user) we point it to the /games/public folder!
It should look something like the second listing from your cPanel:
I was finally able to get Laravel installed with some help from this:
http://shincoding.com/laravel/installing-configuring-laravel-shared-hosting/

Categories