/php.d --with-bz2
make && make install
cat >/etc/profile.d/lamp.sh <<END
PATH=/app/php/bin:/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
END
bash /etc/profile.d/lamp.sh
cp php.ini-production /etc/php.ini
sed -i '255s@DirectoryIndex index.html@DirectoryIndex index.php index.html@' /app/httpd24/conf/httpd.conf
cat >>/app/httpd24/conf/httpd.conf <<DEF
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DEF
service httpd24 restart
###4.测试
cat > /app/httpd24/htdocs/index.php <<EDD
<html><body><h1>It works!</h1></body></html>
<?php
echo date("Y/m/d h:i:s");
\$mysqli=new mysqli("localhost","shenxm","xm1234");
if(mysqli_connect_errno()){
echo "连接数据库失败!";
\$mysqli=null;
exit;
}
echo "连接数据库成功!";
\$mysqli->close();
\$conn = mysql_connect('localhost','root','centos');
if ($conn)
echo "OK";
else
echo "Failure";
mysql_close();
phpinfo();
?>
EDD
}
creat_lamp_on_centos7 ()
{
####1.源码编译安装Httpd2.4
yum groupinstall "development tools" -y
yum install openssl-devel expat-devel pcre-devel -y
cd /app
tar xvf apr-1.6.2.tar.gz
tar xvf apr-util-1.6.0.tar.gz
tar xvf httpd-2.4.27.tar.bz2
cp -r apr-1.6.2 httpd-2.4.27/srclib/apr
cp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util
cd httpd-2.4.27/
./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
cat > /etc/profile.d/lamp.sh <<END
PATH=/app/httpd24/bin/:$PATH
END
bash /etc/profile.d/lamp.sh
apachectl
####2.二进制安装mariadb
####可以在另台主机上进行安装,这里是在本地安装
cd /app
tar xvf mariadb-10.2.8-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local
ln -s mariadb-10.2.8-linux-x86_64/ mysql
useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
cd mysql/
scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf
sed -i '27a\datadir = /app/mysqldb \ninnodb_file_per_table = ON \nskip_name_resolve = ON' /etc/mysql/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
mkdir /var/log/mariadb
chown mysql /var/log/mariadb/
systemctl start mysqld
cat > /etc/profile.d/lamp.sh <<EOF
PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
EOF
bash /etc/profile.d/lamp.sh
/usr/local/mysql/bin/mysqladmin -u root password 'xm1234'
cat > /app/mysql-file.txt <<eof
create database wpdb;
grant all on wpdb.* to shenxm@'%' identified by 'xm1234';
eof
mysql -uroot -pxm1234< /app/mysql-file.txt
####3.源码编译安装Php
yum install libxml2-devel bzip2-devel libmcrypt-devel -y #(epel源)
cd /app
tar xvf php-7.1.10.tar.xz
cd /app/php-7.1.10/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/httpd24/bin/a |