cannot login - PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

cannot login - PHP

Post by publicGenome »

Hi Members,

I'm a noob in PHP application development. I'm working on application, where I didn't write code, and there's isn't any developer, and, or support whatsoever.

About application:
It's a laravel based.

My machine specs: Mac OSX 10.9
PHP version 5.5.24

browser I'm using chrome.

Apache: Server version: Apache/2.2.29 (Unix)

about mysql and virtual hosts configs:
In

[text]usr/local/Cellar/mysql/5.6.23/my.cnf

datadir=/usr/local/var/mysql/
socket=/var/mysql/mysql.sock[/text]

grep -n "ServerName" /etc/apache2/httpd.conf
164:ServerName localhost

[text]/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/Users/myusername/Sites"
ServerName localhost
</VirtualHost>
[/text]
Hosts information:
less /etc/hosts
127.0.0.1 localhost
Error:
Login Failed

I'm stuck and do not know which log to check in now. And how to fix it.
Any guidance shall be of high value to me here.
Thanks.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

What's throwing the error? The application? MySQL itself? Which version of Laravel?
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Celauran wrote:What's throwing the error? The application? MySQL itself? Which version of Laravel?
Hi Celauran: Thanks for your reply and attention to my post.

I'm unable to figure out the cause (mysql, application) of error.
- Have Laravel installed and in my path.
Laravel version: 5.0.27

- Eclipse PDT, with zend debugger installed.

There's nothing in laravel logs after: [2015-04-21 15:40:20]
(apps->storage->log)

In mysql logs, few lines:
Version: '5.6.23' socket: '/var/mysql/mysql.sock' port: 3306 Homebrew
2015-05-28 12:11:32 1100 [Note] /usr/local/Cellar/mysql/5.6.23/bin/mysqld: ready for connections.
2015-05-28 12:11:32 1100 [Note] Event Scheduler: Loaded 0 events
2015-05-28 12:11:32 1100 [Note] Server socket created on IP: '::'.
2015-05-28 12:11:32 1100 [Note] - '::' resolves to '::';
2015-05-28 12:11:32 1100 [Note] IPv6 is available.
2015-05-28 12:11:32 1100 [Note] Server hostname (bind-address): '*'; port: 3306
2015-05-28 12:11:32 1100 [Note] RSA public key file not found: /usr/local/var/mysql//public_key.pem. Some authentication plugins will not work.
2015-05-28 12:11:32 1100 [Note] RSA private key file not found: /usr/local/var/mysql//private_key.pem. Some authentication plugins will not work.
Last edited by publicGenome on Thu May 28, 2015 12:28 pm, edited 1 time in total.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

Have you checked that your .env file exists? Can you log in to MySQL manually?
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Celauran wrote:Have you checked that your .env file exists? Can you log in to MySQL manually?
I don't know .env file. :(
Any instructions on it might help.

Yes, I'm able to login to mysql manually. Can select database, the user is present in the user table.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

Laravel 5 uses phpdotenv for storing configuration settings. There should be a file called .env in your project root (ie. same directory as app, artisan, etc.) and should look something like this:

[text]APP_ENV=local
APP_DEBUG=true
APP_KEY=BigMess0fNumb3rsAndLe77ers

DB_HOST=localhost
DB_DATABASE=whatever
DB_USERNAME=username
DB_PASSWORD=password

CACHE_DRIVER=file
SESSION_DRIVER=file[/text]

.env is in .gitignore, so you may not have one if you cloned the project. Look also for a file called env.example or similar (which you would copy to .env and modify with your settings).
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Hi,

1)
There's no .env file in my folder. :banghead:
I've app->config --> database.php there. It has hard coded :
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'Database_Name',
'username' => 'userName',
'password' => 'SOMEpassword',
'charset' => 'utf8',
Can this be the root of error?

2)
I have two my.cnf file:

/usr/local/opt/mysql/my.cnf

