Created
January 8, 2012 01:50
-
-
Save kaz29/1576823 to your computer and use it in GitHub Desktop.
CakePHP Setup Script for NiftyCloud - Ubuntu 10.04 64bit Plain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export CAKEPHP_VERSION=2.0.5 | |
export CAKEPHP_PATH=/usr/local/app | |
if [ ! -d $CAKEPHP_PATH ] | |
then | |
mkdir $CAKEPHP_PATH | |
fi | |
# IPアドレスを取得 | |
export IPADDR=`ip addr show | grep eth0 | grep 'inet *' | awk '{print $2;}' | cut -f1 -d '/'` | |
# apache2,php5インストール | |
apt-get install -y apache2 apache2-mpm-prefork apache2-utils libapache-mod-security libapache2-mod-php5 \ | |
php5 php5-curl php5-cli php5-xdebug php5-mcrypt php-pear php5-common php5-gd php5-ldap php5-xsl php5-intl php-apc | |
# FW設定更新 | |
ufw allow 80 | |
cd $CAKEPHP_PATH | |
wget --no-check-certificate "https://github.com/cakephp/cakephp/tarball/$CAKEPHP_VERSION" | |
tar xvfz $CAKEPHP_VERSION | |
mv cakephp-* cakephp | |
chmod -R go+w $CAKEPHP_PATH/cakephp/app/tmp | |
rm -Rf $CAKEPHP_VERSION | |
## Security.salt を生成 | |
/sbin/ifconfig > /tmp/hashseed | |
/bin/ps aux >> /tmp/hashseed | |
/bin/date >> /tmp/hashseed | |
export 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_PATH/cakephp/app/Config/core.php | |
## Security.cipherSeed を更新 | |
/bin/sed -i.orig -e "s/76859309657453542496749683645/$CIPHER/g" $CAKEPHP_PATH/cakephp/app/Config/core.php | |
# Apacheの設定 | |
a2enmod rewrite | |
cat <<_EOT_ 1>/etc/apache2/sites-available/cakephp | |
<VirtualHost *:80> | |
ServerName $IPADDR | |
DocumentRoot "$CAKEPHP_PATH/cakephp/app/webroot" | |
ErrorLog /var/log/apache2/cakephp_error_log | |
CustomLog /var/log/apache2/cakephp_access_log combined | |
RewriteEngine on | |
RewriteLogLevel 0 | |
<Directory "$CAKEPHP_PATH/cakephp/webroot"> | |
Options FollowSymLinks Includes | |
AllowOverride All | |
order allow,deny | |
allow from all | |
</Directory> | |
</VirtualHost> | |
_EOT_ | |
rm /etc/apache2/sites-enabled/000-default | |
cd /etc/apache2/sites-enabled | |
a2ensite cakephp | |
# PHPの設定を変更 | |
/bin/sed -i.orig -e "s/;date.timezone =/date.timezone = Asia\/Tokyo/g" /etc/php5/apache2/php.ini | |
/bin/sed -i.orig -e "s/;date.timezone =/date.timezone = Asia\/Tokyo/g" /etc/php5/cli/php.ini | |
/bin/sed -i.orig -e "s/# configuration/; configuration/g" /etc/php5/cli/conf.d/mcrypt.ini | |
## PHPUnitをインストール | |
pear upgrade-all | |
pear config-set auto_discover 1 | |
pear install pear.phpunit.de/PHPUnit | |
# apacheを再起動 | |
service apache2 restart | |
echo "==== インストール終了 ====" | |
echo "以下のコマンドを実行してMySQLをインストールしてください。" | |
echo "curl http://s3sync.rb.ncss.nifty.com/mysql_for_cakephp2.sh | sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "setup started. Now updating packages..." > /root/_setup.log | |
/bin/cat <<EOF > /etc/rc.local | |
apt-get update | |
apt-get -y upgrade | |
apt-get install -y curl git-core | |
curl https://raw.github.com/gist/1576823/7859b65f36ae4c79b8c3298ec683879d95e3955c/cakephp2.sh | sh | tee -a /root/_setup.log | |
/bin/sed -i.orig -e "s/apt/#apt/g" /etc/rc.local | |
/bin/sed -i.orig -e "s/curl https/#curl https/g" /etc/rc.local | |
/bin/sed -i.orig -e "s/\/bin\/sed/#\/bin\/sed/g" /etc/rc.local | |
exit 0 | |
EOF | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export CAKEPHP_PATH=/usr/local/app | |
# mysqlインストール | |
apt-get install -y mysql-server mysql-common mysql-client php5-mysql | |
# apacheを再起動 | |
service apache2 restart | |
# 試験用のデータベースを作成 | |
echo "開発用データベースを作成します。MySQLインストール時に指定したパスワードを入力してください。" | |
echo "CREATE DATABASE development CHARACTER SET utf8;" | mysql -u root -p | |
# database設定ファイルを作成 | |
cat <<_EOT_ 1>$CAKEPHP_PATH/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', | |
); | |
var \$test = array( | |
'datasource' => 'Database/Mysql', | |
'persistent' => false, | |
'host' => 'localhost', | |
'login' => 'root', | |
'password' => '', | |
'database' => 'development', | |
'prefix' => 'test', | |
'encoding' => 'UTF8', | |
); | |
} | |
_EOT_ | |
echo "==== インストール終了 ====" | |
echo "MySQLインストール時に指定したパスワードを下記のファイルに設定してください。" | |
echo "vim /usr/local/app/cakephp/app/Config/database.php" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment