# prelude:before scp soft upload
cat >/etc/yum.repos.d/CentOS-Base.rep <<EOF
[Local]
name=Local Yum
baseurl=file:///yum/cdrom
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
mkdir -p /mnt/cdrom
mkdir -p /yum
mount /dev/cdrom /mnt/cdrom
yum clean all
yum makecache
yum -y install vim
sed -i ‘s/ONBOOT=no/ONBOOT=yes/g’ /etc/sysconfig/network-scripts/ifcfg-eth0
###### scp soft upload
# scp CentOS-Base.repo root@10.211.55.16:/app/data/web-server/apache
# scp apr-1.6.3.tar.gz root@10.211.55.16:/app/data/web-server/apache
# scp apr-util-1.6.1.tar.gz root@10.211.55.16:/app/data/web-server/apache
# scp httpd-2.4.29.tar.gz root@10.211.55.16:/app/data/web-server/apache
# scp libmcrypt-2.5.8.tar.gz root@10.211.55.16:/app/data/web-server/apache
# scp mariadb-10.2.8-linux-x86_64.tar.gz root@10.211.55.16:/app/data/web-server/apache
# scp php-7.1.10.tar.gz root@10.211.55.16:/app/data/web-server/apache
## install development tools
yum -y groupinstall “development tools”
yum -y install openssl-devel expat-devel pcre-devel
yum -y install net-tools
# define app path
MYSQLDB=”/app/mysqldb”
APPPATH=”/app/data/web-server/apache”
#mkdir $APPPATH
cd $APPPATH
# decompress soft
tar -xvf apr-1.6.3.tar.gz
tar -xvf apr-util-1.6.1.tar.gz
tar -xvf httpd-2.4.29.tar.gz
# copy
cp -r apr-1.6.3 httpd-2.4.29/srclib/apr
cp -r apr-util-1.6.1 httpd-2.4.29/srclib/apr-util
# compile httpd
cd httpd-2.4.29
./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 -j 4 && make install
# add httpd path
echo “PATH=/app/httpd24/bin/:$PATH” > /etc/profile.d/lamp.sh
chmod +x /etc/profile.d/lamp.sh
. /etc/profile.d/lamp.sh
echo $PATH
# startup httpd
/app/httpd24/bin/apachectl
ss -tnl
# copy mariadb to /usr/local
cd ..
tar -xvf mariadb-10.2.8-linux-x86_64.tar.gz -C /usr/local
# install mariaDB
LCOAL=”/usr/local/”
cd $LCOAL
ln -s mariadb-10.2.8-linux-x86_64/ mysql
# don’t mkdir /app/mysqldb before add user, so useradd can do this
useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
mkdir /etc/mysql
cd mysql/
cat > /etc/mysql/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir=/app/mysqldb/data
innodb_file_per_table=ON
skip_name_resolve=ON
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
EOF
# add mysql server to chkconfig
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –list
# mkdir mariadb log dir
mkdir /var/log/mariadb
chown -R mysql /var/log/mariadb/
chown -R mysql /app/mysqldb/
# initial mysql db
cd /usr/local/mysql/scripts
./mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/app/mysqldb/data
service mysqld start
# add httpd path
PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
echo $PATH
# install php depends
yum -y install libxml2-devel bzip2-devel libmcrypt-devel
# install php depends libmcrypt
APPPATH=”/app/data/web-server/apache”
cd $APPPATH
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
cd $APPPATH
# decompress and install php
tar -xvf php-7.1.10.tar.gz
cd 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/apxs –with-mcrypt –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –enable-maintainer-zts –disable-fileinfo
make -j 4 && make install
cp php.ini-production /etc/php.ini
# modify httpd.conf
cat >>/etc/httpd24/httpd.conf << EOF
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
EOF
sed -i ‘s/DirectoryIndex\sindex.html/DirectoryIndex index.php index.html/g’ /etc/httpd24/httpd.conf
# restart apache
apachectl stop
apachectl
# create test php
cat >/app/httpd24/htdocs/index.php << EOF
<html><body><h1>LAMP</h1></body></html>
<?php
error_reporting(E_ALL);
\$mysqli=mysqli_connect(“localhost”,”root”,””);
if(mysqli_connect_errno()){
echo”连接数据库失败!”;
\$mysqli=null;
exit;
}
echo”连接数据库成功!”;
\$mysqli->close();
phpinfo();
?>
EOF
setenforce 0
getenforce
systemctl stop firewalld