You are not logged in.
Pages: 1
Hi,
I've encountered with this problem several times and tried different solutions. But, solutions which I tried don't work for all situations. Because some shared hostings can be too strict. For example, your hosting provider may not let you to reach your home directory because of the some security concerns (really don't understand why but I've encountered). On this situation you can't place the laravel working and system directories (I mean except public in root) as a sibling of public directory. They should be in public like I will show below. But before that, I should indicate this method may not be secure. (Actually if you write your opinion about security of the method, It will be great.)
Step 1: First of all, we gather application, bundles, laravel, storage directories, paths.php and artisan in a different directory which we named as larasys (It will be better, if you use different name).
map of directories:
- public
-- larasys
--- application
--- bundles
--- laravel
--- storage
--- paths.php
--- artisan
-- index.phpStep 2: Create a .htaccess file in larasys like below:
deny from allThis will prevent direct access to larasys directory.
Step 3: Then we place larasys in the public (probably in shared hosting you should rename this too. htdocs, public_html, for example) folder.
Step 4: Now we configure our php files. First of all, index.php in public fires the laravel by using paths.php and we changed directory of the paths.php. Because of the fact that, we should change the index.php like below:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @version 3.2.13
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
*/
// --------------------------------------------------------------
// Tick... Tock... Tick... Tock...
// --------------------------------------------------------------
define('LARAVEL_START', microtime(true));
// --------------------------------------------------------------
// Indicate that the request is from the web.
// --------------------------------------------------------------
$web = true;
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require 'larasys/paths.php';
// --------------------------------------------------------------
// Unset the temporary web variable.
// --------------------------------------------------------------
unset($web);
// --------------------------------------------------------------
// Launch Laravel.
// --------------------------------------------------------------
require path('sys').'laravel.php';Step 5: As you realize, we don't touch place and name of application, laravel, bundles, storage directories. But actually we changed the public. Because of this, we should change paths.php. In brief, we will just change the $paths['public'] = 'public' to $paths['public'] = '..' , full content of file is below:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @version 3.2.6
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
*/
/*
|----------------------------------------------------------------
| Application Environments
|----------------------------------------------------------------
|
| Laravel takes a dead simple approach to environments, and we
| think you'll love it. Just specify which URLs belong to a
| given environment, and when you access your application
| from a URL matching that pattern, we'll be sure to
| merge in that environment's configuration files.
|
*/
$environments = array(
'local' => array('http://localhost*', '*.dev'),
);
// --------------------------------------------------------------
// The path to the application directory.
// --------------------------------------------------------------
$paths['app'] = 'application';
// --------------------------------------------------------------
// The path to the Laravel directory.
// --------------------------------------------------------------
$paths['sys'] = 'laravel';
// --------------------------------------------------------------
// The path to the bundles directory.
// --------------------------------------------------------------
$paths['bundle'] = 'bundles';
// --------------------------------------------------------------
// The path to the storage directory.
// --------------------------------------------------------------
$paths['storage'] = 'storage';
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = '..';
// --------------------------------------------------------------
// The path to the upload directory.
// --------------------------------------------------------------
$paths['upload'] = $paths['public'].'/files';
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// END OF USER CONFIGURATION. HERE BE DRAGONS!
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// --------------------------------------------------------------
// Change to the current working directory.
// --------------------------------------------------------------
//define('__DIR__','/home/hediyemi');
chdir(__DIR__);
// --------------------------------------------------------------
// Define the directory separator for the environment.
// --------------------------------------------------------------
if ( ! defined('DS'))
{
define('DS', DIRECTORY_SEPARATOR);
}
// --------------------------------------------------------------
// Define the path to the base directory.
// --------------------------------------------------------------
$GLOBALS['laravel_paths']['base'] = __DIR__.DS;
// --------------------------------------------------------------
// Define each constant if it hasn't been defined.
// --------------------------------------------------------------
foreach ($paths as $name => $path)
{
if ( ! isset($GLOBALS['laravel_paths'][$name]))
{
$GLOBALS['laravel_paths'][$name] = realpath($path).DS;
}
}
/**
* A global path helper function.
*
* <code>
* $storage = path('storage');
* </code>
*
* @param string $path
* @return string
*/
function path($path)
{
return $GLOBALS['laravel_paths'][$path];
}
/**
* A global path setter function.
*
* @param string $path
* @param string $value
* @return void
*/
function set_path($path, $value)
{
$GLOBALS['laravel_paths'][$path] = $value;
}That's all. No more step. I tried it works but I might have forgetten to mention something. If you meet some error and unexpected situation, please comment.
Thanks for your attention.
Last edited by bllim (2013-01-27 00:38:04)
Offline
i try your setting and get these error
Warning: require(J:\AppServLive\www\laravel\laravel\ioc.php): failed to open stream: No such file or directory in J:\AppServLive\www\laravel\system\laravel\core.php on line 45
Fatal error: require(): Failed opening required 'J:\AppServLive\www\laravel\laravel\ioc.php' (include_path='.;C:\php\pear') in J:\AppServLive\www\laravel\system\laravel\core.php on line 45please help
Offline
Are you sure you edit index.php and paths.php correctly?
Offline
sorry my bad ![]()
i delete all files, extract laravel again copy your configuration, and its ON, thx
Offline
Hi,
I got an error following your post.. i checked the paths.php and index.php files and its same as what you did..
heres the error :
Unhandled Exception
Message:
Undefined offset: 6
Location:
/usr/lib/php/head.php on line 90
Thanks in Advance..
Offline
This may not be related to changing directory structure or index.php/path.php. Can you give more information. For example what is there in /usr/lib/php/head.php on line 90 ?
Offline
I dont know whats in there.. its not accecible by my account.. im on a shared host..
Offline
That's a weird exception
. I can't really estimate what is the reason behind the error. Undefined offset 6 means there isn't any member of array which its key is 6. But because we can't see the head.php, Thats all what I can say
.
I would suggest you report this your hosting provider. At least they can see head.php
.
Offline
Hi,
I've encountered with this problem several times and tried different solutions. But, solutions which I tried don't work for all situations. Because some shared hostings can be too strict. For example, your hosting provider may not let you to reach your home directory because of the some security concerns (really don't understand why but I've encountered). On this situation you can't place the laravel working and system directories (I mean except public in root) as a sibling of public directory. They should be in public like I will show below. But before that, I should indicate this method may not be secure. (Actually if you write your opinion about security of the method, It will be great.)
[snip]
That's all. No more step. I tried it works but I might have forgetten to mention something. If you meet some error and unexpected situation, please comment.
Thanks for your attention.
I use your way. but I get error like this :
Unhandled Exception
Message:
Class 'PDO' not found
Location:
/home/mysite/public_html/web/application/config/database.php on line 31please help me....1 month I deploy laravel on shared hosting...with no solution.
Let's Visit Indonesia
You will not be disappointed, come!!!, even once in your life or you'll regret it.
Offline
Laravel requires PDO library. Are you sure PDO library is installed on your hosting? You can check it by writing this:
<?php new PDO(); in a file outside of laravel and running it.
Offline
Hi.
I've just fallowed this method and I got this error; I also did it on my local enviroment and got the same error. Using Laravel 3.2.14
Unhandled Exception
Message:
Error rendering view: [users.index]
Undefined variable: users
Location:
/home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/storage/views/0c70ee5cce2d0d833e43cbca6be998c1 on line 7
Stack Trace:
#0 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/laravel.php(42): Laravel\Error::native(8, 'Undefined varia...', '/home/vol8/byet...', 7)
#1 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(386) : eval()'d code(7): Laravel\{closure}(8, 'Undefined varia...', '/home/vol8/byet...', 7, Array)
#2 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(386): eval()
#3 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/blade.php(71): Laravel\View->get()
#4 [internal function]: Laravel\{closure}(Object(Laravel\View))
#5 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/event.php(199): call_user_func_array(Object(Closure), Array)
#6 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/event.php(138): Laravel\Event::fire('laravel.view.en...', Array, true)
#7 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(348): Laravel\Event::until('laravel.view.en...', Array)
#8 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(590): Laravel\View->render()
#9 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/response.php(268): Laravel\View->__toString()
#10 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/laravel.php(180): Laravel\Response->render()
#11 /home/vol8/byethost16.com/b16_13081292/htdocs/index.php(34): require('/home/vol8/byet...')
#12 {main}
Offline
Hi.
I've just fallowed this method and I got this error; I also did it on my local enviroment and got the same error. Using Laravel 3.2.14Unhandled Exception
Message:
Error rendering view: [users.index]
Undefined variable: users
Location:/home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/storage/views/0c70ee5cce2d0d833e43cbca6be998c1 on line 7
Stack Trace:#0 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/laravel.php(42): Laravel\Error::native(8, 'Undefined varia...', '/home/vol8/byet...', 7)
#1 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(386) : eval()'d code(7): Laravel\{closure}(8, 'Undefined varia...', '/home/vol8/byet...', 7, Array)
#2 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(386): eval()
#3 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/blade.php(71): Laravel\View->get()
#4 [internal function]: Laravel\{closure}(Object(Laravel\View))
#5 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/event.php(199): call_user_func_array(Object(Closure), Array)
#6 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/event.php(138): Laravel\Event::fire('laravel.view.en...', Array, true)
#7 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(348): Laravel\Event::until('laravel.view.en...', Array)
#8 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/view.php(590): Laravel\View->render()
#9 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/response.php(268): Laravel\View->__toString()
#10 /home/vol8/byethost16.com/b16_13081292/htdocs/nucleo/laravel/laravel.php(180): Laravel\Response->render()
#11 /home/vol8/byethost16.com/b16_13081292/htdocs/index.php(34): require('/home/vol8/byet...')
#12 {main}
It is a rendering issue. The error says, you try to use $users variable in users.index view without send it to view.
Offline
Hi. Thanks for the help but why is this working if I run the same code inside a clean instalation, i mean, using the same model, controllers and views without changing the folder structure?
Offline
Can you check steps again ? I changed the structure of directory on a live website. I didn't get anything like these.
Offline
This is what i did. I created a folder inside my public_html called nucleo and uploaded everything but public dir. Then uploaded the js/css/img .htcacces and index.php in public_html; same level as nucleo folder. Next in index.php changed the path route to nucleo/path.php, finally in path.php changed the public variable to "..". I hope you coulld help me. I could give you acces to my hosting since this is a free hosting just for testing.
Thanks for your time
Offline
Hi.
I found what was happening. and bllim you were right. In my routes.php i got this.
Route::get('/', function(){
return View::make('users.index');
});
in my UsersController this:
public function __construct(){
parent::__construct();
$this->filter('before', 'auth');
}
I thought that this part in the controller was going to redirect me to login if the user was not logged in.
the i just changed the route to
Route::get('/', array('before' => 'auth', function(){
return View::make('users.index');
}));
Offline
I'm happy about your problem is solved
. Have a nice day...
Offline
Pages: 1