I'm trying to setup laravel (5.4.12) in shared hosting. Following this tutorial I had deleted my public_html and created soft-link for public_html to public folder of laravel project. I had successfully setup laravel (5.3.29) following the same tutorial for my previous project. But this time when I try to open base url it downloads index.php file of public directory of laravel folder. Can anyone help me out.
You can do it without deleting public_html folder.
for routing to public forlder just add these lines to .htaccess files
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Normally PHP files are downloaded when the web server isn't configured to serve PHP files. Sounds like you need to talk to your hosting provider.
Finally found the solution. The issue was with PHP version. I had selected PHP version 7.1.0RC4,I changed it to 7.0.12 and the problem is gone.
Laravel 5 setup without artisan serve command
Rename the server.php in the your Laravel root folder to index.php
copy the .htaccess file from /public directory to your Laravel root
folder.
Related
This is the first time I am developing a Laravel Vue app. When I use php artisan serve, everything works fine. But when I load it with http://localhost/myProject/public, assets are not loaded. My images are in img directory inside public folder. I was using blade templating to manage this issue when I use Laravel alone. But now I can't use blade since it is a Vue component. How can I run the project without php artisan serve? My Ultimate aim is to deploy the project in godaddy shared server. Please help me.
Debug your application using 'php artisan serve' while you develop from your local machine.
When you publish it into godaddy,
compress the project folder (say 'my_project') and upload the zip file ('my_project.zip') to 'public_html' directory in godaddy.
unzip the folder.
Now the directory structure will be 'public_html/my_project...'
you will have a 'public' directory inside 'my_project'.
Now create a subdomain which points to the 'public' directory.
That's it. Now load the subdomain.
The assets and api's will work perfectly.
just rungit clone [your_project_address] in the www folder and then run 'php artisan migrate', of course, you should have configured well.
#ThasheelApps this is your solution to access api's.
Create a .htaccess file in root folder and paste the following code there:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This issue occurs many times due index.php in url. if you try your api endpoint including index.php, it will work perfectly. to prevent this issue we need to follow above soution htaccess
Follow these steps:
zip your project after npm run dev and php artisan serve without
any error.
Go to your shared hosting location and outside fo public_html
make a folder name say myproject. Inside this folder extract all
your project files.
cut your public folder from project folder on root, go to your
subdomain folder under public_html and paste.
go to index.php inside public folder and
require DIR.'/../vendor/autoload.php'; and
$app = require_once DIR.'/../bootstrap/app.php'; pointing to your project location on root.
That is all. Enjoy, if you have properly created and attached your DB to your project.
I have uploaded my laravel project on shared hosting and my images will not work.
I have added .htaccess in the root directory and every thing works file except images. My .htaccess file is below.
RewriteEngine On
RewriteBase /
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
My image link is mydomain.com/storage/facilities/May2017/BYKdbdIQCezQ6Gsh05EK.jpg
and it shows
You don't have permission to access /public/storage/facilities/May2017/BYKdbdIQCezQ6Gsh05EK.jpg on this server.403 ERROR
Is this symlink error? I do not have ssh access so is there any way to link storage folder?
Here is the simple solution
you can create symlink using cron job what you have to do is.
1) php (absolute path to artisan) storage:link
like php /home/(yourusername)/public_html/artisan storage:link
OR
2) ln -s /home/(yourusername)/public_html/storage/app/public/ /home/(yourusername)/public_html/public
go to public folder and rename public to storage.
Two things:
1) I recommend you put your images in your assets folder
2) It's common knowledge that Laravel doesn't like you having access to your Storage folder. You can change permissions for it, if need be, but I highly recommend you know what you're doing before you decide what to set it to.
I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....
I am a newbie to Laravel.
I want to upload Laravel project from local to shared hosting server.
Scenario is like below:
I have a site (abc.com).
I want to deploy Laravel project inside this site so that URL will be like abc.com/xyz
I have moved Laravel project files and folders inside xyz folder.
But site is not running.
What paths needs to change and in which files?
Please help.
It will run as abc.com/xyz/public
This can be done, but keep in mind that having the Laravel files in your web server root is not recommended.
How you can accomplish abc.com/xyz:
In folder xyz where laravel is installed you can add this in a .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Again, this setup is not recommended, because the Laravel files should never be in or above your root.
A better way would probably be to install Laravel in the dir below the root and set xyz as your public directory. You would just have to change the paths in index.php to make sure it searches for the Laravel files below your web root.
I recently created a website with laravel 4. I used XAMP to test my website on localhost and to make it easier I created a virtual host in the vhosts file which points to the public folder of my Laravel app. The website is working perfectly.
Now I rented a webspace at One.com hoster. I opened the webspace with ftp and when I came on the "root" but there weren't any folders so I guess that the root location is the public location? I don't for sure.
The normal structure of a Laravel app is like this:
--> app
--> bootstrap
--> public
--> vendor
--> other files
This doesn't work because I think that One.com doesn't use a public html folder. I tried to make it work but unfortunately. I moved the contents of the public folder to the root of my domain and moved all the other folders in a folder named core. Then I changed some config files index.php and paths.php but still it doesn't work.
The question is what do I need to change to my folder structure to let it work on this One.com webserver and which files I need to adapt (.htaccess, paths.php)? I would like to protect my private folders of course.
Thanks in advance.
Just place .htaccess file in the root folder with data below:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
one.com does use a public_html folder because that's where your files are served from. What you can't get to is your home folder. Xampp is a windows package - have you made sure your filenames follow case conventions? Windows being case insensitive, and Linux being sensitive.