Linode VPS的强大功能—StackScripts

2012年7月5日 | 分类: Linode | 标签: ,

在部署CentOS的时候发现了linode的一个非常好的功能叫StackScripts,主要的作用就是在部署新系统的时候自动帮你安装一些常用的软件,而StackScripts用户也可以自定义,也可以用以前别人写好的,极大的提高了部署新服务器的效率。有的StackScripts可以直接帮助你部署服务器+LAMP+Wordpress,十分的强大。
具体进入位置如下:

如果你没有StackScripts,可能出现以下界面:

你可以在以下界面增加StackScripts:

下面给出一个Install Nginx, PHP 的StackScripts

#!/bin/bash

######################
# START Base Install #
######################
# <UDF name=&quot;name&quot; Label=&quot;System Hostname&quot; />
# <UDF name=&quot;public_ip&quot; Label=&quot;System IP address Public&quot; />
# <UDF name=&quot;public_gateway&quot; Label=&quot;Public Gateway&quot; />
# <UDF name=&quot;private_ip&quot; Label=&quot;System IP address Private&quot; />
source <ssinclude StackScriptID=&quot;4269&quot;>

apply_hostname -f &quot;$NAME&quot;
setup_network -f &quot;$NAME&quot; &quot;$PUBLIC_IP&quot; &quot;$PUBLIC_GATEWAY&quot; &quot;$PRIVATE_IP&quot;
install_keys
set_timezone
update_system
####################
# END Base Install #
####################

###############################
# START Install Nginx and PHP #
###############################

function remi_rpm {
	## Import the REMI rpm
	
	## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
	rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
 
	## CentOS 6 and Red Hat (RHEL) 6 ##
	rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
}

function nginx_repo {
	echo -e &quot;[nginx] \nname=nginx repo \nbaseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/ \ngpgcheck=0 \nenabled=1&quot; > /etc/yum.repos.d/nginx.repo
}

function install_php {
	yum -y --enablerepo=remi install nginx php php-fpm php-common
	yum -y --enablerepo=remi install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
}

function setup_nginx {
	chkconfig httpd off
	chkconfig --add nginx
	chkconfig --levels 235 nginx on
	chkconfig --add php-fpm
	chkconfig --levels 235 php-fpm on
	
	mkdir /etc/nginx/sites-available
	mkdir /etc/nginx/sites-enabled
	
	# Configure PHP
	wget -N -P /etc/php-fpm.d/ 192.168.129.23/etc/php-fpm.d/www.conf
	wget -N -P /etc/ 192.168.129.23/etc/php-fpm.conf
	wget -N -P /etc/ 192.168.129.23/etc/php.ini
	
	# Download the nginx config ** SHOULD PASSWORD PROTECT THIS, FOR NOW ITS PRIVATE NETWORK **
	wget -N -P /etc/nginx/ 192.168.129.23/etc/nginx/nginx.conf
}

# Run these once everything has been configured No reason to do it till then
function restart_service {
	/etc/init.d/httpd stop
	/etc/init.d/nginx restart
	/etc/init.d/php-fpm restart
}

remi_rpm
nginx_repo
install_php
setup_nginx
restart_service

#############################
# END Install Nginx and PHP #
#############################

# GlusterFS
yum -y install wget fuse fuse-libs
cd /tmp
wget http://download.gluster.com/pub/gluster/glusterfs/LATEST/CentOS/6/glusterfs-core-3.2.6-1.el6.x86_64.rpm
wget http://download.gluster.com/pub/gluster/glusterfs/LATEST/CentOS/6/glusterfs-fuse-3.2.6-1.el6.x86_64.rpm
wget http://download.gluster.com/pub/gluster/glusterfs/LATEST/CentOS/6/glusterfs-geo-replication-3.2.6-1.el6.x86_64.rpm

rpm -Uvh glusterfs-core-3.2.5-2.el6.x86_64.rpm
rpm -Uvh glusterfs-fuse-3.2.5-2.el6.x86_64.rpm
rpm -ivh glusterfs-geo-replication-3.2.5-2.el6.x86_64.rpm

/etc/init.d/glusterd start
chkconfig glusterd on
目前还没有任何评论.