Created
February 26, 2011 01:42
-
-
Save xuyuanme/844836 to your computer and use it in GitHub Desktop.
Install Nginx and config Google ghs proxy
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 | |
# Install Nginx and config Google ghs proxy, tested on Amazon EC2 Linux | |
# You need first to add a domain A record point ghs to the server which runs Nginx | |
# and then alias sub-domain to ghs.your_domain_name | |
# Author: Yuan XU | |
# Version: 0.1 | |
# URL: blog.xuyuan.me | |
if [ -z $1 ]; then | |
echo "Usage: nginx.sh [domain_name]" | |
echo "For example: nginx.sh example.com" | |
exit 1 | |
fi | |
domain_name=$1 | |
echo "Install Nginx and config Google ghs for domain $1" | |
yum erase -y nginx | |
yum update -y | |
yum install nginx -y | |
wget https://gist.github.com/raw/844774/97504b89ff50f355500334513ef6538a1e98e547/nginx.conf | |
rc=$? | |
if [ $rc -gt 0 ]; then | |
echo "Failed to download config file for Nginx. Exit with error." | |
exit 1 | |
fi | |
sed "s/zexample/$domain_name/g" nginx.conf > nginx.conf.tmp | |
rm -f nginx.conf | |
mv nginx.conf.tmp /etc/nginx/nginx.conf | |
/etc/init.d/nginx start | |
rc=$? | |
if [ $rc -gt 0 ]; then | |
echo "Failed to start Nginx. Exit with error." | |
exit 1 | |
fi | |
echo "Nginx is installed and running. Please point sub-domain to ghs.$domain_name" | |
echo "If you need customized config, you can edit /etc/nginx/nginx.conf" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment