Compile and install Lnmp shell script under Linux centos

#! /bin/bash
repo="/etc/yum.repos.d/CentOS7-Base-163.repo"if[!-e $repo ]; then                 # -e Determine the existence of the file; reference: Shell if conditional judgment file or directory
yum install -y wget
cd /etc/yum.repos.d/
mkdir bak
mv * bak
# wget http://mirrors.aliyun.com/repo/Centos-7.repo
# wget http://mirrors.aliyun.com/repo/epel-7.repo
          # Move two files to the directory
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
# sed -i  's/$releasever/7/g'/etc/yum.repos.d/CentOS-Base.repo
          # The yum source does not match the corresponding version package; modify yum to centos7
yum clean all                           #Clear original cache
yum makecache                           #Generate a new cache
          # make cache [meɪk][kaʃ]Make cache{ka xi}
yum  list                               #Check yum
cd
else 
echo "yum has switched"
fi
################## nginx  ##################
aznginx(){
lsnginx=(`find / -name "nginx.conf" | sed "s/ //g"`) #The shell parenthesis attribute defines the array variable lsnginx. Its value is the execution result of a command
echo "
The total number of nginx configuration files is:${#lsnginx[*]}
List nginx configuration files"    ${lsnginx[*]}         # [*]The asterisk lists all the elements, and the asterisk is changed to 1 to specify the subscript 1, which means the second element, starting from 0 by default
if[ ${#lsnginx[*]}-lt 1]                     # -lt is less than;$Is empty,!Non-operation;$?Judge the execution status of the last command, 0 is normal; Reference: linux shell$$,$!Special usage
then
echo "The configuration file is empty, nginx is being installed"
yum install -y gcc gcc-c++
yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel
useradd -s /bin/false-M nginx
mkdir -p /www/server/nginx/download                                     #Download catalog
mkdir -p /www/server/nginx/18                                           #installation manual
cd /www/server/nginx/download
#
# wget http://nginx.org/download/nginx-1.18.0.tar.gz
wget http://work.eisc.cn/ruanjian/rpm/lnmp/nginx-1.18.0.tar.gz
tar -zxf nginx-1.18.0.tar.gz
cd nginx-1.18.0
# Compile and install directory parameters:--prefix
. /configure --user=nginx \
- - group=nginx \
- - prefix=/www/server/nginx/18 \
- - with-http_v2_module \
- - with-http_ssl_module \
- - with-http_sub_module \
- - with-http_stub_status_module \
- - with-http_gzip_static_module \
- - with-pcre
make && make install
ln -s /www/server/nginx/18/nginx-1.18.0/www/server/nginx/18/nginx
             # Give nginx-1.12.0Create a soft link and remove the version number at the end
ln -s /www/server/nginx/18/sbin/* /usr/local/sbin/ #Create soft link of nginx command to environment variable
############ Add support for php############
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=9000/tcp #First release the firewall port
firewall-cmd --reload                   #Restart firewall
mkdir -p /www/wwwroot/html              #web path
nginxconf="/www/server/nginx/18/conf/nginx.conf"
sed -i "/#/d" $nginxconf ; sed -i "/^$/d" $nginxconf 
cp $nginxconf $nginxconf.backup
          # Focus:Modify the boot soft chain and need to write a file, otherwise the reboot fails and the nginx cannot be started
sed -i "1 a\pid    /usr/bin/nginx.pid; " $nginxconf
/usr/local/sbin/nginx                   #Start nginx
NR=`cat -n $nginxconf | grep "error_page" | awk -F" " '{print $1}'` ; echo $NR
sed -i "$NR i\  location ~ \.php$ { \n                         root           /www/wwwroot;  \n                         fastcgi_pass 127.0.0.1:9000; \n                         fastcgi_index index.php; \n                         fastcgi_param  SCRIPT_FILENAME  \$document_root\$fastcgi_script_name; \n                         include        fastcgi_params; \n                 }" $nginxconf
                      # Modify the support php parsing directory location
NR=`cat -n $nginxconf | grep "root" | grep "html" | awk -F" " 'NR==1{print $1}' | sed "s/ //g" ` ; echo "Find the web directory line number of nginx as:" $NR 
sed -i "$NR s/root.*/root  \/www\/wwwroot\;/g" $nginxconf
          # Modify web directory
echo "                                                                          #Write php test file
<? php
phpinfo()?>
" > /www/wwwroot/html/index.php
####################################
cd
nginx -s stop                           #stop
nginx
nginx -t                                #Soft-connected
nginx
yum install -y net-tools                #Port Toolkit
netstat -ntlp                           #View port
nginx -s reload                         #nginx reload configuration; restart
firewall-cmd --permanent --add-port=80/tcp #Firewall allows port 80
systemctl restart firewalld
 cat /var/log/nginx/error.log           #nginx log
else                                    #If you want to end directly: exit and fi cooperate
 echo "nginx.conf exists and nginx is installed"
fi
}
aznginx
################## php7.2 ##################
azphp(){
lsphp=(`find / -name "php.ini" | sed "s/ //g"`) #The shell parenthesis attribute defines the array variable lsnginx. Its value is the execution result of a command
echo "
The total number of nginx configuration files is:${#lsphp[*]}
List nginx configuration files"    ${lsphp[*]}     # [*]The asterisk lists all the elements, and the asterisk is changed to 1 to specify the subscript 1, which means the second element, starting from 0 by default
if[ ${#lsphp[*]}-lt 1]               # -lt is less than;$Is empty,!Non-operation;$?Judge the execution status of the last command, 0 is normal; Reference: linux shell$$,$!Special usage
then
echo "The configuration file is empty, php is being installed"
yum install epel-release -y             #Install the expansion pack and update the system kernel
yum list
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
          # Install php dependencies (including Nginx dependencies)
downloadPHP="/www/server/php/download"
installPHP="/www/server/php/72"
mkdir -p $downloadPHP
mkdir -p $installPHP                    #Create download and installation directories
groupadd www                            #Create a www group
useradd -g www www                      #Create user www to belong to group www
yum install -y wget ; yum install -y star
          # Install wget download tool and star decompression tool
cd $downloadPHP                         #Download the file after entering the download directory
# wget http://am1.php.net/distributions/php-7.2.1.tar.gz
wget http://work.eisc.cn/ruanjian/rpm/lnmp/php-7.2.1.tar.gz
tar xvf php-7.2.1.tar.gz                # tar -xvf is decompression,-cvf is to create a compressed package
cd php-7.2.1
# Create users and groups, and download and unzip the php installation package
cp -frp /usr/lib64/libldap*/usr/lib/  #Copy the dap library
#### Compile and install is the beginning of a command
. /configure --prefix=/www/server/php/72 \
- - with-config-file-path=/www/server/php/72/etc \
- - enable-fpm \
- - with-fpm-user=www \
- - with-fpm-group=www \
- - enable-mysqlnd \
- - with-mysqli=mysqlnd \
- - with-pdo-mysql=mysqlnd \
- - enable-mysqlnd-compression-support \
- - with-iconv-dir \
- - with-freetype-dir \
- - with-jpeg-dir \
- - with-png-dir \
- - with-zlib \
- - with-libxml-dir \
- - enable-xml \
- - disable-rpath \
- - enable-bcmath \
- - enable-shmop \
- - enable-sysvsem \
- - enable-inline-optimization \
- - with-curl \
- - enable-mbregex \
- - enable-mbstring \
- - enable-intl \
- - with-mcrypt \
- - with-libmbfl \
- - enable-ftp \
- - with-gd \
- - enable-gd-jis-conv \
- - enable-gd-native-ttf \
- - with-openssl \
- - with-mhash \
- - enable-pcntl \
- - enable-sockets \
- - with-xmlrpc \
- - enable-zip \
- - enable-soap \
- - with-gettext \
- - disable-fileinfo \
- - enable-opcache \
- - with-pear \
- - enable-maintainer-zts \
- - with-ldap=shared \
- - without-gdbm
#### Compile and install is the end of a command
make -j 4&& make install                           #Let make-j 4 At most 4 compile commands can be executed simultaneously
cp php.ini-development $installPHP/etc/php.ini
cp $installPHP/etc/php-fpm.conf.default $installPHP/etc/php-fpm.conf
cp $installPHP/etc/php-fpm.d/www.conf.default $installPHP/etc/php-fpm.d/www.conf
setphpini=`find $installPHP -name "php.ini"`; echo $setphpini #Define a variable name: setphpini whose value is a find Find the file php.The result returned by the ini command
\ cp $setphpini $setphpini.backup                    #Backup,Backslash, don&#39;t ask
sed -i "s/expose_php.*/expose_php\=off/g" $setphpini
             # sed -i Modify the file to match the previous string and all strings after it, and modify it to the next;\Translate special characters$setphpini is a file path variable
sed -i "s/short_open_tag.*/short_open_tag\=ON/g" $setphpini
sed -i "s/max_execution_time.*/max_execution_time\=1s/g" $setphpini
             # execution  [ˌɛksəˈkjuʃ(ə)n]carried out
sed -i "s/max_input_time.*/max_input_time\=1s/g" $setphpini
sed -i "s/memory_limit.*/memory_limit\=128M/g" $setphpini
             # [ ˈmeməri ˈlɪmɪt]Memory limit
sed -i "s/post_max_size.*/post_max_size\=30M/g" $setphpini
sed -i "s/date.timezone.*/date.timezone\=Asia\/Shanghai/g" $setphpini
sed -i "s/memory_limit.*/memory_limit\=128M/g" $setphpini
sed -i "s/mbstring.func_overload.*/mbstring.func_overload\=2/g" $setphpini
NR=`cat -n $setphpini | grep "mbstring.func_overload" | awk -F" " '{print $1}' | sed "s/ //g"`; echo $NR
             # Define the line number variable NR; grep matches the line where the string is located, prints the first column, and deletes spaces
sed -i "$NR a\extension = /www/server/php/72/lib/php/extensions/no-debug-zts-20170718/ldap.so" $setphpini
             # Write a string, at line$NR of a\Write the next line,
NR=`cat -n $setphpini | grep "\[opcache" | awk -F" " '{print $1}' | sed "s/ //"`; echo $NR
sed -i "$NR a\zend_extension=/www/server/php/72/lib/php/extensions/no-debug-zts-20170718/opcache.so" $setphpini 
sed -i "s/opcache.max_accelerated_files.*/opcache.max_accelerated_files\=4000/g" $setphpini
             # Cache
sed -i "s/opcache.revalidate_freq.*/opcache.revalidate_freq\=60/g" $setphpini
sed -i "s/opcache.fast_shutdown.*/opcache.fast_shutdown\=1/g" $setphpini
sed -i "s/opcache.enable_cli.*/opcache.enable_cli\=1/g" $setphpini
sed -i "s/disable_functions.*/disable_functions\=passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru/g" $setphpini
 NR=`cat -n $setphpini | grep disable_functions | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen = /var/run/www/php-cgi.sock " $setphpini
############################
wwwconf=`find $installPHP -name "www.conf" `; echo "Modify the configuration file:"$wwwconf
cp $wwwconf $wwwconf.backup
############################
NR=`cat -n $wwwconf | grep "listen \= " | awk -F" " '{print $1}' | sed "s/ //g"`
             # cat -n View the file to display the line number, awk field processing prints the first column as the line number
sed -i "$NR s/listen.*/listen \= \/var\/run\/www\/php-cgi.sock/g" $wwwconf
             # Get the line number, sed-i modify the content of the specified line number
NR=`cat -n $wwwconf | grep "listen.owner = www" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen.owner = www" $wwwconf
             # sed -i at the specified line number$NR&#39;s a\Insert string into the next line
                                                                                         
NR=`cat -n $wwwconf | grep "listen.group = www" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen.group = www"  $wwwconf
NR=`cat -n $wwwconf | grep "listen.mode =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen.mode = 0660" $wwwconf 
NR=`cat -n $wwwconf | grep "listen.allowed_clients" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen.allowed_clients = 127.0.0.1" $wwwconf 
NR=`cat -n $wwwconf | grep "listen.backlog" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\listen.backlog = -1" $wwwconf 
NR=`cat -n $wwwconf | grep "pm.max_children =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR s/pm.max_children \=.*/pm.max_children \= 180/g" $wwwconf 
NR=`cat -n $wwwconf | grep "pm.start_servers =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR s/pm.start_servers \=.*/pm.start_servers \= 50/g" $wwwconf 
NR=`cat -n $wwwconf | grep "pm.min_spare_servers =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR s/pm.min_spare_servers \=.*/pm.min_spare_servers \= 50/g" $wwwconf 
NR=`cat -n $wwwconf | grep "pm.max_spare_servers =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR s/pm.max_spare_servers \=.*/pm.max_spare_servers \= 180/g" $wwwconf 
NR=`cat -n $wwwconf | grep "request_terminate_timeout =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\request_terminate_timeout = 120" $wwwconf 
                    # $NR is in the specified line, a is the string to be inserted in the next line
NR=`cat -n $wwwconf | grep "request_slowlog_timeout =" | awk -F" " '{print $1}' | sed "s/ //g"`
sed -i "$NR a\request_slowlog_timeout = 50" $wwwconf 
NR=`cat -n $wwwconf | grep "slowlog =" | awk -F" " '{print $1}' | sed "s/ //g"`; 
sed -i "$NR a\slowlog = var/log/slow.log" $wwwconf 
mkdir /var/run/www/
chown -R www:www /var/run/www                   #Create php-cgi.sock storage directory
NR=`cat -n $installPHP/etc/php-fpm.conf | grep "pid =" | awk -F" " '{print $1}' | sed "s/ //g"`; echo $NR
sed -i "$NR a\pid = /www/server/php/72/var/run/php-fpm.pid"/www/server/php/72/etc/php-fpm.conf
echo -e "
[ Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[ Service]
Type=simple
PIDFile=$installPHP/var/run/php-fpm.pid
ExecStart=$installPHP/sbin/php-fpm --nodaemonize --fpm-config $installPHP/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[ Install]
WantedBy=multi-user.target
" > /usr/lib/systemd/system/php-fpm.service
NR=`cat -n /www/server/php/72/etc/php-fpm.d/www.conf | grep "listen =" | awk -F" " '{print $1}' | sed "s/ //g"`; echo $NR
            # grep matches the line where the string is located, awk-F specifies a space as a separator, and prints the first column
sed -i "$NR s/listen =.*/listen = 127.0.0.1:9000/g" $installPHP/etc/php-fpm.d/www.conf
            # Modify the configuration file to monitor port 900
ln -s /www/server/php/72/bin/php  /usr/bin      #Create a shortcut, use php directly
 systemctl start php-fpm
 systemctl stop php-fpm
 systemctl restart php-fpm
 systemctl reload php-fpm
else 
echo "php.ini file exists, php has been installed"
fi
}
azphp
azmariadb(){
lsphp=(`find / -name "mysql.server" | sed "s/ //g"`) #The shell parenthesis attribute defines the array variable lsnginx. Its value is the execution result of a command
echo "
The total number of nginx configuration files is:${#lsphp[*]}
List nginx configuration files"    ${lsphp[*]}             # [*]The asterisk lists all the elements, and the asterisk is changed to 1 to specify the subscript 1, which means the second element, starting from 0 by default
if[ ${#lsphp[*]}-lt 1]                       # -lt is less than;$Is empty,!Non-operation;$?Judge the execution status of the last command, 0 is normal; Reference: linux shell$$,$!Special usage
then
echo "The configuration file is empty, mariadb is being installed"
yum install -y openssl openssl-devel ncurses ncurses-devel bison bison-devel jemalloc jemalloc-devel centos-release-scl devtoolset-7  gcc gcc-c++
            # Install gcc and other dependencies
yum remove cmake -y
ln -s /usr/local/bin/cmake /usr/bin/            #Remove the old version of cmake
cd
wget work.eisc.cn/ruanjian/rpm/lnmp/cmake-3.19.1.tar.gz
tar -xvf cmake-3.19.1.tar.gz                            #cmake version is higher than 3.10
cd cmake-3.19.1 
rm -f CMakeCache.txt                                    #Clear history compilation
. /bootstrap && gmake && gmake install
/usr/local/bin/cmake --version                  #View the compiled cmake version
# wget https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz
                  # Install libevent
cd
wget work.eisc.cn/ruanjian/rpm/lnmp/libevent-2.1.10-stable.tar.gz
tar -xvf libevent-2.1.10-stable.tar.gz 
cd tar -xvf libevent-2.1.10-stable
. /configure --prefix=/usr --disable-static&& make && make install
yum install -y centos-release-scl devtoolset-7 #Install C++High version
gcc --version
scl enable devtoolset-7 bash & echo "single&Symbols execute the following commands in parallel"                               
### Use the new version of gcc to restart invalid###
gcc --version 
echo "The following command does not require interruption like scl, so it gets executed"
cd  
wget http://work.eisc.cn/ruanjian/rpm/lnmp/mariadb-10.5.8.tar.gz
# https://downloads.mariadb.org/                                #Official website mirror
tar -zxvf mariadb-10.5.8.tar.gz
cd mariadb-10.5.8
sed -i "s/MYSQL_VERSION_MAJOR.*/MYSQL_VERSION_MAJOR=101/g" VERSION
                # Modified version number
sed -i "s/MYSQL_VERSION_MINOR.*/MYSQL_VERSION_MINOR=42/g" VERSION 
sed -i "s/MYSQL_VERSION_PATCH.*/MYSQL_VERSION_PATCH=63/g" VERSION 
groupadd -g 41 mysql && useradd -c "MySQL Server"-d /srv/mysql -g mysql -s /bin/false-u 41 mysql
                    # Create user groups and users for mariadb
# sed -i "s@data/test@\${INSTALL_MYSQLTESTDIR}@g" sql/CMakeLists.txt  && mkdir build && cd    build
cmake -DCMAKE_BUILD_TYPE=Release                      \
  - DCMAKE_INSTALL_PREFIX=/usr                     \
  - DINSTALL_DOCDIR=share/doc/mariadb-10.5.8       \
  - DINSTALL_DOCREADMEDIR=share/doc/mariadb-10.5.8 \
  - DINSTALL_MANDIR=share/man                      \
  - DINSTALL_MYSQLSHAREDIR=share/mysql             \
  - DINSTALL_MYSQLTESTDIR=share/mysql/test         \
  - DINSTALL_PLUGINDIR=lib/mysql/plugin            \
  - DINSTALL_SBINDIR=sbin                          \
  - DINSTALL_SCRIPTDIR=bin                         \
  - DINSTALL_SQLBENCHDIR=share/mysql/bench         \
  - DINSTALL_SUPPORTFILESDIR=share/mysql           \
  - DMYSQL_DATADIR=/srv/mysql                      \
  - DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock       \
  - DWITH_EXTRA_CHARSETS=complex                   \
  - DWITH_EMBEDDED_SERVER=ON                       \
  - DSKIP_TESTS=ON                                 \
  - DTOKUDB_OK=0                       
make && make install
:<<!               # Multi-line comments
- DCMAKE_INSTALL_PREFIX=Point to the mysql installation directory
- DINSTALL_SBINDIR=sbin points to the executable file directory (prefix/sbin)
- DMYSQL_DATADIR=/var/lib/mysql points to the mysql data file directory (/var/lib/mysql)
- DSYSCONFDIR=/etc/mysql points to the mysql configuration file directory (/etc/mysql)
- DINSTALL_PLUGINDIR=lib/mysql/plugin points to the plugin category (prefix/lib/mysql/plugin)
- DINSTALL_MANDIR=share/man points to the man document directory (prefix/share/man)
- DINSTALL_SHAREDIR=share points to aclocal/mysql.m4 installation directory (prefix/share)
- DINSTALL_LIBDIR=lib/mysql points to the object code library directory (prefix/lib/mysql)
- DINSTALL_INCLUDEDIR=include/mysql points to the header file directory (prefix/include/mysql)
- DINSTALL_INFODIR=share/info points to the info document storage directory (prefix/share/info)
The official recommendation of prefix is set to/usr
!
install -v -dm 755/etc/mysql                                   #Create a file/etc/mysql/my.cnf
cat >/etc/mysql/my.cnf <<"EOF"
# Begin /etc/mysql/my.cnf
# The following options will be passed to all MySQL clients
[ client]
# password       = your_password
port            =3306
socket          =/run/mysqld/mysqld.sock
# The MySQL server
[ mysqld]
port            =3306
socket          =/run/mysqld/mysqld.sock
datadir         =/srv/mysql
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 16K
myisam_sort_buffer_size = 8M
# Don't listen on a TCP/IP port at all.
# skip-networking
# Note that skip opening here will cause port 3306 to be abnormal
# required unique id between 1 and 2^32-1
server-id       =1
# Uncomment the following if you are using BDB tables
# bdb_cache_size = 4M
# bdb_max_lock =10000
# InnoDB tables are now used by default
innodb_data_home_dir =/srv/mysql
innodb_log_group_home_dir =/srv/mysql
# All the innodb_xxx values below are the default ones:
innodb_data_file_path = ibdata1:12M:autoextend
# You can set.._buffer_pool_size up to 50-80%
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 128M
innodb_log_file_size = 48M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit =1
innodb_lock_wait_timeout =50[mysqldump]
quick
max_allowed_packet = 16M
[ mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
# safe-updates
[ isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[ myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[ mysqlhotcopy]
interactive-timeout
# End /etc/mysql/my.cnf
EOF
:<<!
cd /usr/bin
mv mysql_install_db mysql_install_db_bak
cp /root/mysql_install_db /usr/bin
!
mysql_install_db --basedir=/usr --datadir=/srv/mysql --user=mysql &&
chown -R mysql:mysql /srv/mysql                         #Initialize the database and modify owner permissions
cp /root/mariadb-10.5.8/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
 # update-rc.d mysqld defaults
 chkconfig --add mysqld
 /etc/init.d/mysqld restart
 systemctl status mysqld
' /usr/bin/mysqladmin'-u root password 'root'           #Set a password for mysql
# mysql                                                  #Login, no password by default
mysql -e "set password = password('WWWeisccn')"         #Set a password for the root user
mysql -uroot -pWWWeisccn -e "create database eisc character set utf8 collate utf8_bin;"
              # Log in to the database and create the database name as
##################################################################################################################################
#### Firewall configuration####
systemctl restart firewalld
firewall-cmd --permanent --add-port=3306/tcp            #Open port 3306
firewall-cmd --permanent --add-port=9000/tcp
firewall-cmd --permanent --add-port=80/tcp
systemctl restart firewalld                             #Restart firewall
firewall-cmd --zone=public--list-ports                 #List the ports that the firewall has opened
netstat -ntlp                                           #Monitor the port usage in operation
#### Automatic startup configuration####
# Note: The compiled and installed application will not start automatically after reboot, so you need to add the boot configuration file/etc/rc.d/rc.local
echo "
source /etc/profile
bash /www/server/StartLnmp.sh
" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

echo "
nginx
systemctl restart php-fpm
/etc/init.d/mysqld restart
echo 'LNMP startup time==========>> `date`'>>/root/LNMPlog.txt
" >> /www/server/StartLnmp.sh
##################################################################################################################################
else
echo "The database has been installed"
fi
}
azmariadb
## One-click script execution: wget eisc.cn/file/shell/centos-LNMP.sh ; sh centos-LNMP.sh

Recommended Posts

Compile and install Lnmp shell script under Linux centos
Compile and install LAMP under Centos 5.2
Linux CentOS6 compile and install Pyt
Compile and install libmodbus library under CentOS7
Centos6.5 compile and install LNMP architecture web environment
Know Linux and install CentOS
CentOs7.3 compile and install Nginx 1.9.9
Centos compile and install Git
Install MySQL under Linux (CentOS 7)
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
CentOS 6.8 under linux install mongodb
Install and configure keepalived under CentOS 5.9
CentOS Yum compile and install MySQL 5.6
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Install Python3 and Py under CentOS7
Compile and install QEMU under Ubuntu
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
CentOS7.5 source code compile and install mysql5.7.29
Install mysql8.0.13 version under Linux CentOS7 system
Centos7 compile and install MySQL8 problem record
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
Compile and install nodejs and yum in Centos8
CentOS7.4 source code compile and install MySQL8.0
Install svn and configuration through yum under CentOS
Centos7.2 compile and install way to build phpMyAdmin
Install centos7 and connect
install LNMP on centos7.4
Compile Hadoop-2.7.6 under CentOS7.4
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Linux Centos7 install jdk1.8
CentOS (linux) install PostgreSQL
Install mysql under Centos 7
Install Jenkins under Centos 7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Centos 7 install JDK (Linux install jdk)
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
centos7 install python3 and ipython
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
CentOS6.5 install Java 8 and Tomcat8
Linux Centos7 install redis tutorial
Install MySQL 8.0.16 on Linux Centos
Install Oracle11gR2 database under CentOS6.9
3 partitioning tools under CentOS Linux
Centos6.5 install and configure mongodb
CentOS7 install python3 and pip3
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack confluence
Install MongoDB database under CentOS7