Skip to content

Instantly share code, notes, and snippets.

@kaz29 kaz29/apc_install.sh

Created May 28, 2011
Embed
What would you like to do?
CakePHP setup on NiftyCloud
#!/bin/sh
# APCをインストール
pecl install apc
cat <<_EOT_ 1>/etc/php.d/apc.ini
extension=apc.so
_EOT_
service httpd restart
#!/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 '/'`
# Dagリポジトリを追加
wget http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm --import RPM-GPG-KEY.dag.txt
cat <<_EOT_ 1>/etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el5/en/\$basearch/dag/
gpgcheck=1
enabled=0
_EOT_
# EPELリポジトリを追加
wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
# 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
sleep 3
# Apache/MySQL/PHP5.3.xをインストール
yum -y --enablerepo=remi-test,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 \
net-snmp
# PHPの設定を変更
/bin/sed -i.orig -e "s/;date.timezone =/date.timezone = Asia\/Tokyo/g" /etc/php.ini
# iptablesのルールを変更(http(80)のアクセスを許可,基本監視用にsnmpポートをあける)
cat <<_EOT_ 1>/tmp/iptables.sed
/-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j ACCEPT/a -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 80 -j ACCEPT
/-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j ACCEPT/a -A RH-Firewall-1-INPUT -s 10.100.0.14 -i eth1 -p udp -m udp --dport 161 -j ACCEPT
/-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j ACCEPT/a -A RH-Firewall-1-INPUT -s 10.100.8.15 -i eth1 -p udp -m udp --dport 161 -j ACCEPT
/-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j ACCEPT/a -A RH-Firewall-1-INPUT -s 10.100.16.13 -i eth1 -p udp -m udp --dport 161 -j ACCEPT
_EOT_
/bin/sed -i.orig -f /tmp/iptables.sed /etc/sysconfig/iptables
/etc/init.d/iptables restart
# 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
# 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,Apache,snmpdを起動
service mysqld start
service httpd 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/zipball/1.3.8"
unzip cakephp-cakephp-1.3.8-0-g33afe21.zip
mv cakephp-cakephp-41cd0e4 cakephp
chmod -R go+w $CAKEPHP_PAH/cakephp/app/tmp
rm -Rf cakephp-cakephp-1.3.8-0-g33afe21.zip
## 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 を生成
CIPHER=""
for i in `seq 1 29`
do
SEED=`expr $RANDOM % 10`
CIPHER=$CIPHER$SEED
done
/bin/sed -i.orig -e "s/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/$SALT/g" $CAKEPHP_PAH/cakephp/app/config/core.php
/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(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'development',
'prefix' => '',
'encoding' => 'UTF8',
);
}
_EOT_
# SimpleTestをインストール
cd $CAKEPHP_PAH/cakephp/vendors
wget "http://downloads.sourceforge.net/project/simpletest/simpletest/simpletest_1.0.1/simpletest_1.0.1.tar.gz?r=http%3A%2F%2Fwww.simpletest.org%2Fen%2Fdownload.html&ts=1305249820&use_mirror=jaist"
tar xvfz simpletest_1.0.1.tar.gz
rm -Rf simpletest_1.0.1.tar.gz
# DebugKitをインストール
cd $CAKEPHP_PAH/cakephp/plugins
wget --no-check-certificate "https://github.com/cakephp/debug_kit/tarball/1.3.0"
tar xvfz cakephp-debug_kit-1.3.0-0-g5db6ec7.tar.gz
mv cakephp-debug_kit-9fd0b6d debug_kit
rm -Rf cakephp-debug_kit-1.3.0-0-g5db6ec7.tar.gz
cd
echo "インストール終了!"
echo "-----"
echo "APCのインストールは下記で..."
echo "wget https://gist.github.com/raw/996655/999125f15f78ee90d465287bc4a1a69fbf884403/apc_install.sh"
echo "sh apc_install.sh"
echo "-----"
echo "URL => http://$IPADDR/"
#!/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 '/'`
# Dagリポジトリを追加
wget http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm --import RPM-GPG-KEY.dag.txt
cat <<_EOT_ 1>/etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el5/en/\$basearch/dag/
gpgcheck=1
enabled=0
_EOT_
# EPELリポジトリを追加
wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
# 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
sleep 3
# Apache/MySQL/PHP5.3.xをインストール
yum -y --enablerepo=remi-test,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 \
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
# 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,Apache,snmpdを起動
service mysqld start
service httpd 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/zipball/1.3.8"
unzip cakephp-cakephp-1.3.8-0-g33afe21.zip
mv cakephp-cakephp-41cd0e4 cakephp
chmod -R go+w $CAKEPHP_PAH/cakephp/app/tmp
rm -Rf cakephp-cakephp-1.3.8-0-g33afe21.zip
## 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 を生成
CIPHER=""
for i in `seq 1 29`
do
SEED=`expr $RANDOM % 10`
CIPHER=$CIPHER$SEED
done
/bin/sed -i.orig -e "s/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/$SALT/g" $CAKEPHP_PAH/cakephp/app/config/core.php
/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(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'development',
'prefix' => '',
'encoding' => 'UTF8',
);
}
_EOT_
# SimpleTestをインストール
cd $CAKEPHP_PAH/cakephp/vendors
wget "http://downloads.sourceforge.net/project/simpletest/simpletest/simpletest_1.0.1/simpletest_1.0.1.tar.gz?r=http%3A%2F%2Fwww.simpletest.org%2Fen%2Fdownload.html&ts=1305249820&use_mirror=jaist"
tar xvfz simpletest_1.0.1.tar.gz
rm -Rf simpletest_1.0.1.tar.gz
# DebugKitをインストール
cd $CAKEPHP_PAH/cakephp/plugins
wget --no-check-certificate "https://github.com/cakephp/debug_kit/tarball/1.3.0"
tar xvfz cakephp-debug_kit-1.3.0-0-g5db6ec7.tar.gz
mv cakephp-debug_kit-9fd0b6d debug_kit
rm -Rf cakephp-debug_kit-1.3.0-0-g5db6ec7.tar.gz
cd
echo "インストール終了!"
echo "-----"
echo "APCのインストールは下記で..."
echo "wget https://gist.github.com/raw/996655/999125f15f78ee90d465287bc4a1a69fbf884403/apc_install.sh"
echo "sh apc_install.sh"
echo "-----"
echo "URL => http://$IPADDR/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.