Linux服务器之自动搭建LAMP环境Shell代码分享

LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言,所有组成产品均是开源软件,是国际上成熟的架构框架,很多流行的商业应用都是采取这个架构,和Java/J2EE架构相比,LAMP具有Web资源丰富、轻量、快速开发等特点,微软的.NET架构相比,LAMP具有通用、跨平台、高性能、低价格的优势,因此LAMP无论是性能、质量还是价格都是企业搭建网站的首选平台。

将Apache MySQL php源码包与安装脚本放在同一目录下,执行脚本文件根据脚本提示输入安装路径即可。

#!/bin/bash
echo "1.please input the mysql's path where will installed [default:/web/mysql]"
read sqlread
if [ "$sqlread" != "" ];then
sql=$sqlread
else
sql="/web/mysql"
fi

echo "2.please input the httpd's path where will installed [default:/web/httpd]"
read httpdread
if [ "$httpdread" != "" ];then
httpd=$httpdread
else
httpd="/web/httpd"
fi

echo "3.please input the php's path where will installed [default:/web/php]"
read phpread
if [ "$phpread" != "" ];then
php=$phpread
else
php="/web/php"
fi


mkdir -p $sql
mkdir -p $httpd
mkdir -p $php
useradd mysql
tar zxvf `ls | grep mysql | grep tar`
cd `ls -d */ | grep mysql`
./configure --prefix=$sql --enable-thread-safe-client --with-extra-charsets=gbk && make && make install
cp ./support-files/my-medium.cnf /etc/my.cnf
${sql}/bin/mysql_install_db --user=mysql
cd ..

tar zxvf `ls | grep http | grep tar`
cd `ls -d */ | grep http`
./configure --prefix=$httpd --enable-so --enable-rewrite && make && make install
cd ..

tar zxvf `ls | grep php | grep tar`
cd `ls -d */ | grep php`
./configure --prefix=$php --with-mysql=$sql --with-apxs2=${httpd}/bin/apxs --with-config-file-path=/usr/local/lib/ && make && make install
cp -f `ls | grep php.ini | head -1` /usr/local/lib/php.ini
cd ..

ln -s ${sql}/bin/* /usr/bin/
ln -s ${httpd}/bin/* /usr/bin/
ln -s ${php}/bin/* /usr/bin/
echo "${httpd}/bin/apachectl start" >> /etc/rc.d/rc.local
echo "${sql}/bin/mysqld_safe --user=mysql &" >> /etc/rc.d/rc.local
echo "AddType application/x-httpd-php .php" >> ${httpd}/conf/httpd.conf

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wygyww.html