php - which one is better to run laravel? -
php - which one is better to run laravel? -
i have installed laravel in cpanel , localhost, found 2 way execute/run laravel.
access/public/
usephp artisan serve
if run in notebook/localhost can utilize php artisan serve , done routing , database, in cpanel cant utilize sec way, must utilize first way, not done routing , etc.
so 1 improve , how create first way run well?
normally, use
php artisan serve
on development environment only.
on production servers, add together <virtualhost> or alias drective in apache configuration.
<virtualhost *:80> serveradmin admin@localhost documentroot /path/to/your/laravel/public servername your.domain.com <directory /path/to/your/laravel/public> allowoverride none order allow,deny allow options followsymlinks rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l] </directory> </virtualhost>
with type of configuration, can access laravel site as: http://your.domain.com/
when using alias, apache configuration this:
alias /any/path/you/want /path/to/your/laravel/public <directory "/path/to/your/laravel/public"> order allow,deny allow options +followsymlinks rewriteengine on rewritebase /any/path/you/want rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </directory>
with configuration, access laravel as: http://your.domain.com/any/path/you/want
on web hosting providers, don't have access apache configuration, in case, have set configuration in .htaccess file within public directory. laravel has default .htaccess file within public directory contains this:
<ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c> options -multiviews </ifmodule> rewriteengine on # redirect trailing slashes... rewriterule ^(.*)/$ /$1 [l,r=301] # handle front end controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule>
you have check if hosting allows .htaccess
php laravel
Comments
Post a Comment