March 14, 2016 The IUS Community Project is sponsored by Rackspace and offers an easy upgrade path for users on CentOS 6 who are tired of being stuck with PHP 5.3 (or Python 2.6). My experience upgrading to PHP 5.6 was totally painless, by YMMV. The IUS repo is recommended over the Remi repo, because IUS uses package names that are different from the default package names, whereas Remi overrides the defaults.
These instructions assume that you already have a version of PHP installed on your server.
$ cd /tmp
If you don't already have the EPEL repo, install that first. EPEL offers packages that aren't available on standard CentOS (like Fail2Ban and phpMyAdmin). If you're not sure whether you have EPEL, run sudo yum repolist and see if epel is listed.
// Install the EPEL repo, if necessary
$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
$ sudo rpm -Uvh epel-release-6*.rpm
// Install the IUS repo
$ wget https://centos6.iuscommunity.org/ius-release.rpm
$ sudo rpm -Uvh ius-release*.rpm
// Install the IUS replace plugin
$ sudo yum install yum-plugin-replace
// Use the plugin to replace the existing PHP with 5.6
$ sudo yum replace php --replace-with php56u
// You will see some warnings. These warnings are normal.
WARNING: Unable to resolve all providers: [...
Continue? [y/N] y
...
Complete!
// Restart your web server. For Apache it's
$ sudo service httpd restart
// Check installed PHP version
$ php -v
// should output...
PHP 5.6.25 (cli) (built: Aug 19 2016 11:03:33)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Congratulations, you are now on PHP 5.6! Want to see what else IUS has available?
// Check for a specific package
sudo yum --enablerepo=ius list python*
// List everything in the IUS repo
sudo yum --disablerepo="*" --enablerepo="ius" list available | more
To learn more, check out the IUS Project website and this installation walkthrough on GitHub. There's also a helpful article by Rackspace.
January 26, 2016 You can check the size and current usage of CentOS swap space by running:
$ grep SwapTotal /proc/meminfo
You can check current swap activity using:
$ vmstat 3 100
procs --------memory---------- --swap-- --io-- --system-- --cpu---
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 1272 61748 227044 2786452 0 0 1 3 7 7 0 0 100 0 0
0 0 1272 61764 227044 2786452 0 0 0 19 18 19 0 0 100 0 0
0 0 1272 61796 227044 2786452 0 0 0 0 21 25 0 0 100 0 0
0 0 1272 61796 227044 2786452 0 0 0 12 29 29 0 0 100 0 0
The swpd column shows total swap usage. The si and so columns show the amount of memory swapped in and swapped out. Swapping should be relatively rare, so the si and so columns should usually be zero. If they are consistently non-zero, your system needs more RAM.
May 23, 2015 Edit the $allowedUnits parameter in /Length.php
protected static $allowedUnits = array(
'em' => true, 'ex' => true, 'px' => true, 'in' => true,
'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true,
'rem' => true // ADDED
);
April 1, 2015 If you've set up a load balancer and have noticed that your Apache logs are showing all traffic coming from your load balancer's IP address instead of the user's, you can fix it by grabbing the X-Forwarded-For header and using that in the log format in httpd.conf:
LogFormat "%{X-Forwarded-For}i %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
Within your application code you can grab HTTP_X_FORWARDED_FOR from the server environment variables.
ENV["HTTP_X_FORWARDED_FOR"] # Ruby
$_SERVER["HTTP_X_FORWARDED_FOR"] # PHP
March 31, 2015 Install the required dependencies:
$ yum -y groupinstall "Development Tools"
$ yum -y install openssl-devel
Download, compile, and install Ruby 2.2.1:
$ cd /tmp
$ wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.gz
$ tar xvfvz ruby-2.2.1.tar.gz
$ cd ruby-2.2.1
$ ./configure
$ make # this will take a while
$ make install
Update gems:
$ gem update --system # updates rubygems itself
$ gem install bundler
$ gem update # updates default gems
Check that Ruby and Rubygems are installed:
$ ruby --version # 2.2.1
$ gem --version # 2.4.6
Finally, clean up:
$ rm -rf /tmp/ruby-2.2.1
$ rm -f /tmp/ruby-2.2.1.tar.gz
And now you can...
$ irb
irb(main):001:0> puts "Hello #{ENV['HOSTNAME']}"
Hello plato
=> nil
February 12, 2015 If you are developing a Rack application locally it's nice to be able to easily test a variety of devices. But if you try to connect via your local IP address, you will find that is doesn't work because by default Rack binds to localhost. In order to accept external connections we need to make Rack bind to 0.0.0.0 instead. You can do this with:
bundle exec rackup --host 0.0.0.0 --port 8080
You can find your local IP address from the OS X System Preferences > Network.
You can now connect from an external device using http://YOUR_IP:8080, e.g. http://10.0.1.14:8080