Creating a test environment

pfwilliams wrote on Monday, November 05, 2012:

I’ve searched the forums and have been unable to find any detailed instructions as to what is necessary to setup a test OpenEMR environment on the production OpenEMR server.  I would like separate databases and separate copies of PHP source code.  I am hoping the two systems can share the same Apache/PHP/MySQL services.

If this is my lucky day, someone might tell me it is as simple as copying the “xampp\htdocs\openemr” folder to a “xampp\htdocs\test-openemr”, and then renaming the duplicated database, and adding or modifying some values/paths in a few .ini/.cfg files and some control table. 

I have to think that separate OpenEMR systems do not require separate servers, and that someone has done this already?
Thank you very much for your time.

yehster wrote on Monday, November 05, 2012:

Your general strategy of copying the folder should work.

However, it might be easier if  you put a “fresh” copy of openemr in test-openemr which has an “unconfigured” sqlconf.php
When you run through the setup.php scripts, you can specify a test-openemr as the database name and have it create a new clean database.

If you do create a copy of the existing database and rename it, then the file to edit is sites/default/sqlconf.php. Edit the $dbase variable in that file.  I would use mysqldump to export your database, and then you can use mysql on the command line to import it to a new database.  I’ll leave it to you to look up syntax/commands on mysql.com

This is not the strategy I personally use. I create multiple virtual machines in VMWare.  However, I know that Windows is your primary OS, and licensing to create multiple Windows VM instances is “trickier.”  (I run ubuntu server for my VM’s, although everything is hosted under windows.)

pfwilliams wrote on Monday, November 05, 2012:

Thank you for your prompt and detailed reply!
I’m not as well-versed as you in using operating systems other than Windows, multi-OS setups, or creating virtual machines. So, I’ll go with your suggestion of copying in a “fresh” openemr folder and running the initial setup scripts.
That does seem much simpler than trying to chase down and modify every reference to the old path and database names.
Thanks again :wink:

doccbst wrote on Monday, November 05, 2012:

I would agree with yehster, just try out free virtualbox  and use ubuntu server iso or maybe turnkey core ( has webmin built-in) linux debian squeeze
If you want a minimal gui just apt-get install xorg apt-get install lxde  apt-get install firefox and then startx or my favorite "apt-get install gnome-desktop-environment "  then  run the gui , install from bradys openemr deb installer just google “openemr deb” and might find you like linux pretty well. easy openemr install for production or testing no licensing issues.
Will not touch your xampp install and you can run both at once for testing etc.

yehster wrote on Monday, November 05, 2012:

The only reference to the database parameters is in sqlconf.php.  Since you are planning to test import processes IIRC, you certainly want a separate database instance for you test server.  However, at some point, you might want to point your test PHP instance back at your “production database.”

Doccbst,
The drawback of your approach is that OP is a Windows user, and while he can run your virtual appliance in order to do any development he’ll either need to learn to configure samba, or something else for file sharing so he can edit .php files that live on “ubuntu” using the windows development tools he is most comfortable with.  Or he needs to learn gnome and the appropriate dev tools in ubuntu.

The other thing is that OP was at one point trying to determine if there are Windows specific issues with the data loading scripts.  Running under Ubuntu isn’t going to help with that.

While, your VM is generally useful, OP has a specific set of needs that you aren’t addressing.

doccbst wrote on Tuesday, November 06, 2012:

This is just one approach that’s worked for me not sure of intent or needs regarding coding of PHP and actual testing perameters but its sure nice to delete and start over when you hose the application or system as I have done many times. Plus you can clone the vm for backup create snapshots and even clone to a live machine when perfected, just a thought. Plus you can only run one instance of xampp at one time, as I said with a vm u can run both at once xampp and vm.

doccbst wrote on Tuesday, November 06, 2012:

Oops, I forgot to mention  2 things maybe important,
#1 in gnome-desktop-environment samba is included, not sure how this would help
#2 in virtualbox with vitualbox-tools additions you can share a folder with windows host for file sharing,
I don’t usually use virtualbox tools because I’ll just have to uninstall on clone from virtual machine to physical machine  I just email to myself (for small files) or transport files through dropbox, ubuntu one ,or other free cloud resources , not sure why this would not work so PLEASE  let me know why VM  is not appropriate for testing and development ? php code is the same in linux and xampp ? correct ? or maybe I am not sure of needs and requirements here !!

yehster wrote on Tuesday, November 06, 2012:

Doccbst,
Your virtualbox is a useful tool.  There is nothing that precludes it from being used for testing/development in GENERAL.

However, pfwilliams is a Windows users.  There are always issues that arise on one platform versus another. This is especially true when dealing with filenames.  Another example is the long standing audit engine/form ID bug, which we are still not sure WHY it existed, but there was definitely a difference between windows and linux.

It would be nice if things on linux always ran the same as on windows.  However, that is not a valid assumption in all cases, so it is important to test in both environments.

doccbst wrote on Tuesday, November 06, 2012:

