Chimeara's avatar

Moving from local to test server

I have used option 2 on this site https://driesvints.com/blog/laravel-4-on-a-shared-host to move my site from my localhost (Windows WAMP) to an Ubuntu shared server but the views don't seem to be working. I am using var/www/html/blue as my site folder with the recommended .htaccess file.

My routes.php has the following:

Route::get('welcome', function () {
    return view('welcome');
});


Route::get('test', function () {
    return 'Hello World';
});

Going to myserver.com/blue/public/index.php/test returns 'Hello World' but going to myserver.com/blue/public/index.php/welcome shows a blank page. The welcome view works fine locally as http://localhost/public/index.php/welcome , but not on the ubuntu server.

I have set access to laravel and laravel/storage as recomened on http://stackoverflow.com/questions/11981621/starting-with-laravel-on-ubuntu

0 likes
11 replies
frezno's avatar

but going to myserver.com/blue/public/index.php/welcome shows a blank page.

ever tried
myserver.com/welcome
?

and do you have a view.blade.php file created?
With 'Hello World' you are returning a string.
Usinge the welcome-route you are calling a view blade file

1 like
Chimeara's avatar

@frezno

Yep i have the veiw and it worka fine on local machine. Myserver.com/welcome and localhost/public/welcome both don't work. Maybe there is an issue with the .htaccess file in the public folder

Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

StuffedGoat's avatar

Did you use 'php artisan config:cache' before you shift the instance to your server? If yes it migth be that you have problems with old paths in your laravel/bootstrap/cache/config.php file.

Hope that helps a bit.

1 like
frezno's avatar
frezno
Best Answer
Level 36

@Chimeara

Maybe there is an issue with the .htaccess file in the public folder

you should delete the first Rewrite Condition:

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
[...]

but why don't you use Laravels htaccess file?

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule> 

and here:

localhost/public/welcome

you should'nt use the /public folder, ie:

// either
localhost/welcome

// or
localhost:8000/welcome

and last but not least, using the mentioned url, does it work without calling the view blade, ie

Route::get('welcome', function () {
    return 'Welcome aboard';
});
1 like
Chimeara's avatar

@frezno Thanks, i'll give it a try tomorrow when i have access to the machine.

Chimeara's avatar

@frezno

That seems to have done the trick for my local machine localhost/welcome is showing the view as expected and localhost/test shows the expected output.

I have then copied this over to the shared machine but myserver.com/blue/test is showing an error page while myserver.com/blue/public/test is showing the output. furthermore neither myserver.com/blue/welcome (error: page not found) or myserver.com/blue/public/welcome (blank page) are working.

Could it be the .htaccess files are not being used on the shared server for some reason?

myserver.com/blue/.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

I have justchecked /etc/apache2/sites-available/default and it has

<DocumentRoot "/var/www/html">
<Directory "/var/www/html/">
    AllowOverride All
</Directory>

So this should also work for /var/www/html/blue shouldn't it?

Chimeara's avatar

@frezno Yep, just trying to figure out why my .htaccess files on the shared server aren't working.

frezno's avatar

hmmm, the storage folder has to be writable, but i see no need to change the permission to 777 on the vendor folders

Please or to participate in this conversation.