A goal is a dream with a deadline. Much effort, much prosperity.

环境:CentOS release 6.5  2.6.32-431.el6.x86_64

 #!/bin/bash
 #--
 #下为软件版本号、安装路径、数据存放路径、密码、URL等,如有不同、则自行修改变量即可
 #释:ylb为依赖包1/
 #释:path为路径1/
 #释:mysqlcatalog为MySQL的安装路径
 #释:mysqldata为MySQL的数据存放位置
 #释:environment为PHP的环境1为开发版样例文件2为生产版样例文件
 http='httpd-2.2.31'
 mysql='mysql-5.7.2-m12'
 php='php-5.3.28'
 libmcrypt='libmcrypt-2.5.8'
 mhash='mhash-0.9.9.9'
 mcrypt='mcrypt-2.6.8'
 cmake='cmake-2.8.12'
 ZendGuardLoader='ZendGuardLoader-php-5.3-linux-glibc23-x86_64'
 ylb1='zlib-devel libxml2-devel ncurses-devel'
 ylb2='php php-cli php-ldap php-common php-mysql httpd mysql-server'
 path1='/usr/src'
 path2='/usr/local'
 mysqlcatalog='/usr/local/mysql/'
 mysqldata='/usr/local/mysql/data'
 mysqlrootpasswd='
 environment1='php.ini-development'
 environment2='php.ini-production'
 epel='https://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm'
 repo='http://mirrors.aliyun.com/repo/Centos-6.repo'

 aliyum() {
  -i  -t  www.baidu.com
  ]
 then
     mv /etc/yum.repos.d/* /tmp
     wget $epel
     yum -y localinstall epel*.rpm
     wget -O /etc/yum.repos.d/CentOS-Base.repo $repo
     yum clean all
     yum makecache
 else
     echo "Network is not connected"
 fi
 }
 #Install depend
 rpm -q $ylb2 | awk '{print $1}' > b.txt
 sed -i '/^package/d' b.txt
 for i in $(cat b.txt)
 do
     rpm -e $i --nodeps > /dev/null
 done

 yum -y install $ylb1 > /dev/null
 if [ ! $? -eq 0 ]
 then
     aliyum
     yum -y install $ylb1 > /dev/null
 fi
 #Install httpd
 tar xf $http.tar.gz -C $path1
 cd $path1/$http
 ./configure --prefix=$path2/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi && make && make install
 echo $? >> /root/debug.txt
 echo "install apache time" >> /root/debug.txt
 cd ~
 ln -s $path2/httpd/bin/* /usr/local/bin/
 cp $path2/httpd/bin/apachectl /etc/init.d/httpd
 sed -i '1a# chkconfig:35 20 80\n# description:web' /etc/init.d/httpd
 chkconfig --add httpd
 chkconfig httpd on
 chkconfig --list httpd
 sed -i '98aServerName www.wjl.com:80' $path2/httpd/conf/httpd.conf
 service httpd start
 netstat -anpt | grep :80 >> /root/debug.txt
 #Install MySql
 tar xf $cmake.tar.gz -C $path1
 cd $path1/$cmake
 ./configure && gmake && gmake install
 groupadd mysql
 useradd -M -s /sbin/nologin -g mysql mysql
 cd ~
 tar xf $mysql.tar.gz -C $path1
 cd $path1/$mysql
 cmake -DCMAKE_INSTALL_PREFIX=$path2/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc && make && make install
 echo $? >> /root/debug.txt
 echo "install mysql time" >> /root/debug.txt
 cp support-files/my-default.cnf /etc/my.cnf
 cp support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
 chkconfig --add mysqld
 chkconfig --list mysqld
 echo "PATH=$PATH:$path2/mysql/bin" >> /etc/profile
 source /etc/profile
 chown -R mysql:mysql $path2/mysql/
 $path2/mysql/scripts/mysql_install_db --basedir=$mysqlcatalog --datadir=$mysqldata --user=mysql
 service mysqld start
 netstat -anpt | grep :3306 >> /root/debug.txt
 cd ~
 mysqladmin -u root password $mysqlrootpasswd
 #Install PHP
 tar xf $libmcrypt.tar.gz -C $path1
 cd $path1/$libmcrypt
 ./configure
 make && make install
 ln -s $path2/lib/libmcrypt.* /usr/lib/
 cd ~
 tar xf $mhash.tar.gz -C $path1
 cd $path1/$mhash
 ./configure
 make && make install
 ln -s $path2/lib/libmhash* /usr/lib/
 cd ~
 tar xf $mcrypt.tar.gz -C $path1
 cd $path1/$mcrypt
 export LD_LIBRARY_PATH=$path2/lib:$ LD_LIBRARY_PATH
 ./configure
 make && make install
 cd ~
 tar xf $php.tar.gz -C $path1
 cd $path1/$php
 ./configure --prefix=$path2/php5 --with-mcrypt --with-apxs2=$path2/httpd/bin/apxs --with-mysql=$path2/mysql --with-config-file-path=$path2/php5 --enable-mbstring && make && make install
 if [ ! $? -eq 0 ]
 then
     yum -y install libtool*
     ./configure --prefix=$path2/php5 --with-mcrypt --with-apxs2=$path2/httpd/bin/apxs --with-mysql=$path2/mysql --with-config-file-path=$path2/php5 --enable-mbstring && make && make install
 fi
 echo $? >> /root/debug.txt
 echo "install php time" >> /root/debug.txt
 cp $path1/$php/$environment1 $path2/php5/php.ini
 grep -v "^;" /usr/local/php5/php.ini  | grep -v "^$"
 sed -i "/default_charset/s#.*\(default_charset\).*#\1 = "utf-8"#g" $path2/php5/php.ini
 sed -i "/file_uploads/s#\(file_uploads\).*#\1 = On#g" $path2/php5/php.ini
 sed -i "/upload_max_filesize/s#.*\(upload_max_filesize\).*#\1 = 2M#g" $path2/php5/php.ini
 sed -i "/max_file_uploads/s#\(max_file_uploads\).*#\1 = 20#g" $path2/php5/php.ini
 sed -i "/post_max_size/s#.*\(post_max_size\).*#\1 = 8M#g" $path2/php5/php.ini
 sed -i "/short_open_tag/s#.*\(short_open_tag\).*#\1 = On#g" $path2/php5/php.ini
 cd ~
 tar xf $ZendGuardLoader.tar.gz -C $path1
 cd $path1/$ZendGuardLoader/php-5.3.x/
 cp ZendGuardLoader.so $path2/php5/lib/php/
 sed -i "1azend_extension=${path2}/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" $path2/php5/php.ini
 sed -i "/LoadModule php5_module/s#.*\(LoadModule php5_module\).*#\1 modules\/libphp5.so#g" $path2/httpd/conf/httpd.conf
 sed -i "55a AddType application\/x-httpd-php \.php \.phtml" $path2/httpd/conf/httpd.conf
 sed -i "/DirectoryIndex/s#.*\(DirectoryIndex\).*#\1 index.php index.html index.htm#g" $path2/httpd/conf/httpd.conf
 cat << END >> $path2/httpd/htdocs/test1.php
 <?php
 phpinfo ();
 ?>
 END
 cat << END >> $path2/httpd/htdocs/test2.php
 <?php
 \$link=mysql_connect('localhost','root','$mysqlrootpasswd')
 ;
 if(\$link) echo "Connect Successfully!";
 else echo "Connect Faild!";
 mysql_close();
 ?>
 END
 echo "已执行完毕、成功与否请查看/root/debug.txt内容,非0为安装失败"
 echo "1、检查软件版本号是否相同"
 echo "2、查看为非0的下的提示报错位置进行修改"
 echo "测试PHP是否正常工作:http://localhost/test1"
 echo "测试PHP能否连接MySQL:http://localhost/test2"

LAMP脚本的更多相关文章

  1. 一键部署lamp 脚本

    一键部署lamp 脚本 如下: #!/bin/bash systemctl stop firewalld systemctl disable firewalld setenforce 0 #----- ...

  2. CentOS自动化安装LAMP脚本

    #!/bin/bash #-- #blog:lizhenliang.blog.51cto.com ########## function ########## depend_pkg () { yum ...

  3. 一键部署lamp脚本

    #!/bin/bash systemctl stop firewalld systemctl disable firewalld setenforce 0 #-------Apache------ # ...

  4. 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境

    CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...

  5. LAMP一键安装包-CentOS 5/6下自动编译安装Apache,MySQL,PHP

    http://www.centos.bz/lamp/ 此安装包已经不再维护,请使用新版http://www.centos.bz/ezhttp/. 适用环境: 系统支持:CentOS-5 (32bit/ ...

  6. Vultr VPS建站攻略 – 一键安装宝塔面板架设LNMP/LAMP Web环境

    我们选择VULTR VPS建站的还是比较多的,其主要原因在于商家的稳定,毕竟我们用来建站选择服务器价格考虑的不是主要的(当然VULTR价格也是比较便宜),最为主要的是因为VULTR商家比较稳定,而且多 ...

  7. Apache下安装配置mod_pagespeed模块,轻松完成网站提速

    mod_pagespeed是一个开源的Apache module,它由谷歌开发,通过优化你的网页来减少响应延迟和带宽占用.作用参考ngx_pagespeed功能:http://blog.linuxey ...

  8. liunx 系统 一键安装

    本文转自:http://hi.baidu.com/iamcyh/item/e777eb81ba90ed5a26ebd9b0 linux VPS环境(MySQL/Apache/PHP/Nginx)一键安 ...

  9. shell学习及脚步编写

    目录: shell基础变量逻辑运算符 scp基础用法脚本 while+for+case基础用法脚本 内核优化脚本 自动修改本机ip脚本 for+case 查询日志脚本 一键yum安装lamp脚本 源码 ...

随机推荐

  1. Docker入门与应用系列(九)图形界面管理之Portainer

    介绍 Portainer是一个开源.轻量级Docker管理用户界面,基于Docker API,可管理Docker主机或Swarm集群,支持最新版Docker和Swarm模式.官方文档https://p ...

  2. python之list去重

    问题就是对一个list中的新闻id进行去重,去重之后要保证顺序不变. 直观方法 最简单的思路就是: 复制代码代码如下: ids = [1,2,3,3,4,2,3,4,5,6,1]news_ids = ...

  3. MVC 多种 数据验证 post

    技术:c# .net  采用mvc框架,实现model的数据验证. 刚开始觉得数据验证很方便,可以判断非空.数据正确性,但是后来发现很多需要数据库的判定还是需要post请求做,但是就想mvc的数据验证 ...

  4. 【BZOJ4712】洪水 树链剖分优化DP+线段树

    [BZOJ4712]洪水 Description 小A走到一个山脚下,准备给自己造一个小屋.这时候,小A的朋友(op,又叫管理员)打开了创造模式,然后飞到山顶放了格水.于是小A面前出现了一个瀑布.作为 ...

  5. nvm-windows 手动安装 nvm use 无效 'node' 不是内部或外部命令,也不是可运行的程序

    按照这两位前辈的教程,安装了nvm-windows. http://www.cnblogs.com/yesyes/p/7403184.html http://blog.csdn.net/jingsi1 ...

  6. 创建view,保存GROUP_CONCAT数据

    create view user_account_view asSELECT u.userId UserId ,u.userCode UserCode,GROUP_CONCAT(ac.id) Acco ...

  7. IIS设置文件 Robots.txt 禁止爬虫

    robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: value.常见的规则行:User-A ...

  8. django的项目创建简明流程

    个人理解,不妥之处请指出 创建项目:django-admin startproject user_sys 创建APP:python manage.py startapp auth 测试项目创建是否成功 ...

  9. Redis与Memcached的比较(转)

    原文:http://blog.nosqlfan.com/html/3729.html 这两年Redis火得可以,Redis也常常被当作Memcached的挑战者被提到桌面上来.关于Redis与Memc ...

  10. 关于session的常用用法

    (一)django有四中session实现方式 1.数据库(database-backed sessions) 2.缓存(cached sessions) 3.文件系统(file-based sess ...