Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ LAMP and LNMP automated installation scripts     - Mount and unloading disks under Linux (Linux)

- Mounting Windows shared directory system under the Linux (Linux)

- Oracle row and column switch to turn columns (Database)

- Spark On YARN cluster installation deployment (Server)

- Mac OS X 10.10 Yosemite compiling OpenJDK 9 (Linux)

- Linux command to view the system status (Linux)

- The difference between free command displays the buffers and cache (Linux)

- Ubuntu modify DNS restart loss problem (Linux)

- Linux System Getting Started Learning: Using yum to download the RPM package without installing (Linux)

- 4 lvcreate example commonly used commands (Linux)

- To setup the Swift language learning environment under linux (Linux)

- ImportTsv-HBase data import tool (Database)

- Java Virtual Machine Basics (Programming)

- iOS developers - a simple factory pattern and OC reflection (Programming)

- Swift used in the application to add a local push at the specified time (Programming)

- Linux Oracle delete archived logs (Database)

- MySQL dual master configuration (Database)

- Java Foundation - Getting Start (Programming)

- Linux System Getting Started Learning: the curl set custom HTTP header (Linux)

- Linux Systems Getting Started Learning: Configuration PCI passthrough on a virtual machine (Linux)

 
         
  LAMP and LNMP automated installation scripts
     
  Add Date : 2018-11-21      
         
         
         
  LAMP & LNMP automated installation scripts
===================================
First, the script describes the environment
Second, the introduction of the script
Third, the function of the script presentation
===================================

First, the script describes the environment
This script is run on RHEL 6.4 version
Running this script should be noted:
1), the host needs access to the Internet, because bloggers are built outside the network yum source Sohu, yum source part of this two parts, one is all the packages inside the disc, one epel source.
2), need to understand the interdependencies between software.
Second, the introduction of the script
Script is made up of functions, each function implemented a function

function create_yum # This function is to build a yum repository sohu
function download # This function is to download all the required packages
This function is a function install_apache # install apache package
function config_apache # This function is to modify the apache service script and open
                                  apache service
This function is a function install_nginx # install nginx package
This function is a function install_mysql # install mysql package
This function is a function config_mysql # initialize and open mysql service mysql
This function is a function install_php # php installation package
This function provides function config_php # php configuration file
This function is a function install_php_fpm # install php-fpm package provides fastcgi services
function config_php_fpm # This function is to modify the php-fpm profile case open
                                php-fpm service
function install_xcache # This function is installed as a package to accelerate the php code
This function is a function install_memcache # installation package of connection memcached
This function is a function install_memcached # install memcached package
This function install_lamp # function which contains only the apache, mysql, php functions
function config_lamp
This function install_lammp # function which contains only the apache, mysql,
                                memcached, php functions
function config_lammp
This function install_lnmp # function which contains only nginx, mysql, php functions
function config_lnmp
This function install_lnmmp # function which contains only nginx, mysql,
                                memcached, php functions
function config_lnmmp

If you think Bo Friends path path configuration file to store data with the results of the Friends of Bo you requested is not the same, that please the Friends of Bo just a little tinkering on their own

Third, the function of the script presentation

1) supported by a machine in a separate installation of a software, such as apache, nginx, mysql, php-fpm, memcached
2) support a machine installed directly lamp, lnmp, lammp, lnmmp architecture
3) if you want to install one by one lamp (lnmp) architecture, please note that the installation sequence: apache (nginx) ->
mysql -> php
4) php and php-fpm actually install php source package, but not the same functionality provided
If your apache and php installed on different machines, so that host php installed
php-fpm;
If your php and mysql installed on different machines, so that host php also installed
php-fpm;
php-fpm and memcached installed on different machines, then the php-fpm that host must be installed memcache, for connection to memcached.
5) After each script is installed, the package will source files generated with the system can identify the header files, library files, binary
6) will provide system V script file for the service
7) the service itself is open, and added to the list of services at startup
The entire script

