0

this is the first time that I try to migrate a Laravel application from my local environment to my remote server.

So basically I have uploaded the entire content of my local Laravel 5.4 application into this folder of my remote server:

/var/www/html/HotelRegistration

Then I am trying to opening this URL into the browser (my remote server):

http://89.36.211.48/HotelRegistration/public/

and how you can see the standard Laravel homepage appear (it is expected, I yet have to replace this page with a custom one).

The problem is that in my web.xml file I have declared these routes:

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

Route::get('contact', function() {
    return View::make('contact');
});

Route::post('contact', 'EnquiryController@index');


Route::resource('/registration', 'RegistrationController');

The first one is the one related to the standard Laravel page that works fine, the last one is:

Route::resource('/registration', 'RegistrationController');

and it should handle HTTP GET request toward the /registration by the RegistrationController class, this controller class contains this index() method:

/**
 * Metodo che mostra la pagina di registrazione di un nuovo utente albergatore.
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function index(){
    Log::info('index() START');

    return view('/registration/index');

}

that opening this URL:

http://89.36.211.48/HotelRegistration/public/registration

should show a registration page. But, as you can see opening it I obtain a Not Found error message.

Into the /var/www/html/HotelRegistration/storage/logs/laravel.log file there is nothing, I expected the output of the log putted at the beginning of the previous method controller, so it seems that it doesn't not enter in this method.

The strange thing is that opening the same URL on my localhost system (http://localhost/HotelRegistration/public/registration) it works fine.

I am thinking that maybe it could be a routes problem (maybe some route is missing), if I perform this statment on my local environment:

php artisan route:list

I obtain:

+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method    | URI                              | Name                 | Action                                               | Middleware   |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                |                      | Closure                                              | web          |
|        | GET|HEAD  | activate                         |                      | App\Http\Controllers\RegistrationController@activate | web          |
|        | GET|HEAD  | api/user                         |                      | Closure                                              | api,auth:api |
|        | GET|HEAD  | contact                          |                      | Closure                                              | web          |
|        | POST      | contact                          |                      | App\Http\Controllers\EnquiryController@index         | web          |
|        | GET|HEAD  | errors                           | errors               | Closure                                              | web          |
|        | POST      | registration                     | registration.store   | App\Http\Controllers\RegistrationController@store    | web          |
|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |
|        | GET|HEAD  | registration/create              | registration.create  | App\Http\Controllers\RegistrationController@create   | web          |
|        | DELETE    | registration/{registration}      | registration.destroy | App\Http\Controllers\RegistrationController@destroy  | web          |
|        | PUT|PATCH | registration/{registration}      | registration.update  | App\Http\Controllers\RegistrationController@update   | web          |
|        | GET|HEAD  | registration/{registration}      | registration.show    | App\Http\Controllers\RegistrationController@show     | web          |
|        | GET|HEAD  | registration/{registration}/edit | registration.edit    | App\Http\Controllers\RegistrationController@edit     | web          |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+

that contains this route:

|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |

that should be the route related to the previous index() method of my controller.

But I can found it also performing the same statment on my remote environment:

root@Betrivius-VPS:/var/www/html/HotelRegistration# php artisan route:list
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method    | URI                              | Name                 | Action                                               | Middleware   |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                |                      | Closure                                              | web          |
|        | GET|HEAD  | activate                         |                      | App\Http\Controllers\RegistrationController@activate | web          |
|        | GET|HEAD  | api/user                         |                      | Closure                                              | api,auth:api |
|        | GET|HEAD  | contact                          |                      | Closure                                              | web          |
|        | POST      | contact                          |                      | App\Http\Controllers\EnquiryController@index         | web          |
|        | GET|HEAD  | errors                           | errors               | Closure                                              | web          |
|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |
|        | POST      | registration                     | registration.store   | App\Http\Controllers\RegistrationController@store    | web          |
|        | GET|HEAD  | registration/create              | registration.create  | App\Http\Controllers\RegistrationController@create   | web          |
|        | GET|HEAD  | registration/{registration}      | registration.show    | App\Http\Controllers\RegistrationController@show     | web          |
|        | PUT|PATCH | registration/{registration}      | registration.update  | App\Http\Controllers\RegistrationController@update   | web          |
|        | DELETE    | registration/{registration}      | registration.destroy | App\Http\Controllers\RegistrationController@destroy  | web          |
|        | GET|HEAD  | registration/{registration}/edit | registration.edit    | App\Http\Controllers\RegistrationController@edit     | web          |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+

So what could be the problem? Why on my remote environment this URL (http://89.36.211.48/HotelRegistration/public/registration) seems not to be hanbdled as done in the local one?

What could be the problem? What am I missing? How can I try to fix it?

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • Trying to get laravel to work in a non vhost setup is just a waste of your time. – apokryfos Apr 13 '17 at 11:56
  • @apokryfos the problem is: how can I have a vhost on my remote server? My URL is something like 89.36.211.48 – AndreaNobili Apr 13 '17 at 12:47
  • You need a DNS entry for it and to map that entry to your host ip. It's not free, but your time is probably not free either so it's a tradeoff. – apokryfos Apr 13 '17 at 12:49
  • @apokryfos maybe is a trivial question. How can I obtain a DNS entry? And exactly what have to map? I think that it should map the declared vhost with the IP of my server. Is it? – AndreaNobili Apr 13 '17 at 12:54
  • Usually hosting providers also provide a service to manage (and purchase) DNS entries. e.g. amazon has Route 53 and GoDaddy has their own. If you're in such a hosting then you may need to check if they already do that. – apokryfos Apr 13 '17 at 13:01
  • @apokryfos My is a VPS, can I buy this kind of service from another provider? What have to contain this mapping. I think that should be something like Is it? – AndreaNobili Apr 13 '17 at 13:30

1 Answers1

0

You need to first change the permissions and give the requires permission and run this command

composer install or composer update

Thank you

Ssallah
  • 1
  • 1
  • What kind of permission have I to set? – AndreaNobili Apr 13 '17 at 13:09
  • cd to /var/www/html/ and type chmod -R 755 /HotelRegistration and then type chown -R www-data:www-data /HotelRegistration .. hope this helps – Ssallah Apr 13 '17 at 13:13
  • try and append index.php like this http://89.36.211.48/HotelRegistration/public/index.php/registration hope it helps thank you – Ssallah Apr 13 '17 at 13:41
  • And change your apache directive to DocumentRoot "/var/www/html/HotelRegistration/public/index.php" – Ssallah Apr 13 '17 at 13:43
  • Yes, in this way seems to works but why on my localhost application the URL is 89.36.211.48/HotelRegistration/public/registration and here is 89.36.211.48/HotelRegistration/public/index.php/registration ? What is the difference? – AndreaNobili Apr 13 '17 at 13:43
  • see http://stackoverflow.com/questions/23837933/how-can-i-remove-public-index-php-in-the-url-generated-laravel or http://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url – Ssallah Apr 13 '17 at 13:51
  • @AndreaNobili the difference is only in Apache settings as I've shown in my answer. Composer commands and permissions can't be the reason in any case. Are you seriously considering using URLs like `site.com/HotelRegistration/public/index.php/hotels/1/Berlin-hotels`? Make it right, like it meant to be. Point Apache to the `public` directory. – Alexey Mezenin Apr 13 '17 at 16:04