PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 15, 2022

[FIXED] Ubuntu Lamp php script with mySQL connection not using Apache

 March 15, 2022     bash, cron, lamp, php, ubuntu     No comments   

Issue

Hi I got a strange problem with my LAMP installation

I'm using an Ubuntu Server with PHP5 Apache and mySQL, all runs great when accessing via http.

But the thing is, I also want to trigger some scripts using bash, basically so I can trigger them at will and prevent them being used via Apache/HTTP

The scripts themselves run when called with php5, all includes are found. But for some unknown reason mySQL does not seem to initiate the Database the way it does via Apache. I just get a message back saying no database is connected.

Is there some special setup for bash related php calls?


Solution

Figured it out. There are no special DB settings for PHP run from Bash, However because I work on several Servers I was using the $_SERVER['HTTP_HOST'] variable to determin which login credentials should be used. Therefore it only worked on the server where the default credentials were correct.

For now I just put in an extra option in the code that uses credentials based on the value of the dirname(__FILE__) variable. Works great.



Answered By - dave
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing