I've created a php application on Openshift. Then I added a MySQL database to my app. Afterward I can see database related variables in SSH shell with env command.
However when I tried to use environment varibles to setup db connection, it does not retrun them to my php code. As a example:
<?php
echo('App: '.$_ENV["OPENSHIFT_APP_NAME"].'<br/>');
echo('Host: '.$_ENV["OPENSHIFT_MYSQL_DB_HOST"]);
OPENSHIFT_APP_NAME returns Application name correctly however OPENSHIFT_MYSQL_DB_HOST is null and host information is not available.
I also restarted my application in console.
As a notice I used WinScp to directly upload my application and I'm not sure if deployment of php application needs anything more or less (like some require stuff)?
Update:
When I checked phpMyAdmin codes, I saw it have a file 'conf.d/passenv.conf' with syntax like this:
PassEnv OPENSHIFT_MYSQL_DB_PORT
My be it help for resolving my problem.
You need to stop and start (NOT restart) your application, since you added MySQL after your application was created.
use the rhc app stop and rhc app start commands.
Related
Amazon AWS have an official template for WordPress configuration file that uses the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'] syntax to set environment variables values to the application. And I have realized that the key in $_SERVER is always equals to a Linux environment variable, that I conveniently can setup in the web console. It would mean that I could also set the same custom variables in my development environment and in deployment make no changes in the code in terms of variables adjustments and neither worry about some configuration file that can be wrongly handled in the deployment process.
But actually, in my development environments the things almost works like this. I an working in a Laravel application, and the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'], as those related to the databases connection works file in the console commands. But, when running the application in a PHP server for development, those same variables does not works, and I receive the Undefined index error.
How does I set my local development environment, so that the local PHP server can understood the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'], fetching variables from the operational system?
Find the location of your local systems php.ini file and update the system variable for the server so that the application can actually see it. Using the command line you have direct access to these types of things because they're loaded into a wrapper, in an application you do not.
Edit: You may also consider using your .env file if it's simply needing to be available to your Laravel app.
What exactly are you trying to set? And what does it get used for?
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?
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.
i read so many similar questions but nothing works with me
im using wamp 2.2 ,Apache 2.0 , PHP V5.3.8
safe_mode=off - disabled_functions deleted from php.ini i'm trying to exec
exec("chrome.exe google.com");
nothing happens and when i try
exec("calc");
the windows shows weird message to execute calc in different user although i changed the user for the apache service to Administrator and i verify the user using
exec("whoami");
where is the problem?
Environment path for CMD and php shell might not be the same.
You either have to give entire path of the file, or export the path of chrome.exe in php first
Also, I believe that chrome.exe opening a page requires XServer, php can't open graphical interfaces in shell. These commands are not passed to actual shell as a parent, so php file can't "launch" applications for you.
Please read specifics of the exec function:
PHP exec Reference
Also try adding 2> errors.txt to see what are the errors if any in the execution of the programme.
--
The program needs to know what X server to connect to, and it needs to have permissions to connect to that server. You specify the X server with the DISPLAY environment variable; this will usually be set automatically if you are running the PHP program from a terminal in
X, or from a GNOME panel or something similar; however, if you are running the PHP script in some other manner, it likely won't know what X server to connect to.
X has various ways of specifying permission to connect to a server, but the most common one is using a file called ".Xauthority" in the users home directory. Because only the user who is logged in at the X server can read this file, they are the only user who can run GUI programs. So, if you start the PHP user as the same user who is logged in at the X server, you shouldn't have any problem with permissions. However, if the PHP program is running as a different user, you will have to give that user permission to access the X server.
Reference: http://bytes.com/topic/php/answers/838364-cant-launch-graphical-apps-php-exec-ubuntu-8-04-system
(I know that link is for linux and won't have exact same solution for Windows, but exec() still needs to know which X interface to refer to)
Stop Apache running as a service.
When windows runs a service it it is not running directly as the user that started the server or manages due to this it could well be starting chrome in a service environment so you wont see it load on your desktop there are 2 ways to get around this
Stop apache service browse to your apache directory and run httpd.exe manualy then try your script it should work or if it is not required to be running though a web request so it not using anything from the browser you can allow it to work with c:\wamp\php\php.exe yourfile.php (your php path should be replaced for c:\wamp\php)
Try PHP script?
<?php shell_exec('notepad.exe');?>
It's working.
I wanted to connect to my server via ssh and run a php script to enter some data into the MySQL databases.
I couldn't do this because I didn't have ssh access.
So instead I'm just going to put a php script into one of my web pages and then put the data in the same folder and then run the php by loading the browser
this seems like a really wierd way to enter data into a database?
but is it ok?
Using a PHP script to execute an SQL script should not be a problem (but be sure to delete both afterwards, just so you don't leave an unvalidated/regulated passage into your database out there).
If your webhost provides a MySQL Admin interface (often phpMyAdmin), you should be able to access that through their Control Panel (often called "cPanel" or "Plesk"). You should be able to upload and execute an SQL file through that interface without installing anything else.
Failing that, you should be able to install Adminer, which is a cutdown version of phpMyAdmin which you can then upload to your server and access through a web browser to, again, upload or copy-and-paste your SQL script into.
So you are basically rebuilding phpMyAdmin's behaviour. I would just install phpMyAdmin, but if your php script is protected (.htaccess or similar), then this should be no problem. Look out for timeouts.
A good tool for working with MySQL db is Workbench, but you must have remote access to your db...
I am getting daily data dump via e-mail, which is being processed by Access (based on the Outlook rule, VBA is extracting the attachment and running Access procedures, so I get a report).
As data dump is getting bigger and bigger, and having in mind that Access is run locally which consumes my resources, I want to set up a PHP/MySQL server to make it more efficient.
The first challenge I face is how to connect Outlook rule with PHP execution? (as I will have Outlook set up on the Windows based machine, with apache/mysql set up (WAMP))
Anyone can share some insights on how to start PHP execution from Outlook?
Thanks for the help!
Srdjan
If you have an existing setup using Access and VBA, and you just need a better database behind it, could you not just use MySQL without PHP and use the MySQL ODBC driver instead of the Access connection you are using at the moment (assuming you are currently using ODBC to connect to the access database)
This way you wouldn't even have to have mysql running locally if the hit is too high on your local machine and it should be pretty straightforward in that you shouldn't have to make to many changes to your vba code.
Of course, whether this will do it depends on what else is going on in your access db
If not you could try using php and using the PHP Command Line Interface (CLI) which you should be able to call as an external executable from Outlook. Just pass php.exe the name of the php script you want to run
UPDATE:
I am not a VBA expert by any means but it looks like the shell function would let you run the PHP CLI from within VBA
Shell("path/to/php.exe phpscript.php")
http://msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx
Of course this will only work if you can get to php.exe on the wamp machine (ie is a local machine or you have network access to the appropriate folder)
Alternatively, if the Wamp server is to be a separate machine then you could trigger the php script to be run by calling a url. I think the XMLHTTP object will do this for you
Dim xmh As Object
Set xmh = CreateObject("MSXML2.XMLHTTP")
xmh.Open "GET", "http://urlofphpserver/script.php", False
xmh.Send