and /usr/local/Cellar/mysql/5.6.23/my.cnf (I added datadir, and socket today in it)
Both have:

datadir=/usr/local/var/mysql/
socket=/var/mysql/mysql.sock

I'm unsure if this is causing an error.
Celauran wrote:Laravel 5 uses phpdotenv for storing configuration settings. There should be a file called .env in your project root (ie. same directory as app, artisan, etc.) and should look something like this:

[text]APP_ENV=local
APP_DEBUG=true
APP_KEY=BigMess0fNumb3rsAndLe77ers

DB_HOST=localhost
DB_DATABASE=whatever
DB_USERNAME=username
DB_PASSWORD=password

CACHE_DRIVER=file
SESSION_DRIVER=file[/text]

.env is in .gitignore, so you may not have one if you cloned the project. Look also for a file called env.example or similar (which you would copy to .env and modify with your settings).
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

publicGenome wrote:I've app->config --> database.php there.
Sounds like a Laravel 4 project, then. Directory structure is different in 5 and app/config/ no longer exists. Check the environment setting in bootstrap/start.php and look for a matching database configuration file (ie. app/config/local/database.php)
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Celauran wrote:
Sounds like a Laravel 4 project, then. Directory structure is different in 5 and app/config/ no longer exists. Check the environment setting in bootstrap/start.php and look for a matching database configuration file (ie. app/config/local/database.php)
Hi,
Now this is something new. :P It's an old application. :mrgreen:
I couldn't find any mention of database in bootstrap/start.php .

There's no app/config/local/database.php
I've app/config/database.php Is that what you wanted to point to?

However, I've something in bootstrap/start.php
$env = $app->detectEnvironment(array(

'local' => array('jackie.something.org'),

));
I'm not working on jackie, it was application's test environment. I'm on local of my machine.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

It cascades. If app/config/local/database.php exists, it will be used. It it doesn't, it will fall back to app/config/database.php

What I've done previously is something like this

Code: Select all

$env = $app->detectEnvironment(function() {
	return getenv('APP_ENV') ?: 'local';
});
which will return local unless you've specified APP_ENV
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

Something else I've been thinking; how did you install Laravel? You mentioned a very specific version of Laravel, but one that doesn't match with the project's directory structure. Have you run composer install / composer update?
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Hi Celauran,
Celauran wrote:Something else I've been thinking; how did you install Laravel? You mentioned a very specific version of Laravel, but one that doesn't match with the project's directory structure. Have you run composer install / composer update?
I installed laravel using composer.
/usr/local/Cellar/composer/1.0.0-alpha9/bin/composer
composer global require "laravel/installer=~1.1"

The structure I mentioned must be screwed up. Previous developer(s) messed a lot with entire application. I'm not surprised if the laravel hierarchy is broken. :P
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cannot login - PHP

Post by Celauran »

Hence the 5.0.27 install for a project that needs 4.x. I'd try cloning the project into a separate directory and just running composer install. Skip the Laravel installer entirely (as it's only really handy for starting new projects)
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

Hi Celauran,

Thanks for your patience and guidance.
Celauran wrote:Hence the 5.0.27 install for a project that needs 4.x. I'd try cloning the project into a separate directory and just running composer install. Skip the Laravel installer entirely (as it's only really handy for starting new projects)
I do not know how to do this. I'll check out.
My question:
1) Won't 5.X laravel work with the application I've?
2) Laravel version I installed is global.
Above you've mentioned to have a separate for my application, thus, I'm now not sure what and how should I be doing.
It was a pain to install laravel 5.X with composer, etc, back. :cry:
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: cannot login - PHP

Post by publicGenome »

I only, copy pasted the folder (application code) (more than 1.5 months back) and opened it in eclipse. Trying to log-in into the application/server. This is the only thing I've done until now apart from setting up local hosts, mysql installation, composer, phpmyadmin, laravel installation. Installation, setups itself took a huge amount of time. :|
Post Reply