I am also windows user and after 8 years of testing, using, and learning openemr have to agree with Fred Trotter as in his statement here: http://answers.yahoo.com/question/index?qid=20081027071850AANo2Bt
perhaps development of openemr should be split into a windows and linux user interface because of issues you infer, I highly respect xampp and use it often but in the earlier days of openemr it was only to be used for testing and not suggested for production use due to the security issues with windows, I still adhere to the belief that Linux is superior to windows on that  aspect of platform deployment, so not to beat a dead horse, Linux will give more favorable result in long term use and deployment of OpenEMR hands down, no argument or coding will ever change that fact, so for a new user perhaps as pfwilliams appears to be, an exposure to linux is fundamental especially for development of code.
As you stated you use ubuntu server in a virtual environment, using VMware I only offered an alternative of Virtualbox which is free and open source code to achieve a realistic deployment  resolution for testing and even production.
I fail to see any problem with my suggestion .With a high speed internet connection, I can have a new install of linux any flavor up and running with an install of openemr that is highly secured and operable in less than an hour with virtualbox.
Doccbst

pfwilliams wrote on Wednesday, November 14, 2012:

I hate bothering you all with stupid questions, but I spent quite a while trying to figure this one out and seem to be stuck.
I seemed to have screwed the installation up royally.
I first went with the above suggestions to install a fresh copy of OpenEMR for my test_openemr system.
I didn’t like that all of our preferences/settings/clickoptions/etc were lost.
So, I instead I copied the htdocs/openemr to htdocs/test_openemr and edited the sites/default/sqlconf.php file.
(I wonder now, is there also a site_id filed I should change somewhere?)
I then hoped to use a batch file similar to this to clone the database:

@ECHO OFF
SET MYSQL_PATH=C:\XAMPP\MYSQL\BIN
SET PROD_DB=OpenEMR
SET TEST_DB=Test_OpenEMR
SET PASS=pass

%MYSQL_PATH%\mysqladmin -h OpenEMR -f -uroot —p%PASS% drop %TEST_DB%
%MYSQL_PATH%\mysqladmin -h OpenEMR -f -uroot —p%PASS% create %TEST_DB%
%MYSQL_PATH%\mysqldump -u root —p —h %PROD_DB% | %MYSQL_PATH\mysql -u root —p %PASS% %TEST_DB%

PAUSE

(I had changed the blank root password to “pass” at some time previously)
Running that script on the server I kept getting “access denied” errors on localhost, and while trying to resolve that, I seem to have toasted things.

I am now unable to access MyPHPAdmin from anywhere and receive “Cannot connect: Invalid settings” errors that refers to checking host, username, and password settings. The most recent development is that all users now get the following message when trying to launch OpenEMR:

Check that mysqld is running.

ERROR: Could not connect to server!

Apache and MySQL are running on the server.
Any help will be greatly (understatement!) appreciated. 

pfwilliams wrote on Wednesday, November 14, 2012:

Oops! That is not one of the batch files I tried running, but an incomplete version I was throwing together to add the -h parameter to see if that helped resolve the access denied errors when running the script.

pfwilliams wrote on Wednesday, November 14, 2012:

Another clue.
I can still access and successfully query the database using either MySQL Workbench, or a VB script using ADODB and Connector/ODBC (using “root” and “pass” in the connection string).

yehster wrote on Wednesday, November 14, 2012:

I suspect the issue is that mysqldump does not transfer database login information, and the “openemr” database user does not exist in your copied database.
Try editing the sqlconf.php to use “root”/“pass” on your test site and seeing if that changes anything.

I think it’s just a basic issue of your test site using invalid credentials to connect to the database. (given that you can connect with MySQL workbench.)

Alternately, you could also try to grant the existing OpenEMR MySQL user access to the test database using MySQL workbench. However, changing the test site to use root to login is probably simpler/more definitive of a test.

pfwilliams wrote on Wednesday, November 14, 2012:

Well, that was stupid of me.
In all my copying, recopying, dragging and dropping I’d replaced the $dbase setting in the production sqlconf.php with “test_openemr”.  I must have overlooked that three times! That has users back into OpenEMR.

I have no test database presently, I had manually dropped the one created by running the setup.php scripts after the fresh OpenEMR  install.  My batch file to clone the database has been getting those localhost access denied errors.  The mysqladmin.exe calls presently return an access message showing “Password:NO” even though I’m supplying -ppass as a parm.  Hmm, I was hoping for a one-click routine that rebuild the test_database from the production with no user intervention.  If dropping the test database deletes user permissions for that database within MySQL, and mysqldump.exe will not bring them back, then I seem to have a problem.  How to programmatically clone all MySQL permissions per user for the “openemr” database to a newly created “test_openemr” database. I’m sure the passwords are encrypted as well :frowning:

Also, there was some unique site_id prompt I had to respond to when creating the second instance of OpenEMR via the setup.php scripts.  Is that something I’d need to manually address when I’m just copying the folders (in addition to modifying sqlconf.php, loading the database, and recreating the MySQL permissions) ?

I thank you profusely!

yehster wrote on Wednesday, November 14, 2012:

You don’t need to drop and create “test_openemr”  to refresh your data.  The default “mysqldump” includes a statement to drop each table before it loads the data. 

However if you did still want to do so, you could probably execute create user and grant with mysqladmin.  You can look up the syntax on MySQL.com.

Also, don’t confuse “MySQL user” with “OpenEMR user”.