Install on CentOS

sc4goodhealth wrote on Thursday, April 23, 2015:

Hi,

I need some help getting past the setup script. I’m installing on CentOS-7 x86_64 with PHP version 5.4.16, Apache httpd version 2.4.6, and MySQL Community Server version 5.6. Note on MySQL - CentOS 7 ships with MariaDB but I installed MySQL to be consistent with OpenEMR’s documented installation procedures.

The setup script is telling me that it is unable to open two files for writing:

/var/www/html/openemr/sites/default/sqlconf.php
/var/www/html/openemr/interface/modules/zend_modules/config/application.config.php

However I have changed ownership to the user apache and changed mod to 777 (this is a test install) to ensure that the files are writable:

-rwxrwxrwx. 1 apache apache 621 Apr 22 09:02 /var/www/html/openemr/sites/default/sqlconf.php

-rwxrwxrwx. 1 apache apache 295 Apr 23 00:22 /var/www/html/openemr/interface/modules/zend_modules/config/application.config.php

At this point, I do not think that the root cause of installation failure is file permissions, as the error messages indicate. Am I missing something around permissions?

What else could be going on? What error logs could I check? Are there other related services that could be causing an issue - for example, should I manually created the openemr database with the user and password settings specified in sqlconf.php? Could I be facing an issue specific to CentOS/EL Linux, like SELinux settings - if so, could someone please give me some insights if possible?

Thank you.

fsgl wrote on Thursday, April 23, 2015:

Unfortunate that the OS is not Debian, in which case the Package can be installed in mere minutes.

Time spent changing to Debian will be time saved in frustration.

Try:

  1. chmod 666 for
    openemr/sites/default/sqlconf.php

2.chown -R for
openemr/sites/default/documents
openemr/sites/default/edi
openemr/sites/default/era
openemr/sites/default/custom/letter_templates
openemr/gacl/admin/templates_c
openemr/interface/main/calendar/modules/PostCalendar/pntemplates/cache
openemr/interface/main/calendar/modules/PostCalendar/pntemplates/compiled

As required here:

sc4goodhealth wrote on Friday, April 24, 2015:

Thank you for the response, fsgl. OpenEMR is working now, although I had to take a different course than you suggested - it is fully documented in this post.

First, though, let me respectfully respond to your suggestion to use a Debian-based OS, like Ubuntu. As we consider a production installation, including multiple installs for redundancy and high availability, our organization must be able to count on support. We have experience with Red Hat Enterprise Linux and feel confident with server support that we could get with Red Hat.

While Canonical now offers enterprise support for Ubuntu, this endeavor would be beyond the scope of our organizational requirements for business continuity, as we simply have no experience with support from Canonical. As an avid Ubuntu user in my personal life, I may experiment on my own time with OpenEMR on Ubuntu, but for our organization, I chose CentOS in anticipation of a move to Red Hat.

As a preface, I am working on a headless server, so I started the process working in Firefox tunneled through SSH, then opened the local firewall for LAN access - instructions for doing the same are included in this post.

Note that some of the relaxed security settings that I am permitting are acceptable for our test installation but will need to be reviewed and tightened before moving our installation to production.

So OpenEMR is working. This is what I had to do.

First, CentOS implements the SELinux kernel security module. I followed instructions at http://wiki.centos.org/HowTos/SELinux to set SELinux’s mode to permissive. Then, I rebooted the system.

sudo nano /etc/selinux/config

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=permissive

SELINUXTYPE= can take one of three two values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

sudo shutdown -r now

Now, the install proceeded to Step 2, and I chose the option to have the installer create the OpenEMR database for me. However, the install hung on Step 3, while it was attempting to create the database. I spent some time reconfiguring MySQL – as I noted above, CentOS ships with MariaDB, which is said to be a “drop-in replacement” for MySQL, but I wanted my configuration be consistent with OpenEMR’s documented installation procedure.

I observed system logs as I attempted to re-run Steps 2 and 3.

sudo tail -f -n 1000 /var/log/messages
sudo tail -f -n 1000 /var/log/mysqld.log
sudo tail -f -n 1000 /var/log/httpd/error_log

