Exercise: remote connection client installed php + tengine,
First, the need to use the script 8 get remote ip and pushing the public key to the remote machine.
Second, create the following directory structure
1.lnmp.sh
------------------------------------------------------
lnmp
├── conf
│ ├── index.php
│ ├── nginx.conf
│ └── php-fpm.conf
├── include
│ ├── config.sh
│ ├── init_os.sh
│ ├── nginx_install.sh
│ └── php_install.sh
├── installrc
├── lnmp.sh
└── src
├── php-7.2.6.tar.bz2
└── tengine-2.3.0.tar.gz
Third, respectively scripting
#!/bin/bash
#####lnmp main program
###2019-6-8######
soft_dir=`pwd`/src
config_dir=`pwd`/conf
cpus=`lscpu|awk '/^CPU\(s\)/{print $2}'`
. installrc
. include / init_os.sh
. include/nginx_install.sh
. include/php_install.sh
. include/config.sh
init_os
nginx_install
php_install
config
2.init_os.sh
#!/bin/bash
#### heat os #########
###yum########
init_os () {
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum make cache && yum repolist
####SELinux########
systemctl disable firewalld
systemctl stop firewalld
#firewall-cmd --permanent --add-service=http
#firewall-cmd --permanent --add-service=https
#firewall-cmd --reload
setenforce 0
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
#NTP
yum -y install chrony
sed -ri '/3.CentOS.pool.ntp.oeg/a\server pool.ntp.org iBurst prefer' /etc/chrony.conf
systemctl start chronyd
systemctl enable chronyd
}
3.nginx_install.sh
#!/bin/bash
#
#tengine install scripts
#by Dan Chen 2019-6-8
nginx_install(){
yum -y install gcc gcc-c++ openssl-devel pcre-devel
useradd nginx
cd $ soft_dir
tar XF $ tengine_version
cd ${tengine_version%.tar.gz}
./configure && make -j $cpus && make install
echo "$nginx_prefix/sbin/nginx" >> /etc/rc.local
chmod a+x /etc/rc.d/rc.local
echo "export PATH=$PATH:$nginx_prefix/sbin" >> /etc/profile
source /etc/profile
}
4.php_install.sh
#!/bin/bash
#
##php install scripts
php_install(){
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \
libxml libxml-devel libcurl libcurl-devel libxslt-devel openssl-devel
cd $ soft_dir
tar xf $php_version
cd ${php_version%.tar.bz2}
./configure --prefix=$php_prefix --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir \
--with-jpeg-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli \
--with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir \
--with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml \
--enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache \
--enable-pcntl --enable-shmop --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make -j $cpus && make install
cp $php_prefix/etc/php-fpm.conf.default $php_prefix/etc/php-fpm.conf
cp cow / fpm / init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod a+x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
}
5.config.sh
#!/bin/bash
#config conf
config() {
#tengine
\cp $config_dir/nginx.conf $nginx_prefix/conf/nginx.conf
\cp $config_dir/index.php $nginx_prefix/html/index.php
\cp $php_prefix/etc/php-fpm.d/www.conf.default $php_prefix/etc/php-fpm.d/www.conf
$nginx_prefix/sbin/nginx
/etc/init.d/php-fpm start
}
6.installrc
#!/bin/bash
#config conf
config() {
#tengine
\cp $config_dir/nginx.conf $nginx_prefix/conf/nginx.conf
\cp $config_dir/index.php $nginx_prefix/html/index.php
\cp $php_prefix/etc/php-fpm.d/www.conf.default $php_prefix/etc/php-fpm.d/www.conf
$nginx_prefix/sbin/nginx
/etc/init.d/php-fpm start
}
to sum up:
1. The present embodiment primarily using a shell function, the function call in the main program lnmp.sh inlet, the installation process is probably about 20 minutes
2. This example mysql database is not installed, the reason is usually mysql is installed separately on multiple high configuration servers and clusters made a little better, interested friends can try to complete mysql cluster structures.
operation result:
[root@Node1 etc]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*