LAMP脚本
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脚本的更多相关文章
- 一键部署lamp 脚本
一键部署lamp 脚本 如下: #!/bin/bash systemctl stop firewalld systemctl disable firewalld setenforce 0 #----- ...
- CentOS自动化安装LAMP脚本
#!/bin/bash #-- #blog:lizhenliang.blog.51cto.com ########## function ########## depend_pkg () { yum ...
- 一键部署lamp脚本
#!/bin/bash systemctl stop firewalld systemctl disable firewalld setenforce 0 #-------Apache------ # ...
- 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境
CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...
- LAMP一键安装包-CentOS 5/6下自动编译安装Apache,MySQL,PHP
http://www.centos.bz/lamp/ 此安装包已经不再维护,请使用新版http://www.centos.bz/ezhttp/. 适用环境: 系统支持:CentOS-5 (32bit/ ...
- Vultr VPS建站攻略 – 一键安装宝塔面板架设LNMP/LAMP Web环境
我们选择VULTR VPS建站的还是比较多的,其主要原因在于商家的稳定,毕竟我们用来建站选择服务器价格考虑的不是主要的(当然VULTR价格也是比较便宜),最为主要的是因为VULTR商家比较稳定,而且多 ...
- Apache下安装配置mod_pagespeed模块,轻松完成网站提速
mod_pagespeed是一个开源的Apache module,它由谷歌开发,通过优化你的网页来减少响应延迟和带宽占用.作用参考ngx_pagespeed功能:http://blog.linuxey ...
- liunx 系统 一键安装
本文转自:http://hi.baidu.com/iamcyh/item/e777eb81ba90ed5a26ebd9b0 linux VPS环境(MySQL/Apache/PHP/Nginx)一键安 ...
- shell学习及脚步编写
目录: shell基础变量逻辑运算符 scp基础用法脚本 while+for+case基础用法脚本 内核优化脚本 自动修改本机ip脚本 for+case 查询日志脚本 一键yum安装lamp脚本 源码 ...
随机推荐
- JavaScript------日期和时间戳的相互转换
var date = new Date(); 日期转时间戳 Number(date)或者date.getTime(); //只是转换成了纯数字的时间戳,例如:1498144203861需要转换才能使用 ...
- 《基础知识》hashCode与equals的区别与联系
一.equals方法的作用 1.默认情况(没有覆盖equals方法)下equals方法都是调用Object类的equals方法,而Object的equals方法主要用于判断对象的内存地址引用是不是同一 ...
- [USACO5.5]隐藏口令Hidden Password
题目链接:传送门 题目大意:给你一个长度 N 的字符串,5<=N<=5,000,000,将首尾合并成环,断环成链并满足字典序最小,输出此时首字母在原串中的位置-1: 题目思路:最小表示法 ...
- rabbitmq 3.6.11 centos 7 安装
http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm http://www.rabbitmq.co ...
- fis3 部署手册
为什么使用FIS3 项目上线一段时间后如果更新JS或CSS文件,而客户端已经对该文件缓存过了,那就有可能会无法及时更新而继续采用旧的JS或CSS文件,无法达到想要的效果. 处理类似情况最有效的解决方案 ...
- zookeeper Java API 简单操作示例
本文主要介绍如何在java IDE中如何应用使用客户端与zookeeper服务器通信. 首先搭建maven环境,并在pom文件中加入zookeeper引用包: <!-- https://mvnr ...
- VMware虚拟机Bridged(桥接模式)
转载于:https://www.linuxidc.com/Linux/2016-09/135521.htm vmware为我们提供了三种网络工作模式,它们分别是:Bridged(桥接模式).NAT ...
- Android自定义上拉控件SpringView
Demo 先看一下SpringView的效果图: 1.拖动灰色部分可拖动下方视图,点击jump按钮可让下方视图自行滑动. 使用方法 布局文件: <com.zql.android.springvi ...
- Java 常用工具类之 String 类
String 类的特点: 字符串对象一旦被初始化就不会被改变. //以下代码的区别: String s = "abc"; // 在常量池中创建一个字符串对象, 池中没有就建立, 池 ...
- 微信js分享朋友圈(一)
1.绑定域名 先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. 备注:登录后可在“开发者中心”查看对应的接口权限. 2.引入js文件 <script type=&q ...