#! / Bin / bash
#discripte: frist, you linux server must be surf Internet because we use http://mirrors.sohu.com/ yum source and epel source
function create_yum {
dir = / etc / yum.repos.d /
mv $ dir / *. repo / tmp
cat >> $ dir / sohu.repo << EOF
[CentOS]
name = sohu-centos
baseurl = http: //mirrors.sohu.com/centos/ $ releasever / os / $ basearch
gpgcheck = 1
enable = 0
gpgkey = http: //mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-6
[Epel]
name = sohu-epel
baseurl = http: //mirrors.sohu.com/Fedora-epel/ $ releasever / $ basearch /
enable = 1
gpgcheck = 0
EOF
yum clean all &> / dev / null
}
function download {
yum -y install wget
cd / root
echo -e " 033 [32m ========= download about web server source package ========== 033 [0m"
wget http://mirror.esocc.com/apache/apr/apr-1.4.6.tar.bz2
wget http://mirror.esocc.com/apache/apr/apr-util-1.5.2.tar.bz2
wget http://mirror.esocc.com/apache/httpd/httpd-2.4.6.tar.bz2
wget http://nginx.org/download/nginx-1.4.2.tar.gz
echo -e " 033 [32m ========= download about php or php-fpm soure package ======== 033 [0m"
wget http://xcache.lighttpd.net/pub/Releases/3.0.3/xcache-3.0.3.tar.bz2
wget http://pecl.php.net/get/memcache-2.2.7.tgz
wget http://downloads.php.net/stas/php-5.4.19.tar.bz2
echo -e " 033 [32m ====== download about memcached source package ======== 033 [0m"
wget http://nchc.dl.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.21-stable.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
echo -e " 033 [32m ====== download about mysql source package ========= 033 [0m"
wget http://mysql.llarian.net/Downloads/MySQL-5.5/mysql-5.5.33.tar.gz
}
function install_apache {
cd / root
yum -y install pcre-devel
tar xf apr-1.4.6.tar.bz2
tar xf apr-util-1.5.2.tar.bz2
tar xf httpd-2.4.6.tar.bz2
cd /root/apr-1.4.6
./configure --prefix = / usr / local / apr && make && make install
echo -e " 033 [32m ========= apr is ok ======== 033 [0m"
cd /root/apr-util-1.5.2
./configure --prefix = / usr / local / apr-util --with-apr = / usr / local / apr && make && make install
echo -e " 033 [32m ========= apr-util is ok ======== 033 [0m"
cd /root/httpd-2.4.6
./configure --prefix = / usr / local / apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib
--with-pcre --with-apr = / usr / local / apr --with-apr-util = / usr / local / apr-util --enable-modules = most
--enable-mpms-shared = all --with-mpm = event && make && make install
echo -e " 033 [32m ========= httpd is ok ======== 033 [0m"
}
function config_apache {
echo -e " 033 [32m frist, Associated system path 033 [0m"
echo "PATH = / usr / local / apache / bin /: $ PATH"> /etc/profile.d/httpd.sh
source /etc/profile.d/httpd.sh
ln -sv / usr / local / apache / include / / usr / include / httpd
echo -e " 033 [32m second, Modify configuration files and provided systemV scripts 033 [0m"
IP = `ifconfig | grep" inet addr "| grep -v" 127.0.0.1 "| awk -F: '{print $ 2}' | cut -d '' -f1`
cp /root/httpd-2.4.6/build/rpm/httpd.init /etc/rc.d/init.d/httpd
sed -i '/ httpd / s / usr / sbin / httpd / usr / local / apache / bin / httpd / g' /etc/rc.d/init.d/httpd
sed -i '/ ^ httpd / a prog = httpd' /etc/rc.d/init.d/httpd
sed -i '/ ^ pidfile / s / var / run / usr / local / apache / logs / g' /etc/rc.d/init.d/httpd
sed -i 's / etc / httpd / conf /httpd.conf/usr / local / apache / conf /httpd.conf/g' /etc/rc.d/init.d/httpd
sed -i '$ a ServerName' $ IP ': 80' /usr/local/apache/conf/httpd.conf
chkconfig --add httpd
chkconfig --level 35 httpd on
service httpd start
}
function install_nginx {
cd / root
yum -y install pcre-devel
tar xf nginx-1.4.2.tar.gz
groupadd nginx
useradd -r -g nginx nginx
cd /root/nginx-1.4.2
./configure
--prefix = / usr
--sbin-path = / usr / sbin / nginx
--conf-path = / etc / nginx / nginx.conf
--error-log-path = / var / log / nginx / error.log
--http-log-path = / var / log / nginx / access.log
--pid-path = / var / run / nginx / nginx.pid
--lock-path = / var / lock / nginx.lock
--user = nginx
--group = nginx
--with-http_ssl_module
--with-http_flv_module
--with-http_stub_status_module
--with-http_gzip_static_module
--http-client-body-temp-path = / var / tmp / nginx / client /
--http-proxy-temp-path = / var / tmp / nginx / proxy /
--http-fastcgi-temp-path = / var / tmp / nginx / fcgi /
--http-uwsgi-temp-path = / var / tmp / nginx / uwsgi
--http-scgi-temp-path = / var / tmp / nginx / scgi
--with-pcre && make && make install
echo -e " 033 [32m ========= nginx is ok ======== 033 [0m"
}
function install_mysql {
cd / root
yum -y install cmake bison
useradd -r mysql
tar xf mysql-5.5.33.tar.gz
cd /root/mysql-5.5.33
cmake. -DCMAKE_INSTALL_PREFIX = / usr / local / mysql -DMYSQL_DATADIR = / mydata / data -DSYSCONFDIR = / etc
-DWITH_INNOBASE_STORAGE_ENGINE = 1 -DWITH_ARCHIVE_STORAGE_ENGINE = 1 -DWITH_BLACKHOLE_STORAGE_ENGINE = 1
-DWITH_READLINE = 1 -DWITH_SSL = system -DWITH_ZLIB = system -DWITH_LIBWRAP = 0 -DMYSQL_UNIX_ADDR = / tmp / mysql.sock
-DDEFAULT_CHARSET = Utf8 -DDEFAULT_COLLATION = utf8_general_ci
make && make install
echo -e " 033 [32m ========= mysqld is ok ======== 033 [0m"
}
function config_mysql {
echo -e " 033 [32m frist, Associated system path, and Initialization database 033 [0m"
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chown -R root.mysql / usr / local / mysql /
mkdir -pv / mydata / data
chown -R mysql: mysql / mydata / data /
sed -i '/ thread_concurrency / a datadir = / mydata / data' /etc/my.cnf
sed -i '/ datadir / a innodb_file_per_table = 1' /etc/my.cnf
/ Usr / local / mysql / scripts / mysql_install_db --user = mysql --datadir = / mydata / data / --basedir = / usr / local / mysql
service mysqld start
echo "PATH = / usr / local / mysql / bin: $ PATH"> /etc/profile.d/mysqld.sh
source /etc/profile.d/mysqld.sh
echo "/ usr / local / mysql / lib"> /etc/ld.so.conf.d/mysqld.conf
ldconfig -v | grep mysql
ln -sv / usr / local / mysql / include / / usr / include / mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
}
function install_php {
yum -y install libxml2-devel bzip2-devel curl-devel libmcrypt-devel mhash-devel
tar xf php-5.4.19.tar.bz2
cd /root/php-5.4.19
./configure --prefix = / usr / local / php --with-mysql = / usr / local / mysql --with-openssl --with-mysqli = / usr / local / mysql / bin / mysql_config
--enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir = / usr
--enable-xml --enable-sockets --with-apxs2 = / usr / local / apache / bin / apxs --with-mcrypt --with-curl
--with-config-file-path = / etc --with-config-file-scan-dir = / etc / php.d --with-bz2 --enable-maintainer-zts
make && make install
echo -e " 033 [32m ========= php is ok ======== 033 [0m"
}
function config_php {
cp /root/php-5.4.19/php.ini-production /etc/php.ini
}
function install_php_fpm {
yum -y install libxml2-devel bzip2-devel curl-devel libmcrypt-devel mhash-devel
tar xf php-5.4.19.tar.bz2
cd /root/php-5.4.19
./configure --prefix = / usr / local / php --with-mysql = mysqlnd --with-pdo-mysql = mysqlnd --with-mysqli = mysqlnd
--with-openssl --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib-dir --with-libxml-dir = / usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path = / etc
--with-config-file-scan-dir = / etc / php.d --with-bz2 --with-curl --enable-maintainer-zts --enable-fpm && make && make install
echo -e " 033 [32m ========= php-fpm is ok ======== 033 [0m"
}
function config_php_fpm {
echo -e " 033 [32m frist, Associated system path 033 [0m"
IP2 = `ifconfig | grep" inet addr "| grep -v" 127.0.0.1 "| awk -F: '{print $ 2}' | cut -d '' -f1`
cp /root/php-5.4.19/php.ini-production /etc/php.ini
echo "PATH = / usr / local / php / bin: / usr / local / php / sbin: $ PATH"> /etc/profile.d/php-fpm.sh
source /etc/profile.d/php-fpm.sh
echo -e " 033 [32m second, Modify configuration files and provided systemV scripts 033 [0m"
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
sed -i 's / 127 .0 .0 .1 /' $ IP2 '/ g' /usr/local/php/etc/php-fpm.conf
cp /root/php-5.4.19/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod + x /etc/rc.d/init.d/php-fpm
service php-fpm start
chkconfig --add php-fpm
chkconfig --level 35 php-fpm on
}
function install_xcache {
cd / root
tar xf xcache-3.0.3.tar.bz2
if [-d / usr / local / php]; then
  cd /root/xcache-3.0.3
  / Usr / local / php / bin / phpize
  ./configure --enable-xcache --with-php-config = / usr / local / php / bin / php-config
  make && make install
else
    install_php_fpm
  cd /root/xcache-3.0.3
  / Usr / local / php / bin / phpize
  ./configure --enable-xcache --with-php-config = / usr / local / php / bin / php-config
  make && make install
  echo -e " 033 [32m ========= xcache is ok ======== 033 [0m"
fi
}
function install_memcache {
cd / root
tar xf memcache-2.2.7.tgz
if [-d / usr / local / php]; then
  cd /root/memcache-2.2.7
  / Usr / local / php / bin / phpize
  ./configure --with-php-config = / usr / local / php / bin / php-config --enable-memcache && make && make install
else
    install_php_fpm
    cd /root/memcache-2.2.7
    / Usr / local / php / bin / phpize
  ./configure --with-php-config = / usr / local / php / bin / php-config --enable-memcache && make && make install
  echo -e " 033 [32m ========= memcache is ok ======== 033 [0m"
fi
}
function install_memcached {
cd / root
tar xf libevent-2.0.21-stable.tar.gz
tar xf memcached-1.4.15.tar.gz
cd /root/libevent-2.0.21-stable
./configure --prefix = / usr / local / libevent && make && make install
echo -e " 033 [32m ========= libevent is ok ======== 033 [0m"
cd / usr / local / libevent /
echo "/ usr / local / libevent / lib"> /etc/ld.so.conf.d/libevent.conf
ldconfig -v | grep libevent
ln -sv / usr / local / libevent / / usr / include / libevent
cd /root/memcached-1.4.15
./configure --prefix = / usr / local / memcached --with-libevent = / usr / local / libevent /
make && make install
echo -e " 033 [32m ========= memcached is ok ======== 033 [0m"
}
function install_lamp {
install_apache
install_mysql
install_php
install_xcache
}
function config_lamp {
config_apache
config_mysql
config_php
}
function install_lnmp {
install_nginx
install_mysql
install_php
install_xcache
}
function config_lnmp {
config_mysql
config_php
}
function install_lammp {
install_apache
install_mysql
install_php
install_xcache
install_memcache
install_memcached
}
function config_lammp {
config_apache
config_mysql
config_php
config_php_fpm
}
function install_lnmmp {
install_nginx
install_mysql
install_php
install_xcache
install_memcache
install_memcached
}
function config_lnmmp {
config_mysql
config_php
config_php_fpm
}
echo -e " 033 [32m ==== make sure yum is ok ========= 033 [0m"
#create_yum
echo -e " 033 [32m ==== now, download all package ==== 033 [0m"
#download
echo -e " 033 [32m ==== install development packages ==== 033 [0m"
#yum -y groupinstall "Development tools" "Server Platform Development"
 echo -e " 033 [32m ========= you can choice you need install package ========== 033 [0m"
