• PHP
  • Ruby on Rails
  • MySQL
  • Linux
    • SELINUX
    • Fedora
    • debian
  • Apache
  • nginx
  • AJAX
Albertech.net

VPS Uptime List

April 23, 2013 10:03 am / Albertech.net

Here’s a site that lists the uptime of VPS providers. From my experience, Knownhost is solid (although pricier) for a VPS and they currently have a 99.983% uptime listed. They are a managed VPS provider, but they also added an unmanaged option via RocketVPS. Uptime is one of the major factors when picking a VPS — along with RAM, bandwidth, and CPU priority.

http://www.hyperspin.com/en/ranking.php?type=2&i=10&d=90&s=10

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: VPS / Tagged: vps uptime

Installing Phusion Passenger 4.0 with SELINUX and Apache on RHEL 6.3

April 3, 2013 12:54 pm / Albertech.net

Installing Phusion Passenger 4 with SELINUX enabled is quite a challenge, especially with the lack of documentation out there with the latest version of Passenger.

Installation Notes:

Follow the following guide: http://www.seifeet.com/2012/09/ruby-apache-on-centos-63.html. This will get you 90% of the way there.

There are a few changes that I needed to make to get it working properly with my app.

Set the passenger temp folder to /var/run/rubygem-passenger instead of /tmp/ in the Apache config.  (/etc/httpd/conf.d/passenger.conf)

PassengerTempDir /var/run/rubygem-passenger

The reason behind this is due to the SELINUX permissions on the parent /tmp folder will not work properly. If you don’t have the PassengerTempDir set in Apache, you will get an error of a temp folder not being set when running “grep httpd /var/log/audit/audit.log | audit2allow -M passenger“

Here’s the permissions I have for the rubygem-passenger folder:

rvm rvm system_u:object_r:httpd_var_run_t:s0 rubygem-passenger

Set the permissions of the /myrailsapp/tmp folder

If you are using compiled CSS libraries such as Compass, you will need to set the proper SELINUX permissions for the compiled assets folder. Otherwise, any changes to the compiled css files will cause a fatal error in your application (read failure in the tmp folder).

chcon -R -t httpd_sys_rw_content_t tmp

Sample Passenger configuration file for Apache (/etc/httpd/conf.d/passenger.conf)

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p0/gems/passenger-4.0.0.rc4/libout/apache2/mod_passenger.so

PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p0/gems/passenger-4.0.0.rc4
PassengerRuby /usr/local/rvm/wrappers/ruby-2.0.0-p0/ruby

PassengerDefaultUser rvm
PassengerDefaultGroup rvm

PassengerLogLevel 2
PassengerDebugLogFile /var/log/httpd/passenger.log

PassengerPreStart [YOUR SITE URL]
PassengerMaxPoolSize 2
PassengerPoolIdleTime 300
PassengerTempDir /var/run/rubygem-passenger

Still having issues with the install? Here’s some fixes:

Error:  Cannot stat ‘/var/run/rubygem-passenger/passenger.1.0.19162’: Permission denied
Fix: This is due to SELINUX blocking access to the folder. Run the “grep httpd /var/log/audit/audit.log | audit2allow -M passenger” after changing setenforce to 0, restarting httpd, and adding the policy via semanage -i passenger.pp.

Error: Cannot change the directory ‘/tmp/passenger.1.0.—/generation-0/buffered_uploads’ its UID to 48 and GID to 48
Fix:
This is a regular user permission issue (User/Group needs to have write permissions) and is also related to not using /var/run/rubygem-passenger

Error: Errno::EACCES Permission Denied
Fix:
 Your /[myrailsapp]/tmp folder permissions is incorrect. Compiled CSS libraries use the /[myrailsapp]/tmp folder to save all the data  This could be either the user/group permissions or the SELINUX. The fastest way to check to see if its a SELINUX issue is setting setenforce to 0 and restarting httpd. If the app works, then you will need to set the /[myrailsapp]/tmp folder permissions. If not, check to see that the folder has global read/write permissions.

 

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Ruby on Rails / Tagged: passenger, rails, SELinux

