Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active December 15, 2015 10:19
Show Gist options
  • Select an option

  • Save wokamoto/5244571 to your computer and use it in GitHub Desktop.

Select an option

Save wokamoto/5244571 to your computer and use it in GitHub Desktop.
MT と phpMyAdmin のための設定メモ
#!/bin/sh
# user settings
LoginUser='mt'
LoginPass='pass'
# database settings
DBName='mt'
DBUser='mt'
DBPass='pass'
DBRootPass='hoge'
# start
mkdir -p /var/www/html/mt
yum install -y git gcc make
yum install -y zlib-devel gd-devel expat-devel ImageMagick-devel
# setup repo (epel, remi)
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# install nginx
rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install -y --enablerepo=nginx nginx
# install MySQL
yum install -y --enablerepo=remi mysql-server mysql-client mysql-devel
service mysqld start
chkconfig mysqld on
# install PHP
yum install -y --enablerepo=remi php php-devel php-mbstring php-mysql php-gd php-mcrypt php-pear php-apc php-fpm
service php-fpm start
chkconfig php-fpm on
# install perl and CPAN module
yum install -y perl perl-YAML cpan ImageMagick-perl
yes '' | perl -MCPAN -e 'install CPAN'
yes '' | cpan 'CGI'
yes '' | cpan 'Image::Size'
yes '' | cpan 'File::Spec'
yes '' | cpan 'CGI::Cookie'
yes '' | cpan 'DBI'
yes '' | cpan 'DBD::mysql'
yes '' | cpan 'HTML::Entities'
yes '' | cpan 'XML::Parser'
yes '' | cpan 'XML::Atom'
yes '' | cpan 'Archive::Tar'
yes '' | cpan 'Mail::Sendmail'
yes '' | cpan 'GD'
yes '' | cpan 'Archive::Tar'
yes '' | cpan 'Archive::Zip'
yes '' | cpan 'IPC::Run'
yes '' | cpan 'Net::SMTP::TLS'
yes '' | cpan 'Net::SMTP::SSL'
yes '' | cpan 'Net::SSLeay'
yes '' | cpan 'Authen::SASL'
yes '' | cpan 'Crypt::SSLeay'
yes '' | cpan 'Crypt::DSA'
yes '' | cpan 'Cache::File'
cd /root/.cpan/build
SSLEAY=`find . -name "Crypt-SSLeay*" -type d -print`
cd $SSLEAY
echo 'N' | perl Makefile.PL
make
make install
# create user
grep "^$LoginUser:" /etc/passwd > /dev/null
if [ $? == 1 ]; then
useradd -p `perl -e "print(crypt('$LoginPass', 'az'));"` $LoginUser
fi
# setup starman
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
cpanm Task::Plack
cpanm Starman
cpanm XML::Parser XMLRPC::Transport::HTTP::Plack
cpanm CGI::Parse::PSGI
cpanm CGI::Compile
echo '#!/bin/sh
CURDIR=`dirname $0`
cd $CURDIR
/usr/local/bin/starman \
-l 127.0.0.1:18520 \
--pid /var/www/html/mt/pids/mt.pid \
/var/www/html/mt/mt.psgi' > /var/www/html/mt/mt.run
chmod 700 /var/www/html/mt/mt.run
# install MTOS
cd ~/
git clone http://github.com/movabletype/movabletype.git
cd movabletype
make me
cp -R ~/movabletype/* /var/www/html/mt
mkdir /var/www/html/mt/pids
mysql -u root -e "create database $DBName default character set utf8 collate utf8_general_ci;"
mysql -u root -e "grant all on $DBName.* to $DBUser@localhost identified by '$DBPass';"
mysql -u root -e "DELETE FROM mysql.user WHERE User = ''; FLUSH PRIVILEGES;"
mysql -u root -e "update mysql.user set password=password('$DBRootPass') where user='root'; flush privileges;"
echo "## Movable Type configuration file ##
# The CGIPath is the URL to your Movable Type directory
CGIPath /mt/
PIDFilePath /var/www/html/mt/pids/mt.pid
# The StaticWebPath is the URL to your mt-static directory
StaticWebPath /mt/mt-static
#================ DATABASE SETTINGS ==================
ObjectDriver DBI::mysql
Database $DBName
DBUser $DBUser
DBPassword $DBPass
DBHost localhost
## Change setting to language that you want to using.
DefaultLanguage ja" > /var/www/html/mt/mt-config.cgi
chown -R $LoginUser:$LoginUser /var/www/html
chmod 775 /var/www/html
# setup supervisor
yum install -y --enablerepo=epel supervisor
echo "
[program:mt]
user=$LoginUser
command=/var/www/html/mt/mt.run
autostart=true
autorestart=true
stopsignal=QUIT" >> /etc/supervisord.conf
service supervisord start
chkconfig supervisord on
# setup nginx
echo 'upstream mt {
server 127.0.0.1:18520;
}
upstream phpfpm {
server 127.0.0.1:9000;
}
server {
listen 80 default;
server_name _;
root /var/www/html;
index index.html index.htm index.php;
charset utf-8;
client_max_body_size 20M;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
location / {
if ( $request_filename ~ .*\.(jpe?g|gif|png|swf|wmv|flv|ico)$ ) {
break;
expires 365d;
}
if ( $request_filename ~ .*\.(txt|css|js)$ ) {
break;
expires 7d;
}
if ( $request_filename ~ .*\.(xml|gz)$ ) {
break;
expires 1d;
}
}
location ~ \.cgi$ {
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_pass http://mt;
break;
}
location ~ \.php$ {
expires off;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(psgi|run|pid)$ {
return 404;
}
}' > /etc/nginx/conf.d/default.conf
service nginx start
chkconfig nginx on
# setup phpMyAdmin
yum install -y --enablerepo=remi phpMyAdmin
ln -s /usr/share/phpMyAdmin /var/www/html/phpMyAdmin
# end
echo "******************************"
echo "******* MTOS Installed *******"
echo "******* Let's enjoy! *******"
echo "******************************"
@wokamoto

Copy link
Copy Markdown
Author

http://www.h-fj.com/blog/archives/2013/04/10-111542.php@hjfuji さんが修正してくれたので、取り込んでおきました。
thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment