PHP Developers Network
http://forums.devnetwork.net/

Laravel: Newbie questions + Shared hosting (one.com)
http://forums.devnetwork.net/viewtopic.php?f=72&t=144319
Page 2 of 3

Author:  hybris [ Sat Oct 14, 2017 5:11 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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

Author:  Celauran [ Sat Oct 14, 2017 8:35 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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.

Author:  hybris [ Sat Oct 14, 2017 2:33 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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:

Syntax: [ Download ] [ Hide ]
<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

Author:  Celauran [ Sat Oct 14, 2017 3:25 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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?

Author:  hybris [ Sat Oct 14, 2017 3:48 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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
Syntax: [ Download ] [ Hide ]
<?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
Syntax: [ Download ] [ Hide ]
<?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?

Author:  Celauran [ Sat Oct 14, 2017 4:26 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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?

Author:  hybris [ Sat Oct 14, 2017 5:11 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)


Author:  hybris [ Sun Oct 15, 2017 3:31 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

error.log (apache2)
Syntax: [ Download ] [ Hide ]
[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'

 

Author:  hybris [ Sun Oct 15, 2017 4:53 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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 ?

Author:  Celauran [ Sun Oct 15, 2017 7:16 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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.

Author:  hybris [ Sun Oct 15, 2017 8:31 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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
Syntax: [ Download ] [ Hide ]
<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)

Syntax: [ Download ] [ Hide ]
<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
Syntax: [ Download ] [ Hide ]
<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..

Author:  Celauran [ Sun Oct 15, 2017 8:38 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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

Author:  hybris [ Sun Oct 15, 2017 10:02 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

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?

Author:  Celauran [ Sun Oct 15, 2017 10:29 am ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)

Maybe start by undoing that change that forces things to HTTPS just so you can see where things are breaking?

Author:  hybris [ Sun Oct 15, 2017 1:09 pm ]
Post subject:  Re: Laravel: Newbie questions + Shared hosting (one.com)


Page 2 of 3 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/