Created
August 9, 2011 21:51
-
-
Save offlinehacker/1135289 to your computer and use it in GitHub Desktop.
Wordpress create
This file contains hidden or 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 | |
WORDPRESS_ROOT=/usr/share/ | |
WORDPRESS_NAME=$1 | |
PASSWORD=$2 | |
DOMAIN=$3 | |
if [ $# -ne 3 ] | |
then | |
echo "Syntax: `basename $0` wordpress_name password domain" | |
exit | |
fi | |
echo "Wordpress root: $WORDPRESS_ROOT" | |
echo "Wordpress name: $WORDPRESS_NAME" | |
echo "Database password: $PASSWORD" | |
echo "Domain: $DOMAIN" | |
mysql -u root -p -e "CREATE DATABASE $WORDPRESS_NAME; | |
GRANT ALL PRIVILEGES ON databasename.* TO \"$WORDPRESS_NAME\"@\"localhost\" IDENTIFIED BY \"$PASSWORD\"; | |
FLUSH PRIVILEGES;" | |
cd $WORDPRESS_ROOT | |
mkdir $WORDPRESS_NAME | |
cd $WORDPRESS_NAME | |
wget http://wordpress.org/latest.zip | |
unzip latest.zip | |
mv wordpress/* . | |
rm -r wordpress | |
IFS=`/bin/echo -ne " \t\n"` | |
nginx_config=$(cat<<EOF | |
server { | |
listen 173.0.62.100:80; #or change this to your public IP address eg 1.1.1.1:80 | |
server_name $DOMAIN; #change this to the domain name, for example www.myblog.com | |
access_log /var/log/$WORDPRESS_NAME.access_log; | |
error_log /var/log/$WORDPRESS_NAME.error_log; | |
location / { | |
root $WORDPRESS_ROOT$WORDPRESS_NAME; | |
index index.php index.html index.htm; | |
# this serves static files that exist without running other rewrite tests | |
if (-f \$request_filename) { | |
expires 30d; | |
break; | |
} | |
# this sends all non-existing file or directory requests to index.php | |
if (!-e \$request_filename) { | |
rewrite ^(.+)$ /index.php?q=$1 last; | |
} | |
} | |
location ~ \.php$ { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $WORDPRESS_ROOT$WORDPRESS_NAME\$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
} | |
EOF | |
) | |
echo "Creating nginx config on: /etc/nginx/sites-enabled/$WORDPRESS_NAME" | |
echo ${nginx_config} > /etc/nginx/sites-enabled/$WORDPRESS_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment