LAMP及LNMP测试环境快速构建(yum版)
2016-03-01 13:09
543 查看
######################################################################### # File Name: lamp_yum_install.sh # Author: xxx # Mail: xxx@qq.com # Created Time: 2015年10月09日 星期五 06时13分20秒 # Description : this is scripts use to lamp install # Version : v1.0 ######################################################################### #!/bin/bash . /etc/init.d/functions RED_COLOR='\E[1;31m' GREEN_COLOR='\E[1;32m' YELLOW_COLOR='\E[1;33m' BLUE_COLOR='\E[1;34m' RES='\E[0m' apache_install(){ yum -y install httpd httpd-devel cp /etc/httpd/conf/httpd.conf{,.`date +%Y%m%d`} sed -i s'/#ServerName www.example.com:80/ServerName 127.0.0.1:80/g' /etc/httpd/conf/httpd.conf /etc/init.d/httpd start chkconfig httpd on } mysql_install(){ yum -y install mysql mysql-server mysql-devel /etc/init.d/mysqld start /usr/bin/mysqladmin -u root password '123456' chkconfig mysqld on } php_install(){ yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap } lamp_test(){ /etc/init.d/httpd restart cat>>/var/www/html/index.php<<EOF <?php phpinfo(); ?> EOF cat >/var/www/html/mysql.php<<EOF <?php //\$link_id=mysql_connect('主机名','用户','密码'); \$link_id=mysql_connect('localhost','root','123456') or mysql_error(); if(\$link_id){ echo "mysql successful by mads!"; }else{ echo mysql_error(); } ?> EOF } main(){ apache_install mysql_install php_install lamp_test } main
######################################################################### # File Name: lnmp_yum_install.sh # Author: xxx # Mail: xxx@qq.com # Created Time: 2015年10月09日 星期五 06时17分02秒 # Description : this is scripts use to lnmp install # Version : v1.0 ######################################################################### #!/bin/bash . /etc/init.d/functions RED_COLOR='\E[1;31m' GREEN_COLOR='\E[1;32m' YELLOW_COLOR='\E[1;33m' BLUE_COLOR='\E[1;34m' RES='\E[0m' nginx_install(){ yum -y install nginx /etc/init.d/nginx start chkconfig nginx on } mysql_install(){ yum -y install mysql mysql-server mysql-devel /etc/init.d/mysqld start /usr/bin/mysqladmin -u root password '123456' chkconfig mysqld on } php_install(){ yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm /etc/init.d/php-fpm start chkconfig php-fpm on #nginx setup cp /etc/nginx/conf.d/default.conf{,.`date +%Y%m%d`} sed -i '17s/index.html/index.php index.html/g' /etc/nginx/conf.d/default.conf sed -i '39,46s/#//g' /etc/nginx/conf.d/default.conf sed -i '44s/\/scripts/$document_root/g' /etc/nginx/conf.d/default.conf #php-fpm setup cp /etc/php-fpm.d/www.conf{,.`date +%Y%m%d`} sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf } lnmp_test(){ /etc/init.d/nginx restart cat>>/usr/share/nginx/html/index.php<<EOF <?php phpinfo(); ?> EOF cat >/usr/share/nginx/html/mysql.php<<EOF <?php //\$link_id=mysql_connect('主机名','用户','密码'); \$link_id=mysql_connect('localhost','root','123456') or mysql_error(); if(\$link_id){ echo "mysql successful by mads!"; }else{ echo mysql_error(); } ?> EOF } main(){ nginx_install mysql_install php_install lnmp_test } main
相关文章推荐
- android wifi 无线调试
- LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP
- Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- LNMP源码安装(RHEL)
- CentOS6 编译安装LNMP步骤
- shell字符串操作详解
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法
- Shell脚本解压rpm软件包
- Linux Shell 数组建立及使用技巧