加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

源码编译安装LAMP

发布时间:2020-12-15 16:31:58 所属栏目:安全 来源:网络整理
导读:环境:centos6.6;httpd-2.2.34;mysql-5.5.55;php5.6.31 #!/bin/bash#2017-08-12#authorbyTanWenXin#AutoinstallLAMP#createDNSservercat/etc/resolv.confEOFnameserver192.168.8.2EOF######################httpd-2.2.34install#########################fun

环境:centos6.6;httpd-2.2.34;mysql-5.5.55;php5.6.31

#!/bin/bash
#2017-08-12
#authorbyTanWenXin
#AutoinstallLAMP

#createDNSserver
cat>>/etc/resolv.conf<<EOF
nameserver192.168.8.2
EOF
######################httpd-2.2.34install#########################
functioninstall_httpd(){
#init
yuminstall-ygccgcc-c++libxml2libxml2-devellibmcryptlibmcrypt-develmhashmhash-develbzip2bzip2-devellibjpeg-devellibpng-develfreetype-developenssl-devellibcurl-devellibmcrypt-devel>/dev/null
mkdir/download&&cd/download
wgethttp://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.34.tar.gz
tarzxfhttpd-2.2.34.tar.gz&&cdhttpd-2.2.34&&./configureprefix=/usr/local/apache2-enable-rewrite--enable-so--enable-cgi--enable-modules=most--enable-mpms-shared=all
if[$?-eq0];then
make&&makeinstall
echo"apacheinstallsuccessful!!!!!"
else
echo"apacheinstallfailed"
exit2
fi

##
#cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd
echo"/usr/local/apache2/bin/apachectlstart">>/etc/rc.local
##
cp/usr/local/apache2/conf/httpd.conf/usr/local/apache2/conf/httpd.conf.bck
sed-i's#index.html#index.htmlindex.php#g'/usr/local/apache2/conf/httpd.conf
sed-i-e'/Groupdaemon/aServerNamelocalhost'/usr/local/apache2/conf/httpd.conf
cat>>/usr/local/apache2/htdocs/index.php<<EOF
<?php
phpinfo();
?>
EOF
cat>>/usr/local/apache2/conf/httpd.conf<<EOF
AddTypeapplication/x-httpd-php.php
#AddTypeapplication/x-httpd-php-source.phps
EOF
}

###############mysql-5.5.55install################################
functioninstall_mysql(){
#installmysql
cd/download
wgethttp://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
tarxfmysql-5.5.55-linux2.6-x86_64.tar.gz-C/usr/local
cd/usr/local
ln-smysql-5.5.55-linux2.6-x86_64/mysql
ln-s/usr/local/mysql/bin/*/usr/bin

##addusermysql
grep"bmysqlb"/etc/passwd
if[$?-ne0];then
useradd-rmysql-s/sbin/nologin-M
fi

#createmy.cnf
mkdir-p/mydata/data
chown-Rmysql.mysql/mydata/data
chown-Rmysql.mysql/usr/local/mysql/*
cd/usr/local/mysql/support-files
cpmy-large.cnf/etc/my.cnf
##modifymy.cnf
sed-i"s#thread_concurrency=8#thread_concurrency=4#g"/etc/my.cnf
sed-i-e'/log-bin=mysql-bin/adatadir=/mydata/data'/etc/my.cnf

#createstartscript
cpmysql.server/etc/rc.d/init.d/mysqld
chkconfig--addmysqld

#initandstartmysql
cd/usr/local/mysql
scripts/mysql_install_db--user=mysql--datadir=/mydata/data/
/etc/init.d/mysqldstart
}

############################php5.6.31install######################
functioninstall_php(){
cd/download
wgethttp://hk1.php.net/get/php-5.5.38.tar.gz/from/this/mirror
tarzxfmirror&&cdphp-5.5.38&&./configure--prefix=/usr/local/php--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--enable-sockets--with-apxs2=/usr/local/apache2/bin/apxs
if[$?-eq0];then
make-j4&&makeinstall
echo"LAMPinstallsuccessful!!!!!"
else
echo"phpinstallfailed"
exit2
fi
cpphp.ini-production/etc/php.ini
/usr/local/apache2/bin/apachectlstart

}

##########################main######################
read-p"AreyousureinstallLAMPviasourcecode?(yesorno)"READ
case$READin
yes|YES|Yes)
install_httpd
install_mysql
install_php
;;
no|NO|No)
echo"Sinceyoudon'twanttoinstallLAMP,thescritpexit"
exit5
;;
*)
echo"Pleasechoose"yes"or"no"again:"
read-p"AreyousureinstallLAMPviasourcecode?(yesorno)"READ
esac

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读