Moving Laravel Project to a Sub Directory - php

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.

Related

How to deploy a Laravel-Vue project on shared server (GoDaddy)

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.

How can I upload my local Laravel web project to server?

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

Setup laravel in shared hosting

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.

How to configure laravel to use on hoster One.com

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.

Deploy CakePHP application to webserver

I am having trouble deploying my CakePHP application onto a shared web server. Here's what I've done:
1) I zipped the application from my local machine: application.zip
2) I then uploaded the zip file on to my public_html on the server and extracted it
So now my application sits at www.mydomain.com/application which works fine, but once I move the contents of the application folder onto public_html (so that my application sits at www.mydomain.com) it doesn't load the application properly. It only loads SOME of the links of the home page and none of the styles.
So to sum it up.. the app works fine right after extracting to public_html/application/
But once I move the contents of the application folder to public_html it doesn't work.
How am I supposed to set up the folder structure so that my application sits at www.mydomain.com?
Any help would be greatly appreciated.
I just happened to try deploying a Cake app in the same way to a shared server using CPanel and had exactly the same problem. What I discovered is that somehow (I think when I extracted the zip to the public_html directory there was an empty .htaccess file that didn't want to be replaced) the .htaccess file in the root of the application was empty.
Just make sure the .htaccess file in the root of your application (i.e. in public_html) contains this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Worked fine for me and I'm all set now!
You could also try deleting cache files in app/tmp/cache
Not the folders but the files in the folders

Categories