Skip to content

Instantly share code, notes, and snippets.

@josephbales
Created February 11, 2014 12:28
Show Gist options
  • Save josephbales/8933927 to your computer and use it in GitHub Desktop.
Save josephbales/8933927 to your computer and use it in GitHub Desktop.

#CentOS 6.5 Install

Assumes minimal.iso

yum install vim

##Install Nginx

http://wiki.nginx.org/Install

sudo yum install nginx

##Install Ruby

yum install wget

Number 2 on the following page to set up EPEL http://www.server-world.info/en/note?os=CentOS_6&p=initial_conf&f=6

http://www.server-world.info/en/note?os=CentOS_6&p=ruby20

##Install Postgres And Configure

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

su - postgres -c 'psql' postgres=# CREATE DATABASE ecrire_prod; postgres=# CREATE USER $user_you_want WITH PASSWORD '$user_password'; postgres=# GRANT ALL PRIVILEGES ON DATABASE ecrire_prod to $user_you_want; postgres=# \q

##Configure Nginx

For your blog to be seen by the world, you need a server to dispatch request to rails. In this tutorial, Nginx will be the server used. You will have to edit /etc/nginx/nginx.conf to have the following settings.

worker_processes 1;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 64;

sendfile        on;

keepalive_timeout  65;

upstream rails {
     server 127.0.0.1:3000 fail_timeout=0;
}

server {
    listen  80;
    rewrite ^(.*) http://yourblogdomain.com$1 permanent;
}

server {
    listen       80;
    server_name  yourblogdomain.com;

    location / {
            root            /srv/http/ecrire/public;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host   $http_host;
            proxy_redirect      off;
            proxy_pass      http://rails;
    }

    location ~ ^/(assets)/  {
            root /srv/http/ecrire/public;
            gzip_static on; # to serve pre-gzipped version
            expires max;
            add_header Cache-Control public;
    }
}

} You will have to replace yourblogdomain.com with your domain name. You will have to restart nginx to make the changes effective.

sudo service nginx restart

sudo chkconfig --add nginx sudo chkconfig --levels 235 nginx on

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