Skip to content

Instantly share code, notes, and snippets.

@oodavid
Created March 27, 2012 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oodavid/2213999 to your computer and use it in GitHub Desktop.
Save oodavid/2213999 to your computer and use it in GitHub Desktop.
CentOS AMP Server Setup

CentOS AMP Server Setup

I think I'd like to write (for fairly perverse reasons) a script that will setup something like this on a CentOS server:

  • Got CentOS?
  • Got root?
    • Update CentOS
    • Set hostname, timezone etc
    • Install Apache, MySQL, PHP, ImageMagick, S3cmd, Git etc.
    • Setup Git with Apache user and pull from github / bitbucket to /var/www/html/
    • Pull MySQL from Amazon S3 (if we can?)
    • Setup CRON: MySQL nightlies, File nightlies
    • Add system user(s)
    • Setup firewall

Probably going to use this lovely gist as an excellent starting point:

https://gist.github.com/2123030

This for adding domains

https://gist.github.com/1106743

#!/bin/bash
#
# Prompts for all the things we need to setup a server
#
echo -e " "
echo -e " . ____ . _____________________________________"
echo -e " |/ \| | |"
echo -e "[| \e[1;31m♥ ♥\e[00m |] | CentOS Server Setup Script v.0.1 |"
echo -e " |___==___| / © oodavid 2012 |"
echo -e " | |"
echo -e " | \e[1;30mI will be asking lots of questions!\e[00m |"
echo -e " |_____________________________________|"
echo -e " "
# Must be root
if [[ ! "root" = "$(whoami)" ]] ; then
echo -e "\e[1;31mWARNING: This script must be run as root...\e[00m"
exit
fi
# MACHINE NAME
echo -e "\e[1;32mMACHINE: Enter the computer hostname\e[00m [eg: workserver1]"
read MACHINE_NAME
# MySQL ROOTPASS
echo -e "\e[1;33mMYSQL: Enter the root MySQL Password\e[00m"
read MYSQL_ROOTPASS
# MySQL PORT
echo -e "\e[1;33mMYSQL: Enter a new port\e[00m [eg: higher than 5000 for extra security, 3306 for simplicity]"
read -e -i "3306" MYSQL_PORT
# S3 BACKUPS
echo -e "\e[1;34mS3 BACKUPS: Perform nightly backups to Amazon S3?\e[00m [y/n]"
read S3
if [[ $S3 == "Y" || $S3 == "y" ]]; then
# Amazon Access Key ID
echo -e "\e[1;34mS3 BACKUPS: Enter your Amazon Access Key ID\e[00m [eg: AKTPHISNYWMROGYBQBQM]"
read S3_KEY
# Amazon Secret Access Key
echo -e "\e[1;34mS3 BACKUPS: Enter your Amazon Secret Access Key\e[00m [k8wmg97ddfsB5K9/OdInWAWfapqnGhisdNFNASFf]"
read S3_SECRET
# Amazon Bucket
echo -e "\e[1;34mS3 BACKUPS: Enter the name of your bucket\e[00m [eg: my.bucket]"
read S3_BUCKET
fi
# Git Name
echo -e "\e[1;35mGIT: Enter the Git Name\e[00m [eg: David King]"
read GIT_NAME
# Git Email
echo -e "\e[1;35mGIT: Enter the Git Email Address\e[00m [eg: david@oodavid.com]"
read GIT_EMAIL
# GitHub?
echo -e "\e[1;35mGIT: Are you using github?\e[00m [y/n]"
read GITHUB
if [[ $GITHUB == "Y" || $GITHUB == "y" ]]; then
# GitHub Username
echo -e "\e[1;35mGIT: Enter your GitHub username\e[00m [eg: oodavid]"
read GITHUB_USER
# GitHub Token
echo -e "\e[1;35mGIT: Enter your Amazon Secret Access Key\e[00m [eg: 0123456789yourf0123456789token]"
read GITHUB_TOKEN
fi
# SSL
echo -e "\e[1;36mSSL: Install SSL cert?\e[00m [y/n]"
# USERS
echo -e "\e[1;32mUSERS: Lock root access?\e[00m [y/n]"
echo -e "\e[1;32mUSERS: Add users?\e[00m [y/n]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment