Skip to content

Instantly share code, notes, and snippets.

@kaz29
Created October 13, 2011 16:40
Show Gist options
  • Save kaz29/1284739 to your computer and use it in GitHub Desktop.
Save kaz29/1284739 to your computer and use it in GitHub Desktop.
CakePHP2.0.0 setup on NiftyCloud CentOS5.6
#!/bin/sh
CAKEPHP_PAH=/usr/local/app
if [ ! -d $CAKEPHP_PAH ]
then
mkdir $CAKEPHP_PAH
fi
# IPアドレスを取得
IPADDR=`ip addr show | grep eth0 | grep 'inet *' | awk '{print $2;}' | cut -f1 -d '/'`
# EPELリポジトリ追加
wget http://ftp.riken.jp/Linux/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
rm -f epel-release-5-4.noarch.rpm
/bin/sed -i.orig -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
# Remiリポジトリ追加
wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm --import RPM-GPG-KEY-remi
rpm -Uvh remi-release-5.rpm
rm -f RPM-GPG-KEY-remi remi-release-5.rpm
# git,screen をインストール
yum --enablerepo=remi,epel -y install git.x86_64 screen.x86_64
sleep 3
# Apache/MySQL/PHP5.3.xをインストール
yum -y --enablerepo=remi,epel,dag install httpd.x86_64 httpd-devel.x86_64 \
mysql.x86_64 mysql-server.x86_64 php53.x86_64 php53-mbstring.x86_64 php53-mysql.x86_64 \
php53-gd.x86_64 php53-cli.x86_64 php53-xml.x86_64 php53-devel.x86_64 \
php-pear.noarch php-pecl-xdebug.x86_64 pcre-devel.x86_64 php-pecl-apc.x86_64 \
net-snmp
# PHPの設定を変更
/bin/sed -i.orig -e "s/;date.timezone =/date.timezone = Asia\/Tokyo/g" /etc/php.ini
# Apacheの設定
mkdir /etc/httpd/sites-enabled
mkdir /etc/httpd/sites-available
cat <<_EOT_ 1>/etc/httpd/conf.d/vhosts.conf
NameVirtualHost *:80
Include sites-enabled/*.conf
_EOT_
cat <<_EOT_ 1>/etc/httpd/sites-available/default.conf
<VirtualHost *:80>
ServerName $IPADDR
DocumentRoot "$CAKEPHP_PAH/cakephp/app/webroot"
ErrorLog logs/cakephp_error_log
CustomLog logs/cakephp_access_log combined
RewriteEngine on
RewriteLogLevel 0
<Directory "$CAKEPHP_PAH/cakephp/webroot">
Options FollowSymLinks Includes
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
_EOT_
ln -s /etc/httpd/sites-available/default.conf /etc/httpd/sites-enabled/000_default.conf
/bin/sed -i.orig -e "s/ AllowOverride None/ AllowOverride All/g" /etc/httpd/conf/httpd.conf
/bin/sed -i.orig2 -e "s/DirectoryIndex index.html index.html.var/DirectoryIndex index.php index.html index.html.var/g" /etc/httpd/conf/httpd.conf
# snmpの設定
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
cat <<_EOT_ 1>/etc/snmp/snmpd.conf
rocommunity niftycloud 10.100.0.14 .1.3.6.1.
rocommunity niftycloud 10.100.8.15 .1.3.6.1.
rocommunity niftycloud 10.100.16.13 .1.3.6.1.
disk / 10000
_EOT_
# MySQL,snmpdを起動
service mysqld start
service snmpd start
# MySQL,Apache,snmpdを自動起動設定
chkconfig mysqld on
chkconfig httpd on
chkconfig snmpd on
# 試験用のデータベースを作成
echo "CREATE DATABASE development CHARACTER SET utf8;" | mysql -u root
# CakePHPをインストール
cd $CAKEPHP_PAH
wget --no-check-certificate "https://github.com/cakephp/cakephp/tarball/2.0.5"
tar xvfz 2.0.5
mv cakephp-cakephp-6864406 cakephp
chmod -R go+w $CAKEPHP_PAH/cakephp/app/tmp
rm -Rf 2.0.5
## Security.salt を生成
/sbin/ifconfig > /tmp/hashseed
/bin/ps aux >> /tmp/hashseed
/bin/date >> /tmp/hashseed
SALT=`/usr/bin/sha1sum /tmp/hashseed | awk {'print $1'}`
/bin/rm -Rf /tmp/hashseed
## Security.cipherSeed を生成
export CIPHER=""
for i in `seq 1 29`
do
SEED=`expr $RANDOM % 10`
CIPHER=$CIPHER$SEED
done
## Security.salt を更新
/bin/sed -i.orig -e "s/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/$SALT/g" $CAKEPHP_PAH/cakephp/app/Config/core.php
## Security.cipherSeed を更新
/bin/sed -i.orig -e "s/76859309657453542496749683645/$CIPHER/g" $CAKEPHP_PAH/cakephp/app/Config/core.php
cat <<_EOT_ 1>$CAKEPHP_PAH/cakephp/app/Config/database.php
<?php
class DATABASE_CONFIG {
var \$default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'development',
'prefix' => '',
'encoding' => 'UTF8',
);
}
_EOT_
## PHPUnitをインストール
pear upgrade-all
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
cd
# Apacheを起動
service httpd start
echo "インストール終了!"
echo "URL => http://$IPADDR/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment