\n"; echo "\n"; echo "OpenEMR Setup Tool\n"; echo "\n"; echo "\n"; echo "\n"; echo "

Optional Site ID Selection

\n"; echo "

Most OpenEMR installations support only one site. If that is " . "true for you then ignore the rest of this text and just click Continue.

\n"; echo "

Otherwise please enter a unique Site ID here.

\n"; echo "

A Site ID is a short identifier with no spaces or special " . "characters other than periods or dashes. It is case-sensitive and we " . "suggest sticking to lower case letters for ease of use.

\n"; echo "

If each site will have its own host/domain name, then use that " . "name as the Site ID (e.g. www.example.com).

\n"; echo "

The site ID is used to identify which site you will log in to. " . "If it is a hostname then it is taken from the hostname in the URL. " . "Otherwise you must append \"?site=siteid\" to the URL used for " . "logging in.

\n"; echo "

It is OK for one of the sites to have \"default\" as its ID. This " . "is the ID that will be used if it cannot otherwise be determined.

\n"; echo "
" . "Site ID:  " . "

\n"; echo "\n"; exit(); } // Support "?site=siteid" in the URL, otherwise assume "default". $site_id = 'default'; if (!$COMMAND_LINE && !empty($_REQUEST['site'])) { $site_id = trim($_REQUEST['site']); } // Die if site ID is empty or has invalid characters. if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) die("Site ID '".htmlspecialchars($site_id,ENT_NOQUOTES)."' contains invalid characters."); //If having problems with file and directory permission // checking, then can be manually disabled here. $checkPermissions = True; $installer = new Installer( $_REQUEST ); global $OE_SITE_DIR; // The Installer sets this $docsDirectory = "$OE_SITE_DIR/documents"; $billingDirectory = "$OE_SITE_DIR/edi"; $billingDirectory2 = "$OE_SITE_DIR/era"; $billingLogDirectory = dirname(__FILE__)."/library/freeb"; $lettersDirectory = "$OE_SITE_DIR/letter_templates"; $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c"; $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled"; $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache"; $zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php"; //These are files and dir checked before install for // correct permissions. if (is_dir($OE_SITE_DIR)) { $writableFileList = array($installer->conffile,$zendModuleConfigFile); $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2); } else { $writableFileList = array(); $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2); } // Include the sqlconf file if it exists yet. $config = 0; if (file_exists($OE_SITE_DIR)) { include_once($installer->conffile); } else if ($state > 3) { // State 3 should have created the site directory if it is missing. die("Internal error, site directory is missing."); } ?> OpenEMR Setup Tool OpenEMR Setup

Congratulations! OpenEMR is now installed.

We recommend you print these instructions for future reference.

