[USP友の会]第1回 一撃サーバー構築シェルスクリプト勉強会 回答#4
WordPressインストール(クリックで大きくなります)
# Create DocumentRoot
mkdir -p /var/www/${ETH0}
cd ${HOME}
mkdir bin
cd bin
wget https://raw.githubusercontent.com/nullpopopo/wpdl/master/bin/wpdl
chmod 700 wpdl
cd ${HOME}
bin/wpdl
cd ${HOME}/src/wordpress/current/
tar xzf latest-ja.tar.gz
cd wordpress/
cp -pr * /var/www/${ETH0}
cd /var/www/${ETH0}
cp -p wp-config-sample.php wp-config.php
chmod 660 wp-config.php
sed -i s/database_name_here/$(grep ^DBPARAM ${PARAMFILE} | awk '{print $2}')/g wp-config.php
sed -i s/username_here/$(grep ^DBPARAM ${PARAMFILE} | awk '{print $3}')/g wp-config.php
sed -i s/password_here/$(grep ^DBPARAM ${PARAMFILE} | awk '{print $4}')/g wp-config.php
sed -i s/'put your unique phrase here'/$(cat /dev/urandom | tr -dc '[:alnum:]'| head -c 32)/g wp-config.php
cd /var/www/
chown -R nginx:${USER} ${ETH0}
chmod -R g+w ${ETH0}
nginx設定(クリックで大きくなります)
# http://wpdocs.sourceforge.jp/Nginx
cd /etc/nginx/
cp -p nginx.conf nginx.conf.orig
# worker_processesの数をコア数に合わせる
sed -i "s/worker_processes[[:space:]]+[0-9]+/worker_processes $(cat /proc/cpuinfo | grep processor | wc -l)/g" nginx.conf
cd conf.d
# Per Site Configuration
cat << _EOL_ > 000_VHOST.conf
server {
server_name ${ETH0};
root /var/www/${ETH0};
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
index index.php index.html index.htm;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
_EOL_
service nginx start
chkconfig nginx on
再起動
reboot
回答つきスライドはこちらになります。