cat << EOF
apache | A) install apache source package.
nginx | ​​N) install nginx source package.
mysql | M) install mysql source package.
php | P) install php source package.
php-fpm | PF) install php-fpm source package.
xcache | X) install xcahe source package.
memcache | ME) install memcache source package.
memcached | MD) install memcached source package.
lamp) install lamp source package.
lammp) install lammp source package.
lnmp) install lnmp source package.
lnmmp) install lnmmp source package.
q | Q) quit
EOF
read -p "Please choose to install:" Choice
echo -e " 033 [32m ===== start install $ Choice ==== 033 [0m"
until [$ Choice == q -o $ Choice == Q]; do
 case $ Choice in
apache | A)
  install_apache
  config_apache ;;
nginx | ​​N)
  install_nginx ;;
mysql | M)
  install_mysql
  config_mysql ;;
php | P)
  install_php
  config_php ;;
php-fpm | PF)
  install_php_fpm
  config_php_fpm ;;
xcache | X)
  install_xcache ;;
memcache | ME)
  install_memcache ;;
memcached | MD)
  install_memcached ;;
lamp)
  install_lamp
  config_lamp ;;
lammp)
  install_lammp
  config_lammp ;;
lnmp)
  install_lnmp
  config_lnmp ;;
lnmmp)
  install_lnmmp
  config_lnmmp ;;