I saw the message:

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

I verified that MySQL was running by following the steps at http://www.cyberciti.biz/faq/cant-connect-to-local-mysql-server-through-socket-varlibmysqlmysql-sock-2/ , but I wasn’t sure that I had installed MySQL correctly. I made sure that STRICT mode was not enabled per OpenEMR documentation and MySQL documentation (http://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sql-mode-full). I still decided to re-install MySQL, and I followed the instructions at http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ to make sure I got it right.

Yet Step 3 was still hanging. Again, I observed system logs as I attempted to re-run Steps 2 and 3.

sudo tail -f -n 1000 /var/log/messages
sudo tail -f -n 1000 /var/log/mysqld.log
sudo tail -f -n 1000 /var/log/httpd/error_log

I saw the message:

PHP Fatal error:  Call to undefined function mysql_connect() in /var/www/html/openemr/setup.php on line 237, referer: http://localhost/openemr/setup.php

After some searching, I found that another OpenEMR user had resolved this issue - https://sourceforge.net/p/openemr/discussion/202505/thread/25237742. The solution here was to install the missing php-mysql module.

sudo yum install php-mysql
sudo service mysqld restart
sudo service httpd restart

Awesome, I re-ran Steps 2 and 3, proceeded to Step 4 as expected, and the installation finished successfully. I could connect from localhost. If you are working on a headless server and only have an SSH connection, install Firefox and XOrg to access the OpenEMR Web portal. Note that these steps are beyond the scope of OpenEMR installation per se, and I’m including them for a full explanation of the workflow in my environment.

sudo yum install firefox
sudo yum install xorg-x11-xauth

On Windows, download and launch Xming. Configure PuTTy to Enable X11 forwarding. Normally the X display location is localhost:0.0, although you can set up different configurations with Xming’s XLaunch utility.

So I knew OpenEMR was installed properly, and I could access it with the credentials that I established during OpenEMR setup. However I needed to make OpenEMR available on our LAN.

The local system firewall in CentOS blocks most ports from external (i.e. other than localhost a/k/a loopback interface) access by default. Previously, CentOS utilized the iptables program to manage the firewall. Now CentOS uses the firewalld daemon to manage the firewall.

With the following commands, I opened ports 80 and 443 on the local firewall, made the changes permanent, and restarted the firewall daemon.

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd –reload

Now, OpenEMR is up and running on CentOS 7, and my colleagues and I can access it over the LAN.

fsgl wrote on Friday, April 24, 2015:

Congratulations.

Always great to see hard work rewarded.

You know your work environment better than anyone possibly can, here in the Fora. We try to remind ourselves of that fact on a regular basis.

I speak from the perspective of a solo practice, where I wear the IT hat as well. After reading the posts of many DIY-ers struggling with setup, it has been my impression that the Packages would have served them better.

I agree with you wholeheartedly that the quality of support is vital. If your practice is based in the U.S., navigating around the security minefield will be impossible without solid support.

Thank you for the detailed feedback & the best of luck.

sc4goodhealth wrote on Friday, April 24, 2015:

Thank you for your contributions to the open source community and in particular the hours/weeks/years of work that I know you’ve put into OpenEMR. If/when I learn enough about packaging RPMs for Fedora/Red Hat/CentOS, I will certainly apply the knowledge to OpenEMR and collaborate with ya’ll to share with the community.

I consider my installation issues resolved but will stay in touch with the forums to help in any way that I can. Take care.

yehster wrote on Sunday, April 26, 2015:

At some point, you may find that other php modules needed by OpenEMR are not installed when you start using more it’s features. curl, xml/xsl functionality for example.

The appropriate yum command to install those packages will likely be the proper corrective action to take.

fsgl wrote on Sunday, April 26, 2015:

Just noticed the colloquialism.

Little wonder Mrs. Clinton has a soft spot for Southerners.

Ya’ll come back now! Ya hear?

iz_27 wrote on Saturday, May 23, 2015:

hi,
thank you for your post, i solve my problem only 5 minute after read your excellent troubleshooting on centos.