I have finished my website with laravel 4. I deploy it to my server and find out that I need to go to : www.example.com/public/ to access the homepage.
How to do the setup to access the home page directly when typing the url : www.example.com? I did a index.php with a header Location etc etc but Laravel didnt like it^^
Thx
You have to change your virtual host to point to /public rather than the root of the Laravel (/) installation
You can usually do this if you have access to your web host's control panel.
actually, it's better practice and laravel intends to, if you change your directory structure.
let's say, your current dir structure is like this
./
www/
app/
public/
bootstrap/
vendor/
change it :
./
app/
www/
bootstrap/
vendor/
see? move up app, bootstrap, vendor etc. then rename public folder to (in this case:) www or whatever directory used by server doc root.
Or, if you really don't want change directory structure, you can simply use this:
return Redirect::to('/public');
Related
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 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/
I am trying to upload my Laravel project onto my web server but not work correctly.
my structure is
public_html/shanto_test/
app
bootstrap
public
vendor
artisan
composer.json
server.php
when I type in browser www.myweb.com/shanto_test
then nothing show.
in that case you'd rather have to type in www.myweb.com/shanto_test/public. since the public folder would be the "document root" of your application.
reference
http://laravelbook.com/laravel-architecture/
You can upload laravel project in cpanel following the steps below:
In the public_html/ folder upload the contents of the public
directory of your laravel project.
In the same dierctory level of public_html upload the all contents
except that of public folder.
Your folder structure on cpanel will look like this:
public_html/
css/
fonts/
js/
...
index.php
app/
bootstrap/
database/
...
routes/
.env
Keeping this structure of folders and sub-folders in your cpanel will get your laravel project running successfully.
There are also alternative ways which involves changing folder paths but this felt the most easiest way to me.
I have laravel4 installed at my webserver in the sub directory laravel4 of my web root. in this web root directory there is another directory called modx which serves a MODX cms. before I had laravel4 installed i could open www.mydomain/modx to get the frontend of the cms. Now it is controled by laravel and I get an error. Web server is an apache2.
Maybe an illustration is better:
webroot /var/www/
│
├--laravel4/ <-serve/process via laravel
├--modx/ <-do not process via laravel
So what do I need to configure the only the laravel4 sub-directory is affected by laravel? is it the .htaccess file?
The best practice and for security sake, you should put laravel folder somewhere else other than web root.
And add a symlink from laravel folder to your web root. For example, execute following in Terminal
ln -s /path/to/your/laravel-master/public /path/to/your/web_root/laravel
I have installed Magento 1.7.0.2 to mydomain.com/mag
(mydomain - is the primary registered domain at my hosting account)
(mag - is any subfolder)
As my website in testing mode, if anything goes wrong, i simply have to delete the “mag” folder and also it does not overwrite any files under public_html.
But if i install on directly to root directly public_html, then it may overwrite few files or folders and if i want to revert any time, then i cannot do that manually.
As i don’t even know the exact folder and file default structure under public_html prior to magento installation.
(I did that once by mistake, that happened)
Now at frontend the site URL will be mydomain.com/mag
But i want, if customers type the http://www.mydomain.com, they will be able to see the LIVE website instead of typing http://www.mydomain.com/mag
How do i do that
Also, will this be OK for SEO part.
Do we need to do this in Magento backend.
or
Do we need to do with hosting company by setting sub-domain type
or
By telling Simple scripts the installation to change the installation folder from mydomain.com/mag to www.mydomain.com
Please do suggest how can i do so.
Regards
In System > Config > Web you will find the following settings for your 'base url'. To update this you will have to perform the following 3 steps:
Step 1: Set the default store to the proper base url
Notice that the base url has the subfolder defined.
Step 2: Set your STORE VIEW base url to the root url
Using your dropdown on the left, change the "Current configuration scope" to your store view [NOT DEFAULT]
To change the base url value, uncheck 'use website' and enter your new base url:
Also, double-check in the same screen that your Session file management cookie path is set to the root folder of your site and that the domain is correct:
Step 3 [also used for multiple store management]
Finally, and this is important, you need to copy the index.php file, .htaccess file, and symlink your media,skin and js folders to your root directory, because they're only available to your subfolder Magento base install right now - we need to let your main domain know where to look for Magento!
From secure shell in your Magento installation directory (in your case, mag) as sudoer:
sudo cp index.php ../
sudo cp .htaccess ../
sudo ln -s js ../
sudo ln -s skin ../
sudo ln -s media ../
Your admin will still be available at yoursite.com/mag/admin.
Edit your index.php file in this main webroot (the file you just copied) and update it around line 45:
$mageFilename = 'app/Mage.php';
Change this to :
$mageFilename = 'cart/app/Mage.php';
Where 'mag' is the subfolder. In your case you'd use the folder named 'mag'. Finally, you need to clear the cache for these changes to take effect.
Step 4: Multi-store [optional]
If you have more than one store, they can all be served this way, but you need to edit the index.php file to give it the correct store code. More info about that can be found here:
http://www.magentocommerce.com/knowledge-base/entry/overview-how-multiple-websites-stores-work
i must say that figuring out how to symbolic link was a hassle and i still couldnt figure it out. All the other steps worked fine except i copied my htaccess and my index.php and i just pasted it to my root. So for those who are having trouble, i found a better solution instead of symbolic link for "media, skin and JS" folders. In your magento admin. System>config under general click web. just change your base skin, media and js to the folder you want them to point to...
ex: {{unsecure_base_url}}cart/skin/
worked for me. Hope it works for anyone with the same problem. Ohh and im using magento 1.8.1 Thanks again #philwinkle