clone_database)) { echo "

The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'

"; echo "

If you edited the PHP or Apache configuration files during this installation process, then we recommend you restart your Apache server before following below OpenEMR link.

"; } ?>

Click here to start using OpenEMR.

conffile (change the 'config' variable to 0), and re-run this script.
\n"; } else { switch ($state) { case 1: echo "Step $state

\n"; echo "Now I need to know whether you want me to create the database on my own or if you have already created the database for me to use. For me to create the database, you will need to supply the MySQL root password.\n
NOTE: clicking on \"Continue\" may delete or cause damage to data on your system. Before you continue please backup your data.


\n
\n \n \n
\n
\n
\n

\n"; break; case 2: echo "Step $state

\n"; echo "Now you need to supply the MySQL server information and path information. Detailed instructions on each item can be found in the 'INSTALL' manual file.

\n
\n \n \n"; if ($inst != 2) { echo "\n"; echo ""; echo ""; } echo ""; // Include a "source" site ID drop-list and a checkbox to indicate // if cloning its database. When checked, do not display initial user // and group stuff below. $dh = opendir($OE_SITES_BASE); if (!$dh) die("Cannot read directory '$OE_SITES_BASE'."); $siteslist = array(); while (false !== ($sfname = readdir($dh))) { if (substr($sfname, 0, 1) == '.') continue; if ($sfname == 'CVS' ) continue; if ($sfname == $site_id ) continue; $sitedir = "$OE_SITES_BASE/$sfname"; if (!is_dir($sitedir) ) continue; if (!is_file("$sitedir/sqlconf.php")) continue; $siteslist[$sfname] = $sfname; } closedir($dh); // If this is not the first site... if (!empty($siteslist)) { ksort($siteslist); echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } echo ""; echo " "; echo ""; echo "
MYSQL SERVER:
Server Host: (If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running MySQL.)
Server Port: (This is the MySQL port. The default port for MySQL is 3306.)
Database Name: (This is the name of the OpenEMR database in MySQL - 'openemr' is the recommended)
Login Name: (This is the name of the OpenEMR login name in MySQL - 'openemr' is the recommended)
Password: (This is the Login Password for when PHP accesses MySQL - it should be at least 8 characters long and composed of both numbers and letters)
Name for Root Account: (This is name for MySQL root account. For localhost, it is usually ok to leave it 'root'.)
Root Pass: (This is your MySQL root password. For localhost, it is usually ok to leave it blank.)
User Hostname: (If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running Apache/PHP.)
UTF-8 Collation: " . "" . "
 (This is the collation setting for mysql. Leave as 'General' if you are not sure. If the language you are planning to use in OpenEMR is in the menu, then you can select it. Otherwise, just select 'General'.)
 
Source Site: (The site directory that will be a model for the new site.)
Clone Source Database: (Clone the source site's database instead of creating a fresh one.)
OPENEMR USER:
Initial User:(This is the login name of user that will be created for you. Limit this to one word.)
Initial User Password:(This is the password for the initial user account above.)
Initial User's First Name:(This is the First name of the 'initial user'.)
Initial User's Last Name:(This is the Last name of the 'initial user'.)
Initial Group:(This is the group that will be created for your users. This should be the name of your practice.)
 



"; break; case 3: // Form Validation // (applicable if not cloning from another database) if (empty($installer->clone_database)) { if ( ! $installer->login_is_valid() ) { echo "ERROR. Please pick a proper 'Login Name'.
\n"; echo "Click Back in browser to re-enter.
\n"; break; } if ( ! $installer->iuser_is_valid() ) { echo "ERROR. The 'Initial User' field can only contain one word and no spaces.
\n"; echo "Click Back in browser to re-enter.
\n"; break; } if ( ! $installer->user_password_is_valid() ) { echo "ERROR. Please pick a proper 'Initial User Password'.
\n"; echo "Click Back in browser to re-enter.
\n"; break; } } if ( ! $installer->password_is_valid() ) { echo "ERROR. Please pick a proper 'Password'.
\n"; echo "Click Back in browser to re-enter.
\n"; break; } echo "Step $state

\n"; echo "Configuring OpenEMR...

\n"; // Skip below if database shell has already been created. if ($inst != 2) { echo "Connecting to MySQL Server...\n"; flush(); if ( ! $installer->root_database_connection() ) { echo "ERROR. Check your login credentials.\n"; echo $installer->error_message; break; } else { echo "OK.
\n"; flush(); } } // Only pertinent if cloning another installation database if ( ! empty($installer->clone_database)) { echo "Dumping source database..."; flush(); if ( ! $installer->create_dumpfiles() ) { echo $installer->error_message; break; } else { echo " OK.
\n"; flush(); } } // Only pertinent if mirroring another installation directory if ( ! empty($installer->source_site_id)) { echo "Creating site directory..."; if ( ! $installer->create_site_directory() ) { echo $installer->error_message; break; } else { echo "OK.
"; flush(); } } // Skip below if database shell has already been created. if ($inst != 2) { echo "Creating database...\n"; flush(); if ( ! $installer->create_database() ) { echo "ERROR. Check your login credentials.\n"; echo $installer->error_message; break; } else { echo "OK.
\n"; flush(); } echo "Creating user with permissions for database...\n"; flush(); if ( ! $installer->grant_privileges() ) { echo "ERROR when granting privileges to the specified user.\n"; echo $installer->error_message; break; } else { echo "OK.
\n"; flush(); } echo "Reconnecting as new user...\n"; flush(); $installer->disconnect(); } else { echo "Connecting to MySQL Server...\n"; } if ( ! $installer->user_database_connection() ) { echo "ERROR. Check your login credentials.\n"; echo $installer->error_message; break; } else { echo "OK.
\n"; flush(); } // Load the database files $dump_results = $installer->load_dumpfiles(); if ( ! $dump_results ) { echo $installer->error_message; break; } else { echo $dump_results; flush(); } echo "Writing SQL configuration...\n"; flush(); if ( ! $installer->write_configuration_file() ) { echo $installer->error_message; break; } else { echo "OK.
\n"; flush(); } // Only pertinent if not cloning another installation database if (empty($installer->clone_database)) { echo "Setting version indicators...\n"; flush(); if ( ! $installer->add_version_info() ) { echo "ERROR.\n"; echo $installer->error_message;; break; } else { echo "OK
\n"; flush(); } echo "Writing global configuration defaults...\n"; flush(); if ( ! $installer->insert_globals() ) { echo "ERROR.\n"; echo $installer->error_message;; break; } else { echo "OK
\n"; flush(); } echo "Adding Initial User...\n"; flush(); if ( ! $installer->add_initial_user() ) { echo $installer->error_message; break; } echo "OK
\n"; flush(); } if ( ! empty($installer->clone_database) ) { // Database was cloned, skip ACL setup. echo "Click 'continue' for further instructions."; $next_state = 7; } else { echo "\n
Next step will install and configure access controls (php-GACL).
\n"; $next_state = 4; } echo "
\n \n
\n

\n"; break; case 4: echo "Step $state

\n"; echo "Installing and Configuring Access Controls (php-GACL)...

"; if ( ! $installer->install_gacl() ) { echo $installer->error_message; break; } else { // display the status information for gacl setup echo $installer->debug_message; } echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.

"; echo "Done installing and configuring access controls (php-GACL).
"; echo "Next step will configure PHP."; echo "
\n \n \n \n \n
\n

\n"; break; case 5: echo "Step $state

\n"; echo "Configuration of PHP...

\n"; echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n"; echo ""; echo "
We recommend you print these instructions for future reference.

"; echo "Next step will configure Apache web server."; echo "
\n \n \n \n \n
\n

\n"; break; case 6: echo "Step $state

\n"; echo "Configuration of Apache web server...

\n"; echo "The \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\", \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\" and \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\" directories contain patient information, and it is important to secure these directories. Additionally, some settings are required for the Zend Framework to work in OpenEMR. This can be done by pasting the below to end of your apache configuration file:
  <Directory \"".realpath(dirname(__FILE__))."\">
      AllowOverride FileInfo
  </Directory>
  <Directory \"".realpath(dirname(__FILE__))."/sites\">
      AllowOverride None
  </Directory>
  <Directory \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\">
      order deny,allow
      Deny from all
  </Directory>
  <Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\">
      order deny,allow
      Deny from all
  </Directory>
  <Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\">
      order deny,allow
      Deny from all
  </Directory>

"; echo "If you are having difficulty finding your apache configuration file, then refer to the 'INSTALL' manual for suggestions.

\n"; echo "
We recommend you print these instructions for future reference.

"; echo "Click 'continue' for further instructions."; echo "
\n \n \n \n \n
\n

\n"; break; case 0: default: echo "

Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.

\n"; echo ""; if ($checkPermissions) { echo "

We will now ensure correct file and directory permissions before starting installation:

\n"; echo "Ensuring following files are world-writable...
\n"; $errorWritable = 0; foreach ($writableFileList as $tempFile) { if (is_writable($tempFile)) { echo "'".realpath($tempFile)."' file is ready.
\n"; } else { echo "

UNABLE to open file '".realpath($tempFile)."' for writing.
\n"; echo "(configure file permissions; see below for further instructions)

\n"; $errorWritable = 1; } } if ($errorWritable) { echo "

You can't proceed until all above files are ready (world-writable).
\n"; echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.
\n"; echo "Fix above file permissions and then click the 'Check Again' button to re-check files.
\n"; echo "

" . "

\n"; break; } echo "
Ensuring following directories have proper permissions...
\n"; $errorWritable = 0; foreach ($writableDirList as $tempDir) { if (is_writable($tempDir)) { echo "'".realpath($tempDir)."' directory is ready.
\n"; } else { echo "

UNABLE to open directory '".realpath($tempDir)."' for writing by web server.
\n"; echo "(configure directory permissions; see below for further instructions)

\n"; $errorWritable = 1; } } if ($errorWritable) { echo "

You can't proceed until all directories are ready.
\n"; echo "In linux, recommend changing owners of these directories to the web server. For example, in many linux OS's the web server user is 'apache', 'nobody', or 'www-data'. So if 'apache' were the web server user name, could use the command 'chown -R apache:apache directory_name' command.
\n"; echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.
\n"; echo "

" . "

\n"; break; } echo "
All required files and directories have been verified. Click to continue installation.
\n"; } else { echo "
Click to continue installation.
\n"; } echo "
" . "" . "

"; } } ?>