Laravel directory to welcome page on a VPS - laravel

Before I was in a shared hosting and had no problem installing and accessing (click next next), Laravel welcome page but I have moved to a bare metal VPS and I am having difficulties to get to the Laravel 5 welcome page. My host tells me to upload the framework to the htdocs directory, but that is exactly what I did and where the app et al are found.
This is the URL scenario.
My web VPS by default shows me its own index.html like this
/var/www/virtual/myweb.com/htdocs/index.html
and yes, I can correctly access that index through myweb.com
but, of course, all my views are in their Views folder, like this:
/var/www/virtual/myweb.com/htdocs/resources/views/welcome.blade.php
my routes page (as it is a freshly installed) naturally
Route::get('/', function() {
return view('welcome');
});
and the URL in my config/app.php file
'url' = >env('APP_URL', http://myweb.com');
If I do something like this in the URL browser box of course, I get to the file of Laravel 5 welcome page
http://www.myweb.com/resources/views/welcome.blade.php
but obviously I don't want to show such path
so, I would like to be able to write myweb.com and directly show my welcome.blade.php
Any ideas as to how?

You should point you web server (Apache) to a public directory of Laravel's project. For example:
DocumentRoot "/var/www/virtual/myweb.com/public/"
<Directory "/var/www/virtual/myweb.com/public/">
After rebooting web server normal URLs should work (if you'll set up correct settings).

Related

Laravel website behind the reverse proxy and subfolder?

I have a Laravel website with LAMP stack and host on a ec2 server. I setup the Virtual Host configuration for the host name www.abc.com and it works fine. One day, The client said they want to use their domain to visit the website like www.client.com/abc. They use the reverse proxy to point our ec2 server. The first problem we met is the virtual host has failed and we fixed it by adding server alias setting.
ServerAlias www.client.com
The url has connected to the server correctly and the second problem is coming up. Because of the subfolder of the url www.client.com/abc, all the assets paths are failed. For example, we had fonts, styles and js paths that generated by laravel-mix:
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css",
"/js/login.js": "/js/login.js"
}
Those paths are absolute and it turns to 404 found on the website if we use the mix() helper function to load assets. The rendered url on the blade pages are wrong.
It would be
http://www.client.com/js/app.js
instead of
http://www.client.com/abc/js/app.js
And the fonts loaded from the vendor and styles, which use the relative paths and are converted to absolute as well. So we had to workaround this by adding the option processCssUrls: false to webpack.mix.js.
The third problem is the redirection when user logs in out. The defaults redirect url is /. I know we can change the redirect urls in middleware and controllers but it feels like so much workaround over this. Is there any better way to solve those problems?
To declare the question again, how to setup a Laravel project behind the reverse proxy with subfolder?
http://www.example.com/laravel

Laravel project custom domain

I am using custom configuration of domain names for my laravel project test as test.local . When I ran this project as test.local in google chrome , it shows laravel homepage. But, when I go to any other routes it shows internal server error.
Can anyone have any solution?
Just add index.php after the url, and then go to specific route
test.local/index.php/login
So in your routes file eg. web.php, do this if you need to, this adds on a domain limitation.
Route::group(['domain' => env('APP_URL', 'test.local')],function () {
//routes...
});
In you .env file, define the app url, you may use https if required
APP_URL=http://local.test
After all, I would strongly suggest you to check you nginx file to see if you are pointing the path to the right one. And also check if index.php is added into the index file property.

config sentinel to work with "public/index.php" in laravel

I have install Laravel in my VPS, and it's working with the "public/index.php" in the url. I had tried lot more to remove this from url but all are failed, and I have to work with this. Currently I am working on the Sentinel authorization package. It's installed successfully but after login or when i click on the sentinal logo I always get redirected to the "http://myipaddress/tmb/" which is incorrect, so where I can set the home link so that it goes to the "http://myipaddress/tmb/public/index.php/". My laravel version is 5.1.20
The default config for the target URLs is the 'home' route. So you have to setup this route in your routes.php properly.
You can override the default routes in the config/sentinel.php file.
But anyway, it's very dangerous that anyone can access your whole application code directory. You should either forbid access to all resources which are not in /public directory or (much better) configure/ask your VPS to set the document root to your public directory!

Routing problems with Laravel 5 on BlueHost Shared Server

I am in the Beta stage of a Laravel 5.0 project using BlueHost as the server. I have not finalised the domain so I am using a temporary address as follows:
IP Address/username
In a normal Laravel project the root URL is the domain name of the website and routing starts from there. However, in this environment, I have to adjust the route.php file. For instance, instead of the familiar
Route::get('/', 'WelcomeController#index');
I've had to do this:
Route::get('/username/', 'WelcomeController#index');
With the usual adjustment in the .htaccess to re-route everything to the public Laravel folder, I can use the temporary address and access the welcome page. However, when I start adding security with the Auth controller, the re-directs don't work. When accessing a secure URL, you are re-directed to IP Address/auth/login instead of IP Address/username/auth/login. In the .htaccess file in the public folder I've added:
RewriteBase /username/
with both slashes, but that doesn't help. Does anyone know how to set up a Laravel project with a secure area, secured by the Auth controller which has a URL that includes a second segment?

Laravel 4 subdomain routing on VPS/WHM

I have been trying to get Laravel 4 subdomain routing to work for a couple of hours now and I just cannot seem to figure it out. I have a VPS and I'm fairly new to a lot of VPS concepts.
The domain in question is an account on the VPS - the main domain of the VPS is different. So, main domain is example.com and the account I am trying to get subdomain routing working on is foobar.com - a cPanel account on example.com
I put the following above the document root route on foobar.com's Routes file -
Route::group(array('domain' => '{account}.foobar.com'), function()
{
Route::get('/', function($account, $id)
{
echo $account;
});
});
I was expecting this to output the subdomain entered - for example something.foobar.com would echo something. Instead I get Error code: ERR_NAME_RESOLUTION_FAILED.
Since this is a cPanel account, I tried adding a subdomain in cPanel. This of course creates a directory of the same name as the subdomain in public_html, which is the doc root for that subdomain. When I navigate to the subdomain after adding it in cPanel, it says cannot list the directory.. blah blah.. basically it's an empty directory and the server will not show anything. If I attempt to delete the directory in public_html, I get a generic 500 error.
Clearly I'm missing something, the Laravel documentation either falls short or this type of server configuration requires something else. Help please! Thanks!
Woohoo! I got it working after a little more reading.
I had to log in as root to my VPS WHM control panel and add a wildcard A DNS entry (*) for the domain. Then I modified /etc/httpd.conf and modified the line ServerAlias to *.foobar.com foobar.com. Restarted httpd and viola!
This is awesome!

Resources