A few notes on installing and configuring a CentOS Linode server

I just got a new CentOS Linux server at Linode, and installed a bunch of software on it that I need to run a couple of Drupal websites and a Play Framework website, and here are my very cryptic notes from that installation process. (Sorry, these are more for me than for you.)

First, I installed all the necessary Linux stuff:

---++ Enable Firewall, Secure ssh

# vi /etc/ssh/sshd_config
    # ----------------------------------------------------------
    # AJA: see http://wiki.centos.org/HowTos/Network/SecuringSSH
    # AJA: see http://centoshelp.org/security/securing-sshd/
    # ----------------------------------------------------------
    Port MYPORT
    AllowUsers MYUSER
    LoginGraceTime 1m
    PermitRootLogin no
    MaxAuthTries 6
    MaxStartups 4

# service sshd restart

---++ Add Non-root User

# adduser USERNAME
# passwd USERNAME

Next, I added the software I needed, including PHP stuff for Drupal and Java and MongoDB stuff for my Play Framework app:

---++ Add Software

* install java
  i don't think i've installed the right jvm, so i've skipped that here. it looks like
  i should have done this:
  http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/

* install mongo
  http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/

* install nginx
  followed these notes:
  http://www.cyberciti.biz/faq/install-nginx-centos-rhel-6-server-rpm-using-yum-command/
  (1)
  wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
  (2)
  yum install nginx

* PLAY! + MONGO
  http://blog.knoldus.com/2012/08/02/working-with-play-framework-using-scala-and-mongodb/
  http://mongodb.github.io/casbah/tutorial.html

* install mysql
  yum install mysql-server
  chkconfig mysqld on
  service mysqld start
  /usr/bin/mysql_secure_installation
  PASSWORD: MYPASSWORD

* install php
  yum install php-mysql php-devel php-gd php-xmlrpc

* install apache/httpd

  yum install httpd
  chkconfig httpd on
  chkconfig --list httpd
 
  later: need to install 'rpaf' module to get IP addresses working
  (http://stderr.net/apache/rpaf/)

After this, I started to configure the added software:

---++ NGINX

Play Config Info: http://www.playframework.com/documentation/2.1.x/HTTPServer

Enable nginx service:

  # chkconfig nginx on

Commands:

  # service nginx start
  # service nginx stop
  # service nginx restart
  # service nginx status
  # service nginx reload

Edit:

  /etc/nginx/nginx.conf

More config:

  # mount the myapp client, which is served up by apache
  location /client {
      proxy_pass        http://myappclient:8001/;
      proxy_set_header  X-Real-IP $remote_addr;
  }

  # mount the myapp server, which is served up by the play framework console
  location /server {
      proxy_pass        http://myappserver:8002/;
      proxy_set_header  X-Real-IP  $remote_addr;
  }


---++ MongoDB

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/
http://docs.mongodb.org/manual/faq/fundamentals/
http://docs.mongodb.org/manual/faq/diagnostics/

* "Uses .rpm packages as the basis of the installation. 10gen publishes packages of the MongoDB releases as .rpm packages for easy installation and management for users of CentOS..."

# Step 1:
# vi /etc/yum.repos.d/10gen.repo
  [10gen]
  name=10gen Repository
  baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
  gpgcheck=0
  enabled=1

# Step 2:
# yum install mongo-10gen mongo-10gen-server

# Configuration:

   * configuration file:  /etc/mongod.conf
   * control script:  /etc/rc.d/init.d/mongod
   * This MongoDB instance will store its data files in the /var/lib/mongo and its log files in /var/log/mongo, and run using the mongod user account.

* Commands

   * To start on reboot: chkconfig mongod on
   * service mongod start
   * service mongod restart
   * service mongod stop

* Using/Testing

   * mongo (client command)
   * (ugh: starting and stopping is insanely slow on A2)

   WARNING: You are running in OpenVZ. This is known to be broken!!!

* On the Production server

  ...
  $ mongo
  mongo> use mydb
  mongo> db.users.save({"email":"MY_EMAIL_ADDRESS", "name":"Alvin Alexander", "password":"MYPASSWORD"})
  ...

There was more to it than this, such as the necessary firewall configuration, but these are most of my notes.