q | Q)
    break
esac
  read -p "Have any choice agin, if you no, q | Q is quit:" Choice
  done

This script and nginx systemV, memcached system V script uploaded as attachments

defect:
1) did not provide the automation system V script nginx, nginx but the system V script I will upload an attachment, you need vim /etc/rc.d/init.d/nginx Friends of Bo and then copy I provide system V script and then add permissions, you can service nginx start the
2) also failed to provide memcached automation system V script, but the memcached system V script to upload an attachment, you need vim /etc/rc.d/init.d/memcached Friends of Bo and then copy the system V me the script then add permissions, you can service memcached start the
     
         
         
         
  More:      
 
- Nginx + uWSGI + Django + Python Application Architecture Deployment (Server)
- Oracle Character Set Summary (Database)
- Let VMware ESXi virtual switch support VLAN (Linux)
- Production environment Linux bonding method standby mode slave card switch (Server)
- SELinux multi-level security (Linux)
- Linux cd command Detailed (Linux)
- How to choose the correct HTTP status code (Server)
- Oracle 10g relations with the constraint of column properties NULLABLE (Database)
- Loop arrays in C language is not easy to find a bug (Programming)
- To install Cinnamon desktop environment on your Ubuntu 14.04 / 12.04 (Linux)
- Ubuntu install driver manager Mint Driver Manager and Device Driver Manager (Linux)
- Docker study notes (Server)
- Github inventory objects Algorithm (Linux)
- C language programming entry - macro definitions and enum (Programming)
- PostgreSQL Select source code analysis (Database)
- True and false in Perl (Programming)
- IO reference Docker container (Server)
- MySQL Installation Troubleshooting (Database)
- Android Application Development: Genymotion can not start solving (Linux)
- Setting Derby as Linux / Windows running as a service from the start (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.