Set up linux box for hosting a-z

Posted by microchasm on Server Fault See other posts from Server Fault or by microchasm
Published on 2010-05-16T17:01:21Z Indexed on 2010/05/17 15:41 UTC
Read the original article Hit count: 322

Filed under:
|
|
|
|

I am in the process of reinstalling the OS on a machine that will be used to host a couple of apps for our business. The apps will be local only; access from external clients will be via vpn only.

The prior setup used a hosting control panel (Plesk) for most of the admin, and I was looking at using another similar piece of software for the reinstall - but I figured I should finally learn how it all works. I can do most of the things the software would do for me, but am unclear on the symbiosis of it all. This is all an attempt to further distance myself from the land of Configuration Programmer/Programmer, if at all possible.

I can't find a full walkthrough anywhere for what I'm looking for, so I thought I'd put up this question, and if people can help me on the way I will edit this with the answers, and document my progress/pitfalls. Hopefully someday this will help someone down the line.

The details:

  • CentOS 5.5 x86_64
  • httpd: Apache/2.2.3
  • mysql: 5.0.77 (to be upgraded)
  • php: 5.1 (to be upgraded)

The requirements:

  • SECURITY!!
    • Secure file transfer
    • Secure client access (SSL Certs and CA)
    • Secure data storage
  • Virtualhosts/multiple subdomains
  • Local email would be nice, but not critical

The Steps:

  • Download latest CentOS DVD-iso (torrent worked great for me).

  • Install CentOS:
    While going through the install, I checked the Server Components option thinking I was going to be using another Plesk-like admin. In hindsight, considering I've decided to try to go my own way, this probably wasn't the best idea.

  • Basic config:
    Setup users, networking/ip address etc. Yum update/upgrade.

  • Upgrade PHP/MySQL:
    To upgrade PHP and MySQL to the latest versions, I had to look to another repo outside CentOS. IUS looks great and I'm happy I found it!
  • Add IUS repository to our package manager

    cd /tmp
    wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-1-1.ius.el5.noarch.rpm
    rpm -Uvh epel-release-1-1.ius.el5.noarch.rpm
    wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1-4.ius.el5.noarch.rpm
    rpm -Uvh ius-release-1-4.ius.el5.noarch.rpm
    yum list | grep -w \.ius\. # list all the packages in the IUS repository; use this to find PHP/MySQL version and libraries you want to install
    

    Remove old version of PHP and install newer version from IUS

    rpm -qa | grep php # to list all of the installed php packages we want to remove
    yum shell  # open an interactive yum shell
    remove php-common php-mysql php-cli #remove installed PHP components
    install php53 php53-mysql php53-cli php53-common #add packages you want
    transaction solve #important!! checks for dependencies
    transaction run #important!! does the actual installation of packages.
    [control+d] #exit yum shell
    php -v
    PHP 5.3.2 (cli) (built: Apr  6 2010 18:13:45)
    

    Upgrade MySQL from IUS repository

    /etc/init.d/mysqld stop
    rpm -qa | grep mysql # to see installed mysql packages
    yum shell
    remove mysql mysql-server #remove installed MySQL components
    install mysql51 mysql51-server mysql51-devel
    transaction solve #important!! checks for dependencies
    transaction run #important!! does the actual installation of packages.
    [control+d] #exit yum shell
    service mysqld start
    
    mysql -v
    Server version: 5.1.42-ius Distributed by The IUS Community Project
    

    Upgrade instructions courtesy of IUS wiki: http://wiki.iuscommunity.org/Doc/ClientUsageGuide


  • Install rssh (restricted shell) to provide scp and sftp access, without allowing ssh login
  • cd /tmp
    wget http://dag.wieers.com/rpm/packages/rssh/rssh-2.3.2-1.2.el5.rf.x86_64.rpm
    rpm -ivh rssh-2.3.2-1.2.el5.rf.x86_64.rpm
    useradd -m -d /home/dev -s /usr/bin/rssh dev
    passwd dev
    

    Edit /etc/rssh.conf to grant access to SFTP to rssh users.

    vi /etc/rssh.conf
    

    Uncomment or add:

    allowscp
    allowsftp
    

    This allows me to connect to the machine via SFTP protocol in Transmit (my FTP program of choice; I'm sure it's similar with other FTP apps).

    rssh instructions appropriated (with appreciation!) from http://www.cyberciti.biz/tips/linux-unix-restrict-shell-access-with-rssh.html


  • Set up virtual interfaces
  • ifconfig eth1:1 192.168.1.3 up #start up the virtual interface
    cd /etc/sysconfig/network-scripts/
    cp ifcfg-eth1 ifcfg-eth1:1 #copy default script and match name to our virtual interface
    vi ifcfg-eth1:1 #modify eth1:1 script
    

    #ifcfg-eth1:1 | modify so it looks like this:
    DEVICE=eth1:1
    IPADDR=192.168.1.3
    NETMASK=255.255.255.0
    NETWORK=192.168.1.0
    ONBOOT=yes
    NAME=eth1:1

    Add more Virtual interfaces as needed by repeating. Because of the ONBOOT=yes line in the ifcfg-eth1:1 file, this interface will be brought up when the system boots, or the network starts/restarts.

    service network restart
    

    Shutting down interface eth0: [ OK ]
    Shutting down interface eth1: [ OK ]
    Shutting down loopback interface: [ OK ]
    Bringing up loopback interface: [ OK ]
    Bringing up interface eth0: [ OK ]
    Bringing up interface eth1: [ OK ]

    ping 192.168.1.3
    

    64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.105 ms


    And this is where I'm at. I will keep editing this as I make progress. Any tips on how to Configure virtual interfaces/ip based virtual hosts for SSL, setting up a CA, or anything else would be appreciated.

    © Server Fault or respective owner

    Related posts about apache

    Related posts about centos