#! /bin/bash
# 卸载系统默认的lamp包
rpm -e httpd --nodeps
rpm -e mysql --nodeps
rpm -e php --nodeps
# 定义所安装的目录
LAMP=/install/tar
RPM=/install/rpm
cd $RPM
# 安装依赖包避免在安装http,mysql,php出现出现错误!
rpm -ivh libtermcap-2.0.8-46.1.i386.rpm --nodeps
rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm --nodeps
rpm -ivh libxml2-2.6.26-2.1.2.8.i386.rpm --nodeps
rpm -ivh libxml2-devel-2.6.26-2.1.2.8.i386.rpm --nodeps
rpm -ivh libxml2-python-2.6.26-2.1.2.8.i386.rpm --nodeps
rpm -ivh openssl-0.9.8e-12.el5.i386.rpm --nodeps
rpm -ivh openssl-0.9.8e-12.el5.i686.rpm --nodeps
rpm -ivh openssl-devel-0.9.8e-12.el5.i386.rpm --nodeps
rpm -ivh openssl-perl-0.9.8e-12.el5.i386.rpm --nodeps
cd $LAMP
# 解压:http,mysql,php
tar -zxvf httpd-2.2.15.tar.gz -C /usr/src
tar -zxvf mysql-5.1.47.tar.gz -C /usr/src
tar -zxvf php-5.2.13.tar.gz -C /usr/src
# 设置解压目录
http=/usr/src/httpd-2.2.15
mysql=/usr/src/mysql-5.1.47
php=/usr/src/php-5.2.13
# 设置安装目录
HTTP=/usr/local/http
MYSQL=/usr/local/mysql
PHP=/usr/local/php
# 安装apache服务员
cd $http
./configure --prefix=/usr/local/http --enable-rewrite --enable-so --enable-auth-digest --enable-cgi --with-ssl=/usr/lib --enable-ssl --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/http/htdocs
cd $http
make && make install
echo $?
cd /usr/local/http/bin
echo "# chkconfig: 35 85 15" >> apachectl
echo "# description: Apache is a World Wide Web Server" >> apachectl
# daoci bahttpfuwukaobeidao/etc/init.d/ muluxia
cp apachectl /etc/init.d/httpd
chmod o+x /etc/init.d/httpd
# 默认httpd.conf 文件备份下
mv /usr/local/http/conf/httpd.conf /usr/local/http/conf/httpd.conf.xg
cp /install/http/httpd.conf /usr/local/http/conf/
cp /install/http/index.php /usr/local/http/htdocs/
chkconfig --add httpd
chkconfig httpd on
service httpd start
# 如果httpd服务启动正常现在ok
echo "httpd OK"
# 安装mysql
cd $mysql
# 删除mysql默认mysql用户和组
userdel mysql
useradd -M -s /sbin/nologin mysql
# 配置mysql
./configure --prefix=/usr/local/mysql --with-mysqld-user=mysql
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var/
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig -v
cp support-files/mysql.server /etc/init.d/mysqld
chmod o+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
echo "mysqld OK"
# 设置环境变量
export PATH=$PATH:/usr/local/mysql/bin/
echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
# 设置mysql密码
mysqladmin -u root password '123456'
# yanzheng duanku
netstat -nutlp | grep mysqld
echo "到此mysql服务安装完成!"
# 安装php
cd $php
./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/http/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php
make && make install
cp php.ini-dist /usr/local/php/php.ini
# 安装gd,mysqli,pdo扩展模块
echo
echo "到此LAMP平台圆满搭建成功!"
echo
echo
echo " 编写者:朋亮"
reboot
LAMP自动安装脚本
原创
©著作权归作者所有:来自51CTO博客作者单成刚的原创作品,如需转载,请与作者联系,否则将追究法律责任
上一篇:CRM安装
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
LAMP&LNMP自动化安装脚本
LAMP&LNMP自动化安装脚本
lamp lnmp 自动化脚本