Ruby on Rails: Generate dropdown menu from JSON key value pair

March 19, 2013 4:39 pm / Albertech.net

If you want to generate a dropdown selector menu from a JSON using Ruby on Rails, you can do it with two lines of code (three including the JSON string).

In your controller, use the JSON parse method to convert the string into a hash.

myjsonstring = '{"1":"Test1","2":"Test2","3":"Test3"}'
@myvar = JSON.parse(myjsonstring)

In your view,

<%= f.collection_select myfieldname, @myjsonstring, :mykey, :myvalue %>

The end result will look like the following with options values set to 1, 2, and 3.
selectortest

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Ruby on Rails / Tagged: json, ruby

Zend Framework – Shorten the parameter URL by using custom routes

March 12, 2013 2:34 pm / Albertech.net

If you want to consolidate a single parameter into the URL path, it is possible via Zend Rewrite.

For instance, you currently have mysite.com/users/edit/userid/1234 and would like to use mysite.com/users/edit/1234.

To do this, edit the bootstrap.php file and include the following code:

    protected function _initRoutes()
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();
        $route = new Zend_Controller_Router_Route('users/edit/:userid',array('controller' =>; 'users','action' => 'edit'));
        $router->addRoute('usersedit',$route);
        return $router;
    }

In your users controller – editAction() method, you will now be able to access the $userid variable with the shorter URL (mysite.com/users/edit/1234)
(Very basic example)

$request = $this->getRequest();
$userid = $request->userid;

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Zend Framework / Tagged: routes, zend framework

Zend Form – Adding a checkbox element with label to the side

February 21, 2013 7:42 pm / Albertech.net

Here’s the fastest way to add a checkbox element with a label to the side of it (inline) using the Zend Framework. By default, the checkbox is put on a separate line after the label,which isn’t a standard practice. This can be done using some CSS and a Zend Decorator element.

CSS Code:

label.inline {
display: inline;

}
.inlinecheck{
clear: both;
float: left;
width: 25px;
margin-bottom: 0;
}

Zend PHP Code:

$this->addElement('checkbox', 'mycheckbox', array(
'label' => 'My Label',
'name' => 'mycheckbox',
));
$this->getElement('mycheckbox')->addDecorator('Label', array('placement' => 'APPEND'));
$this->getElement('mycheckbox')->addDecorator('HtmlTag', array('tag' => 'dl','class' => 'inlinecheck'));

Rename mycheckbox with the name of your element and set the label accordingly.

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Frameworks, PHP / Tagged: checkbox, zend

Post Navigation

← Older Posts
Newer Posts →

Categories

  • AJAX
  • Android
  • Apache
  • Canon Cameras
  • Cloud
  • CMS
  • Computer Mods
  • Conferences
  • Deals
  • debian
  • Fedora
  • Flash
  • Frameworks
  • git
  • Hardware
  • HTML
  • IDE
  • iPhone
  • iPhone App Review
  • jQuery
  • Linux
  • Mac OS X
  • MySQL
  • nginx
  • PHP
  • portfolio
  • Puppet
  • Ruby on Rails
  • Script Reviews
  • SELINUX
  • Software
  • Software Review
  • SQL Server
  • statistics
  • Tech
  • Tomcat
  • Uncategorized
  • VMWARE
  • VPS
  • Windows
  • wordpress
  • Zend Framework

Blogroll

  • DragonAl Flickr
  • Dropbox – Free 2GB Account
  • James' Blog
  • Javascript Compressor
  • PHP Builder Community
  • PHP-Princess.net
  • Rubular – Regular Expression Validator
  • The Scale-Out Blog
  • Tiny MCE

Tags

activation AJAX android antec Apache AWS awstats canon coda codeigniter debian enclosure external free G1 install vmware tools Internet Explorer iphone 5 jquery Linux mx-1 MySQL office 2007 OSX photoshop PHP plugin plugins portfolio redesigned website review rewrite script security SELinux ssh tinymce tutorial upgrade VMWARE vmware server wordpress wordpress mu XSS zend framework
© Copyright 2013 Albertech.net
Infinity Theme by DesignCoral / WordPress
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.