Skip to content

Instantly share code, notes, and snippets.

@josephbales
Last active August 29, 2015 13:56
Show Gist options
  • Save josephbales/8969338 to your computer and use it in GitHub Desktop.
Save josephbales/8969338 to your computer and use it in GitHub Desktop.
Possibly installing Ecrire blogging platform on CentOS with Apache and Passenger.

Ecrire Install Guide for CentOS 6.5 (experimental)

Installing Ecrire on CentOS 6.5 with Apache and Passenger. This is experimental and doesn't work. Don't try it.

@pothibo This works, but I'm still working out the procedure. I'll post it to the wiki when it's complete.

###Conventions:
Commands starting with a # should be run as root. All other commands will be marked with a $ and should be run as a non-privileged user.

###Software Versions: CentOS 6.5
Postgresql 9.3
Ruby 2.0.0p353
Rails 4.0.2
Apache 2.2.15
Passenger 4.0.37

CentOS 6.5 Installation

Installed from minimal.iso into a VirtualBox VM

Basic setup

Install some basic needs

# yum install curl wget vim man

Install EPEL repos

Pull down the RPM
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Install the repo
# rpm -Uvh epel-release-6-8.noarch.rpm
Disable the repo unless explicitly called for
# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
An example of using the repo
# yum --enablerepo=epel install package-name-here

Install the development tools

# yum -y groupinstall "Development Tools"

Install Ruby 2.0.0p353

We will create an RPM file from sources and install from the RPM

Install some additional development libraries

# yum --enablerepo=epel -y install libyaml libyaml-devel readline-devel ncurses-devel gdbm-devel tcl-devel openssl-devel db4-devel libffi-devel

If installing the development libraries fails on EPEL, do a # yum clean and try again

Make the build directories
# mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

Pull down the Ruby sources and specs
# wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz -P rpmbuild/SOURCES
# wget https://raw.github.com/hansode/ruby-2.0.0-rpm/master/ruby200.spec -P rpmbuild/SPECS

Build the RPM
# rpmbuild -bb rpmbuild/SPECS/ruby200.spec

Install the RPM
# rpm -Uvh rpmbuild/RPMS/x86_64/ruby-2.0.0p353-2.el6.x86_64.rpm

Test the installation
# ruby -v
# gem -v

####References

Add EPEL repos (Option 2)
http://www.server-world.info/en/note?os=CentOS_6&p=initial_conf&f=6
Build 2.0 RPM from source
http://www.server-world.info/en/note?os=CentOS_6&p=ruby20

Installing Postgresql 9.3

Configure your YUM repository

Edit the file /etc/yum.repos.d/CentOS-Base.repo
Add the following line to the [base] and [updates] sections

exclude=postgresql*

Download the lasted PGDG rpm
# curl -O http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

Install the rpm distribution
# rpm -ivh pgdg-centos93-9.3-1.noarch.rpm

List available packages if needed
# yum list postgres*

Install Postgresql 9.3, development packages will be dependencies for gems that are installed later
# yum install postgresql93-server postgresql93-devel

Initialize the server
# service postgresql-9.3 initdb

Start the server
# service postgresql-9.3 start

Set the server up to start on boot
# chkconfig postgresql-9.3 on

####References

https://wiki.postgresql.org/wiki/YUM_Installation

Install Apache 2.2.15

Install Apache
# yum install httpd

Start the server
# service httpd start

Configure the server to start on boot # chkconfig httpd on

Configure the firewall by adding the following lines to /etc/sysconfig/iptables:

-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

(Second line is only needed for https)

Make sure this is above any lines that would globally restrict access, like the following:

-A INPUT -j REJECT --reject-with icmp-host-prohibited

Restart the the firewall # service iptables restart

Install Rails 4.0.2

The v option is for the version, the V options is for verbose mode
# gem install rails -Vv 4.0.2

Install and Configure Passenger 4.0.37

Install some library dependencies
# yum install httpd-devel curl-devel

Install the passenger gem
# gem install passenger -v 4.0.37

Install the Apache module
# passenger-install-apache2-module

Follow prompts on the module installation selecting Ruby as the language.

Create passenger.conf file in /etc/httpd/conf.d

LoadModule passenger_module /usr/lib64/ruby/gems/2.0.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/lib64/ruby/gems/2.0.0/gems/passenger-4.0.37
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>

Restart the Apache server to apply the module
# service httpd restart

Deploying a web application: an example

Suppose you have a web application in /home/user/apps/ecrire. Add a virtual host to your Apache configuration file and set its DocumentRoot to /home/user/apps/ecrire/public:

<VirtualHost *:80>
  ServerName www.yourhost.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/user/apps/ecrire/public
  <Directory /home/user/apps/ecrire/public>
    # This relaxes Apache security settings.
    AllowOverride all
    # MultiViews must be turned off.
    Options -MultiViews
  </Directory>
</VirtualHost>

Restart the Apache server to apply the new VirtualHost
# service httpd restart

####References http://sergiy.kyrylkov.name/2012/02/26/phusion-passenger-with-apache-on-rhel-6-centos-6-sl-6-with-selinux/

BELOW THIS LINE NEEDS SOME SERIOUS WORK

Change permission for /srv/http

By default, /srv/http belongs to root's group and user. I prefer assigning it to the group http and let anyone on the group change the content of the directory.

chgrp -R http /srv/http chmod g+w /srv/http


setenforce 0 for now until i figure out selinux, above might not be necessary

Set up database according to Ecrire wiki

http://stackoverflow.com/questions/9964124/rake-dbmigrate-failed

then

sudo service postgresql-9.3 restart

write settings.local.yaml file according to wiki

sudo yum install libxml2-devel libxslt

sudo gem install pg -v '0.17.1' -- --with-pg-config=/usr/pgsql-9.3/bin/pg_config

do bundle install, will ask for password to install gems if not root already

RAILS_ENV=production bundle exec rake db:migrate

RAILS_ENV=production bundle exec rake assets:precompile

add a user per wiki instructions

PULL REQUEST SUBMITTED FOR FOLLOWING [joey@centos ecrire]$ RAILS_ENV=production bundle exec rake assets:precompile WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.6 I, [2014-02-12T22:54:58.934024 #26403] INFO -- : Writing /home/joey/apps/ecrire/public/assets/background-f573f8a7cb07f9c8b1c543e0b652ab44.png rake aborted! require_tree argument must be a directory (in /home/joey/apps/ecrire/themes/default/assets/javascripts/post.js:1)

Tasks: TOP => assets:precompile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment