PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Dec 13, 2017 9:34 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Sat Oct 14, 2017 5:11 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 8:35 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 2:33 pm 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 3:25 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
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?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 3:48 pm 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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?


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 4:26 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
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?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sat Oct 14, 2017 5:11 pm 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 3:31 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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'

 


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 4:53 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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 ?


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 7:16 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 8:31 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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..


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 8:38 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
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

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 10:02 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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?


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 10:29 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6402
Location: Montreal, Canada
Maybe start by undoing that change that forces things to HTTPS just so you can see where things are breaking?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sun Oct 15, 2017 1:09 pm 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
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:
Syntax: [ Download ] [ Hide ]
<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:
Syntax: [ Download ] [ Hide ]
 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

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group