#!/bin/bash
echo “rpm包安装mysql”
yum localinstall mysql80-community-release-el7-1.noarch.rpm
yum repolist all | grep mysql
yum repolist enabled|grep mysql
yum install yum-utils
yum-config-manager –disable mysql80-community
yum-config-manager –enable mysql57-community
yum repolist enabled | grep mysql
yum install -y mysql-community-server
echo “启动mysql服务”
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
echo “生成mysql初始密码”
mysql_init_pwd_src=grep "temporary password" /var/log/mysqld.log
mysql_init_pwd=${mysql_init_pwd_src##*: }
echo “初始密码为: [${mysql_init_pwd}]”
mysqladmin -u root -p”${mysql_init_pwd}” password ‘Sjm1987!’
systemctl restart mysqld
yum -y install tcl-devel
yum -y install expect
/usr/bin/expect <<-EOF
spawn mysql -h 127.0.0.1 -uroot -p
set timeout 100
expect {
“*Enter password:” {send “Sjm1987!\r”}
interact
}
expect eof
EOF
echo “PHP安装”
yum -y gcc install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel pcre-devel sqlite-devel bzip2 bzip2-devel openldap openldap-devel epel-release oniguruma oniguruma-devel
tar -zxvf php-7.4.20.tar.gz
cd php-7.4.20
cp -frp /usr/lib64/libldap* /usr/lib/
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local –with-freetype –with-jpeg –with-zlib –enable-pdo –with-pdo-mysql –enable-xml –with-xmlrpc –disable-rpath –enable-bcmath –with-curl –enable-mbregex –enable-fpm –enable-mbstring –with-openssl –with-mhash –enable-sockets –enable-pcntl –with-ldap –with-ldap-sasl –enable-soap –without-pear –with-bz2 –disable-fileinfo –enable-gd
line=sed -n '/EXTRA_LIBS = /=' Makefile | tail -n1
sed -i “${line}s/.*/& -llber/” Makefile
make && make install
cp /root/soft/confgfile/php.ini /usr/local/php/etc/php.ini
cp /root/soft/confgfile/php-fpm.conf /usr/local/php/etc/php-fpm.conf
cp /root/soft/confgfile/www.conf /usr/local/php/etc/php-fpm.d/www.conf
cat>/etc/systemd/system/php-fpm.service<<EOF
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=True
[Install]
WantedBy=multi-user.target
EOF
sed -i ‘$a \PATH=$PATH:\/usr\/local\/php\/bin’ /etc/profile
export PATH
source /etc/profile
sudo groupadd nginx
sudo useradd -g nginx nginx
mkdir -p /usr/local/tmpphp/log
php -v
source /etc/profile
systemctl enable php-fpm
echo “安装nginx”
tar -zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure –prefix=/usr/local/nginx –with-http_ssl_module
make && make install
cp /root/soft/confgfile/nginx.conf /usr/local/nginx/conf/nginx.conf
mkdir /usr/local/nginx/conf/conf.d
cp /root/soft/confgfile/vhost.conf /usr/local/nginx/conf/conf.d/my_vhost.conf
cat>/etc/systemd/system/nginx.service<<EOF
[Unit]
Description=nginx web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable nginx