Page 2 of 3

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 5:11 am
by hybris
Ok so I think I set up a gti hook on the server (according to tutorial).

So now Im back on my local computer. Which files shall I include / exclude from GIT? I cant seem to fins a tutorial for this? Anyone got a good link to tutorial for which files to include in git version handling?

(Ofc I understand if I create new controllers, view pages, middleware and so on I need to include those but what files from laravel installation do i need to include)?

Thanks

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 8:35 am
by Celauran
If we're still talking Laravel, it should come with a .gitignore file out of the box. You shouldn't really need to modify it.

For a rule of thumb, don't commit code you don't own (eg /vendor, /node_modules, etc) and don't commit code containing sensitive information (like your .env file). For the latter, it generally makes sense to include a dummy version of that file that represents the structure without the values.

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 2:33 pm
by hybris
Ok so I almost got it working now.. I made a local homepage that i pushed to production server through git (smashes my head against the wall for not using git before..its really cool :)).

So I can see my homepage online.

then I made some text change to welcome.blade on my local server and pushed it to production and it works fine so I thought I had it all setup but then i add auth to my local page and it works fine but when i push it to production I get:
Not Found
The requested URL /login was not found on this server.

same with register - not found

However the welcome to lavarel page was updated with links to login and register in upper right corner..

Do I need to change something in the .htaccess file? Atm my /public htaccess looks like:

Code: Select all

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

    RewriteEngine On

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

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

?
Thanks

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 3:25 pm
by Celauran
Your .htaccess looks mostly the same as mine, so I'm sure it's fine. Have you defined /login and /register in your routes file?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 3:48 pm
by hybris
Nope, i used the php artisan create:auth command on my local and it works fine there.. in git there was some files/folders created that i pused to production server and thats all. I thought it could be some routes problem but when i checked routes on my local it doesn't contain routes to login / register so I thought it wasn't nessecary?

My local web.php

Code: Select all

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

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

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
my production web.php

Code: Select all

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

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

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

I don't get why it would work good on my local but not my production since they look the same?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 4:26 pm
by Celauran
Yeah, I think Auth::routes probably handles the routing for that. Forgot that Laravel provides authentication for free. Have you checked your Apache logs?

I'm assuming that your document root is pointing to /public and that everything else lives above that, is that correct?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sat Oct 14, 2017 5:11 pm
by hybris
Celauran wrote:Have you checked your Apache logs?
Nope only the laravel log but it didn't say anything.
Celauran wrote:I'm assuming that your document root is pointing to /public and that everything else lives above that, is that correct?
Yeah when i type in the browser www.mypage.com its pointing to lavarel/public/index.php

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 3:31 am
by hybris
error.log (apache2)

Code: Select all

[Sun Oct 15 06:25:03.456179 2017] [mpm_prefork:notice] [pid 1580] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Sun Oct 15 06:25:03.456232 2017] [core:notice] [pid 1580] AH00094: Command line: '/usr/sbin/apache2'


Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 4:53 am
by hybris
Ok so i found the missing pages...

i have to add index.php to find them like:

www.mysite.com/index.php/login <- I see the login page

when i go to my site and try login it shows:
www.mysite.com/login <- 404 error

So how do i fix it so i dont have to type in index.php to find the pages ?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 7:16 am
by Celauran
That's definitely an .htaccess issue, then. The .htaccess file looks fine, so I'd recommend checking your Apache configuration. Make sure mod_rewrite is enabled, make sure AllowOverride is set for your DocumentRoot, etc.

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 8:31 am
by hybris
Ok so my folderstructure is:

var/www/html/Test/public/index.php

where Test is the Laravel project folder.

the .htaccess is located in /public/

My apache2:

sites-enabled/000-default.conf

Code: Select all

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName http://www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/Test/public

        <Directory /var/www/html/Test/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
        </Directory>


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =nfoscan.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

000-default-le-ssl.conf (I suspect this is where its wrong or that im missing override)

Code: Select all

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName http://www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/Test/public


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
SSLCertificateFile /etc/letsencrypt/live/nfoscan.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nfoscan.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName nfoscan.com
</VirtualHost>
</IfModule>

I tried to enter

Code: Select all

<Directory /var/www/html/Test/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
        </Directory>
in
000-default-le-ssl.conf but that resulted in internal server error..

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 8:38 am
by Celauran
Unless it's working on HTTP and failing on HTTPS, I wouldn't worry about the SSL config too much. At a glance, the vhost config looks fine to me. I have my Directory in quotes and with a trailing slash, but don't know that that makes a difference. What I'd recommend is to compare it against your local config, since you know that is working. Again, check that mod_rewrite is enabled. You should see that in httpd.conf

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 10:02 am
by hybris
I followed some guide that makes all connection https and its failing on the https.. I havent been able to test http since it always switches to https (I suspect it would work on http but fail on https since 000-default.conf is config for http right? Here I could add the
<Directory /var/www/html/Test/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

but when i try to add this ^^ part into 000-default-le-ssl.conf (which is the config for https right?) i get internal server error... ?

So my guess is I configured rewrite for http but not https ??? But im very new to this all so I might have misunderstood it all?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 10:29 am
by Celauran
Maybe start by undoing that change that forces things to HTTPS just so you can see where things are breaking?

Re: Laravel: Newbie questions + Shared hosting (one.com)

Posted: Sun Oct 15, 2017 1:09 pm
by hybris
Celauran wrote:Maybe start by undoing that change that forces things to HTTPS just so you can see where things are breaking?
Well I spent last 1-2 weeks trying to set it up following different tutorials (Im totally new to DO, Laravel, Unix, GIT ...) So this will be my last option, I dont know what I did when I enabled ssl so I don't really dare to try and remove it now when I'm so close if I mess up.

http://www.mysite/index.php/login is working but i guess that /login works is because of auth:routing instead of .htaccess rewrite right (instead of like /login.blade.php)

I seen some suggestions like

in ssl.conf put the following:

Code: Select all

<Directory /var/www/html/Test/public/>
   AllowOverride All
</Directory>
Does anyone know where to enable AllowOverride All for a directory when using ssl? (I strongly suspect this is why it is not working)

Edit:
In 000-Default-le-ssl.conf this does NOT give an error:

Code: Select all

 DocumentRoot /var/www/html

        <Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>

It shows my hello world index.php i have in dir html

but when I change to my laravel public I get internal server error

Code: Select all

 DocumentRoot /var/www/html/Test/public

        <Directory /var/www/html/Test/public/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>

If I edit out the <Directory></Directory> part it works that mysite.com show laravel welcome.blade but to reach the links i need to add ...com/index.php/login

So it works to change DocumentRoot to /Test/public but as soon as I try to mess with the <Directory it gives me internal server error?