|
| 1 | +Installation of The DataTank on CentOS 6.5 |
| 2 | +======================================== |
| 3 | + |
| 4 | +Background |
| 5 | +---------- |
| 6 | +When installing The DataTank, users of CentOS 6 will need to make a choice about what version of PHP they will be using to support the installation. As CentOS 6.5 is based on Red Hat Enterprise Linux - with its preference for older packages that have a proven track record of stability - the default installation of PHP is version 5.3.3. |
| 7 | + |
| 8 | +However, the Laravel 4.0 framework, which forms the foundation upon which TheDataTank is constructed, requires PHP 5.3.7 as the minimum version, and newer versions of Laravel bump that requirement up to PHP 5.4.0. Additionally, there are a number of [PHPUnit tests](https://github.com/tdt/core/issues/170) that come with The DataTank which use syntax that requires by PHP 5.4 and above. |
| 9 | + |
| 10 | +Thus, there are two choices when it comes to running The DataTank on CentOS 6 -- either upgrade PHP to version 5.4.x, or make the modifications, detailed below, needed to install The DataTank using the default PHP 5.3.3 installation. |
| 11 | + |
| 12 | +When feasible, upgrading PHP to 5.4.x is perhaps the better option, because it enables forward-compatibility and will support the full complement of PHPUnit tests. [Daniel Heramb](http://danielheramb.blogspot.com/2013/03/how-to-install-laravel-on-linux.html) has written some good instructions on installing PHP 5.4 as part of a Laravel installation. |
| 13 | + |
| 14 | +But there may be compelling reasons for remaining on PHP 5.3.3. There may be an organizational preference for utilizing default packages, or it may be necessary to maintain 5.3.x compatibility for other PHP applications running on the server. Drupal 7, for example, will run on PHP 5.4, but "prefers" 5.3, and may generate a rather large number of warnings when running PHP 5.4. |
| 15 | + |
| 16 | +For cases where remaining on PHP 5.3.3 is considered the best option, the following installation instructions may be used. They have been successfully tested on a virtual machine running a fresh installation of CentOS 6.5. Additionally, many of the steps below will also be of use to those installing The DataTank on top of PHP 5.4.x on a Red Hat-family Linux distribution, as they reflect a yum-based installation, Red Hat-flavored directory structures, and instructions on a required SELinux security configuration. |
| 17 | + |
| 18 | +# Installation of basic packages |
| 19 | + |
| 20 | +As the root user, use Yum to install git, curl, the MySQL client and Apache webserver: |
| 21 | + |
| 22 | + yum install git |
| 23 | + yum install curl |
| 24 | + yum install wget |
| 25 | + yum install mysql |
| 26 | + yum install httpd |
| 27 | + |
| 28 | +Install and start memcached: |
| 29 | + |
| 30 | + yum install memcached |
| 31 | + /etc/init.d/memcached start |
| 32 | + |
| 33 | +Next comes the PHP installation. To install PHP 5.4, follow the directions at [Daniel Heramb's website](http://danielheramb.blogspot.com/2013/03/how-to-install-laravel-on-linux.html). To install 5.3.3, follow the instructions below. |
| 34 | + |
| 35 | + |
| 36 | +Install PHP core and various PHP libraries: |
| 37 | + |
| 38 | + yum install php |
| 39 | + yum install php-pecl-memcache |
| 40 | + yum install php-devel |
| 41 | + yum install php-mysql |
| 42 | + yum install php-pecl-apc |
| 43 | + yum install php-xml |
| 44 | + |
| 45 | +The following package was recommended for optimization, but is not available in the default repositories. It is listed here for completeness only; you do not need to install it - and, indeed, may not be able to. |
| 46 | + |
| 47 | + yum install php-pecl-zendopcache |
| 48 | + |
| 49 | +There are some additional PHP packages which must be installed from the Extra Packages for Enterprise Linux (or EPEL) RPM repository, which is a repository of Red Hat compatible binaries supported by the Fedora community. Use the following commands to install the EPEL repository |
| 50 | + |
| 51 | + wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm |
| 52 | + rpm -ivh epel-release-6-5.noarch.rpm |
| 53 | + |
| 54 | +With the EPEL repository installed, you will now be able to install these two PHP packages: |
| 55 | + |
| 56 | + yum install php-mcrypt |
| 57 | + yum install php-mbstring |
| 58 | + |
| 59 | +# Install Composer and download tdt/core |
| 60 | +Use the following commands to install Composer and put it in the path: |
| 61 | + |
| 62 | + curl -sS https://getcomposer.org/installer | php |
| 63 | + mv composer.phar /usr/local/bin/composer |
| 64 | + |
| 65 | +Create an installation directory and bring in the tdt code using git: |
| 66 | + |
| 67 | + mkdir /opt/tdt |
| 68 | + cd /opt/tdt |
| 69 | + git clone https://github.com/tdt/core.git |
| 70 | + |
| 71 | +# Database setup and configuration |
| 72 | +If MySQL is to be hosted locally, install and start the MySQL server: |
| 73 | + |
| 74 | + yum install mysql-server |
| 75 | + /etc/init.d/mysqld start |
| 76 | + |
| 77 | +Configuring security on MySQL is outside the scope of this document. However, the following lines of SQL used to create a database and user are included for your convenience. Log into your MySQL prompt, and type the following: |
| 78 | + |
| 79 | + create database tdt; |
| 80 | + create user 'tdt_user'@'localhost' identified by 'PASSWORD123'; |
| 81 | + grant all on tdt.* to 'tdt_user'@'localhost'; |
| 82 | + |
| 83 | +Be sure to use a better password than the one provided above. Add these settings to the Set these credentials in Laravel database configuration file in /opt/tdt/core/app/config/database.php. It should look like this: |
| 84 | + |
| 85 | + |
| 86 | + 'mysql' => array( |
| 87 | + 'driver' => 'mysql', |
| 88 | + 'host' => 'localhost', |
| 89 | + 'database' => 'tdt', |
| 90 | + 'username' => 'tdt_user', |
| 91 | + 'password' => 'PASSWORD123', |
| 92 | + 'charset' => 'utf8',- |
| 93 | + 'collation' => 'utf8_unicode_ci', |
| 94 | + 'prefix' => '', |
| 95 | + ) |
| 96 | + |
| 97 | +# Hack composer.json and run the build |
| 98 | + |
| 99 | +For installing on PHP 5.3.3, this is where things get tricky. Those who are installing on 5.4.x can skip the edits to composer.json listed below, and move on to running composer, at the end of this section. |
| 100 | + |
| 101 | +The reason Laravel requires PHP 5.3.7 at a minimum is that it requires bcrypt-based hashing, which is not available in 5.3.3. Howerver, [Rob Clancy](https://github.com/robclancy/laravel4-hashing) has provided a patch which overrides the bcrypt hashing code with a hash using the sha5 algorythm. Enable this patch by adding the following to the top of the "require" section of tdt's core/composer.json file: |
| 102 | + |
| 103 | +* "robclancy/laravel4-hashing": "dev-master", |
| 104 | + |
| 105 | +You will also need to trick the Composer build process into using Laravel 4.0.10 instead of 4.1.x. This is because the 4.1 series of Laravel requires PHP 5.4, and will not run with 5.3. Thus, in the same core/composer.json file as above, edit the line that referes to "laravel/framework", as follows: |
| 106 | + |
| 107 | +* "laravel/framework": "4.0.10 as 4.1.10", |
| 108 | + |
| 109 | +Now, run composer - this could take 20 minutes or so, depending on your setup. |
| 110 | + |
| 111 | + cd core |
| 112 | + composer install |
| 113 | + |
| 114 | +# Set up the webserver, configure permissions and the firewall |
| 115 | + |
| 116 | +Create a shortcut under Apache's content directory to the publicly exposed portion of your installation: |
| 117 | + |
| 118 | + ln -s /opt/tdt/core/public /var/www/html/tdt |
| 119 | + |
| 120 | +Edit the Apache configuration file, located at /etc/httpd/conf/httpd.conf: |
| 121 | + |
| 122 | +* Under the configuration for <Directory "/var/www/html">, change <i>AllowOverride None</i> to <i>AllowOverride All</i> |
| 123 | + |
| 124 | +This directory needs to be made fully accessible to the application: |
| 125 | + |
| 126 | + chmod -R 777 /opt/tdt/core/app/storage/ |
| 127 | + |
| 128 | +Even with 777 permissions, SELinux will prevent the app from accessing that directory unless you explicitly provide that permission. Use the following command: |
| 129 | + |
| 130 | + chcon -Rv --type=httpd_sys_content_rw_t /opt/tdt/core/app/storage |
| 131 | + |
| 132 | +Alternately, if you are on a non-production machine and you just want to turn SELinux off, do this: |
| 133 | + |
| 134 | + echo 0 > /selinux/enforce |
| 135 | + |
| 136 | +Start the webserver |
| 137 | + |
| 138 | + apachectl start |
| 139 | + |
| 140 | +Finally, if you want to access this site from a browser on a different machine, you will need to open up port 80 in the iptables firewall. Add the following line to your /etc/sysconfig/iptables file: |
| 141 | + |
| 142 | +* -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT |
| 143 | + |
| 144 | +Then, restart the iptables firewall: |
| 145 | + |
| 146 | + /etc/init.d/iptables restart |
| 147 | + |
| 148 | +The DataTank should now be installed and running at http://[Your.IP.Address]/tdt/. The admin console is located at http://[Your.IP.Address]/tdt/api/admin. The default username and password are both "admin." |
0 commit comments