I am trying to upload Laravel 5 project to subfolder as:
public_html/project/
I have changed in index.php
require __DIR__.'/../project/bootstrap/autoload.php';
$app = require_once __DIR__.'/../project/bootstrap/app.php';
in config/app.php
'url' => 'http://example.com/project',
when I try url as:
http://example.com/project/public it is directed to
http://example.com/public
What is the way to upload it to server. Can anyone help me as I have tried lot options.
It is not a good idea to upload your entire laravel project in the public_html (public)folder. The files in the public folder are having unrestricted access.
If you are constrained to think about uploading the laravel project to the public_html folder because you want to upload to a shared host, then it is not necessary to do so.
Instead try this:
1. Create a folder called laravel (or anything you like) on the same level as the public_html folder.
Eg:
/
|--var
|---www
|----laravel
|----public_html
2. Copy every thing except the public folder from your laravel project in the laravel folder (on server host).
3. Open the public folder of your laravel project, copy everything and paste in the public_html folder (on server host)
4. Now open the index.php file in the public_html folder and:
Change:
require __DIR__.'/../bootstrap/autoload.php';
To:
requrie require __DIR__.'/../laravel/bootstrap/autoload.php';
And
Change:
$app = require_once __DIR__.'/../bootstrap/app.php';
To:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
Save and close.
5. Now go to the laravel folder and open server.php file
Change:
require_once __DIR__.'/public/index.php';
To:
require_once __DIR__.'../public_html/index.php';
Save and close.
Now when you visit the url which you configured as the domain with your server, your laravel app should work just as it worked on your localhost.
Note: The 'url'=>'someurl' in the config/app is used by artisan ie the cli, it does not have any effect on your webserver urls.
Hope it helps.
Edit
After completing the above if your get a blank page when you try to visit the url, set write permissions for the storage folder recursively .i.e all folders within the storage and its subfolders should have permissions 775 set for the webserver owner and group to have write permission.
You can also set the permissions as 777 to give read, write and execute access to all for the storage folder if you don't plan to store any sensitive information in the storage folder.
Be careful with the file permissions in linux, they are like double edged sword, if not used correctly, they may make your app vulnerable to attacks. For understanding Linux file permissions you can read this
After I completed the above steps. Do check with read/write permissions(i.e it should be 777) for few folcers:
storage, vendor and bootstrap>cache
Check for .htaccess file if it is there in the public_html folder or copy it from public folder.
Finally check the version of php it should be higher than 5.5
It worked for me. Cheers!!
Issue Fixed:-
Go to laravelFolder/bootstrap/cache then rename config.php
eg. config.php_old and reload your site.
I did like this. (My version was laravel 5.2)
Change the name of server.php file to 'index.php'.
Copy .htaccess file from public folder to main directory(Created subfolder)
And inside .htaccess after RewriteEngine On we have to add
RewriteBase /yoursubfolder/
Related
I develop a Laravel Api in local it's work, when I deploy I have a error 500.
I copied the folder to the server.
I moved the public folder to root and changed the path in index.php.
I modify the file .env with the prod value.
With I test with postman my route https://my-domain/public/api/v1/mytest : I have a error 500.
What did i miss ?
Please be sure you have followed all the steps. I assume you do not use a subdomain.
Move your zipped project to a folder in the server (e.x. /home/mollusk/project)
Unzip the project
After unzipping your project, move everything under public folder into public_html folder (e.x. /home/mollusk/public_html)
Edit index.php under public_html folder changing
$app = require __DIR__.'/../bootstrap/app.php';
to
$app = require __DIR__.'/../project/bootstrap/app.php';
Give your domain name as value to APP_URL variable in .env file
APP_URL=https://my-domain
I resolve this problem.
The version lumen in dev and prod was different. I upgraded the dev version (5.8) to be in phase with the server (8.x) and it's work !
I am trying to deploy a Laravel project on shared hosting. I copied the Laravel folder in user's root directory (/home/shrpr) and copied the content of public directory in /home/shrpr/www folder. I modified the index.php in public folder to include "../Laravel" as explained in site. Since, composer is not allowed on this shared hosting, I also copied my local vendor and storage folder along with laravel folder. But I still keep on getting error 500. So, I added a test.php file in the laravel folder and included it in index.php file to test if path and all is correct as under:
require __DIR__.'/../laravel/test.php'; die;
This works fine as the content of test.php is getting displayed properly. So, it looks like some dependencies of vendor folder is missing. Is there a way of identifying and uploading complete dependencies of laravel and uploading it, that is without use of composer?
Try composer update before upload to shared hosting.
Change permissons of your index.php to 644.
Check your enviroment, maybe isn't works.
Wich version of php is running in your shared hosting? and wich is yor Laravel version, change php version to 7.0
Make sure you have PHP 5.5+ installed on the server. Move the index.php file from public to www and change the paths accordingly.
Another way to deploy laravel on shared hosting is to set up your domain as addon domain and then set root folder of the addon domain to the /public folder of the laravel project. eg. home/mili/laravelproject/public
I tried this with godaddy and it worked.
I have the folder into the web server /, where I put all the files/folders except the public folder(with that index.php) of the new laravel project and also in /public_html/ I put all the files from the public folder.
I didn't have to change the paths in bootstrap folder containing 2 files app and autoload, and I did everything as is in the first path in
Uploading Laravel Project onto Web Server
Instead of showing the notorious Welcome to Laravel, it shows nothing.
I am using godaddy web hosting. What I am doing wrong?
Solution:
1.
You have the Home Directory in the web server
/
Which is the parent of Public_HTML folder, here you upload into a folder created by you all the files contenting your laravel project files, folders except the public folder.
In the
/Public_html
You upload all the files containing in the public folder of your laravel project
2. Open the index.php into the public_html and change these things:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
into
require __DIR__.'/../laravelfoldernameinroot/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravelfoldernameinroot/bootstrap/app.php';
3. Make sure to change the php version in cpanel into 5.6, this is obligatory in order the website to work.
4. All other changes depends on changes you made after building the fresh laravel project.
So I am having an issue with pushing a Laravel app to production on a dedicated server's subfolder.
Server is run on Apache.
Url I want to push my app would be subdomain.domain.com/project
The structure of my dedicated server is
.cpanel
...
-laravel
-app
-vendor
-...
-public_ftp
-public_html
-folder
-contents of laravels public directory
-ssl
I know that in order not to expose my hidden files I am required to install it in a root directory, but this is not an option because I will be having multiple projects running under subdomain.domain.com/project-1, subdomain.domain.com/project-2 and etc... and all will have a separate laravel installation.
I need a hand in order to achieve that, can anyone give me some advice?
Managed to do it myself, the problem was when i was creating a symlink, so instead i just moved contents of my public directory to public_html/project-1/ and changed index.php path to /../../laravel/
The thing was that I have done it originally but I didnt expect that permissions for storage need to be manually set, that solved my issue and laravel works.
ALWAYS CHECK ERROR LOGS :)
You can place your separate folders in your subdomain with no problem.
The important thing is that you need to point the browser to public/ folder under your laravel projects.
You can create a .htaccess file with the command below in root folder of each project and perform a redirect.
Place the following command in your .htaccess file:
RedirectMatch ^/$ /public/
I have a GoDaddy web hosting account with a cPanel access. I am trying to figure out where should i upload my php files.
I have created a new folder inside the public_html folder as fortnox_invoicing and have copied all the code (PHP/HTML/JS) files in that folder.
But when i try to browse the php files it doesn't work instead i get "ops, this page does not exist" message.
http://example.com/fortnox_invoicing/index.php
Following is how the public_html directory looks like for now:
You can upload your PHP files in public_html if you want to browse your website like:
http://example.com
You can also upload PHP files in subfolder if you wish to browse it like
http://example.com/subfolder
If you are receiving error 404 while browsing subfolder, locate .htaccess file and check if there is any rules that are restricting index.php to load and causing 404 page. If .htaccess file is hidden, you'll have to enable the show hidden file in while opening cPanel File Manager. Try renaming .htaccess file and load your website again. Also make sure that root folder contains index page and it is listed as default page in .htaccess file.
You see this page because your website doesn't have "index.php" or "index.html" file in public_html folder.
for example
-public_html
-index.php
**-subfolder**
-aboutus.php
-contact.php
-service.php
**-subfolder**
-thankyou.php
Most service providers use the above hierarchy.