判断目录是否存在、
判断文件是否存在啊
判断目录是否可执行啊
共享一个选择命令执行的shell 脚本
service httpd stop case "$1" in 5.2) exit 1 ;; 5.3) ln -sf /a/apps/php-5.3.29/lib/libphp5.so /a/apps/httpd-2.4.12/modules/libphp5.so ln -sf /a/apps/php-5.3.29/bin/php /usr/bin/php ;; 5.4) ln -sf /a/apps/php-5.4.41/lib/libphp5.so /a/apps/httpd-2.4.12/modules/libphp5.so ln -sf /a/apps/php-5.4.41/bin/php /usr/bin/php ;; 5.5) ln -sf /a/apps/php-5.5.25/lib/libphp5.so /a/apps/httpd-2.4.12/modules/libphp5.so ln -sf /a/apps/php-5.5.25/bin/php /usr/bin/php ;; *) echo "Usage: $1 {5.2|5.3|5.4|5.5}" service httpd start exit 1 ;; esac service httpd start
切换PHP版本shell脚本
按照命令动态apache虚拟主机
httpd_Vsersion=2.4.12 DomainName= #解析域名和绑定域名 DomainName=$1 mkdir -p /a/domains/${DomainName}/public_html chown -R www:www /a/domains/${DomainName}/public_html log_path=\"/a/domains/${DomainName}/public_html/${DomainName}/ errorlog=${log_path}${DomainName}-errorlog.log\" customlog=${log_path}${DomainName}.log\" #写入配置文件 cat > /a/apps/httpd-${httpd_Vsersion}/conf/vhosts/${DomainName}.conf <<EOF <VirtualHost *:80> ServerName $1 DocumentRoot /a/domains/${DomainName}/public_html ErrorLog ${errorlog} CustomLog ${customlog} common </VirtualHost> EOF echo ${DomainName}" vhost create success , website directory : /a/domains/"${DomainName}"/public_html/" service httpd restart exit 1