Lnmp + FastCGI platform build script

Source: Internet
Author: User
Tags openldap

Lnmp + FastCGI platform build script

This script describes how to build the lnmp + FastCGI platform. The installation package to be prepared is as follows:

Cmake-2.8.10.2.tar.gz

Libevent-2.0.21-stable.tar.gz

Libmcrypt-2.5.8.tar.gz

Mhash-0.9.9.9.tar.gz

Nginx-1.2.0.tar.gz

Php-5.4.9.tar.gz
Libiconv-1.13.tar.gz

Mysql-5.5.13.tar.gz

The script is replaced by lnmp1_memcached.zip. The script is placed in the same directory as the installation package.

Install the dependency package first. You need to configure the yum source. We will not go into details here. The following is the script content:

#! /Bin/bash
Echo "++ +++"
Echo "+ check Yum repository configuration +"
Echo "++ +++"
Yum clean all>/dev/null
Yum list>/dev/null
If [$? -EQ 0]; then
Echo "yum repository configuration is normal"
Sleep 1
Else
Echo "the yum repository configuration is abnormal. Check the yum configuration"
Fi
Echo "++ +++"
Echo "+ install dependent software package +"
Echo "++ +++"
Yum-y install GCC gcc-C ++ Autoconf automake bison flex FreeType-devel fontconfig-devel gettext-devel libjpeg-devel libpng-devel libxml2 libxml2-devel libtool lib- ltlibdl tool- ltdl-devel LibTIFF-devel libxpm-devel libicu-devel libidn kernel-devel libxslt-devel zlib-devel glibc-devel glib2 glib2-devel kernel bzip2-devel ncurses-devel curl- devel e2fsprogs e2fsprogs-devel krb5 krb5-devel OpenSSL-devel OpenLDAP openldap-devel nss_ldap openldap-clients openldap-servers PCRE-devel Pam-devel vim-enhanced mysql-devel

Unzip lnmp1_memcached.zip


Installnginx (){
Read-P "is about to begin nginx installation. Do you want to start installation? (Y/n) "command_nginx_install
If [$ command_nginx_install = N] | [$ command_nginx_install = N]; then
Echo "installation canceled! "
Exit
Elif [$ command_nginx_install = y] | [$ command_nginx_install = y]; then
Echo "installation is starting ...... "
Sleep 2
Fi
CD lnmp + memcached
Useradd-S/sbin/nologin-M nginx
Tar-zxf nginx-1.2.0.tar.gz-C/usr/src/
CD/usr/src/nginx-1.2.0/
. /Configure -- prefix =/usr/local/nginx -- PID-Path =/usr/local/nginx. PID -- 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 =/usr/local/nginx/client -- http-proxy -Temp-Path =/usr/local/nginx/Proxy -- http-FastCGI-temp-Path =/usr/local/nginx/fcgi -- http-uwsgi-temp-Path =/ usr/local/nginx/uwsgi -- http-scgi-temp-Path =/usr/local/nginx/scgi -- With-PCRE
If [$? -EQ 0]; then
Echo "configuration complete, prepare for compilation and installation"
Else
Echo "configuration failed. Please check"
Exit
Fi
Make & make install
If [$? -EQ 0]; then
Echo "nginx installation completed"
Else
Echo "nginx Installation failed. Please check"
Exit
Fi
}
Installmysql (){
Echo "##############################"
Echo "# Start to install MySQL database ...... #"
Echo "##############################"
Read-P "is about to begin MySQL database installation. Continue? (Y/n) "command_mysql_install
If [$ command_mysql_install = N] | [$ command_mysql_install = N]; then
Echo "installation canceled! "
Exit
Elif [$ command_mysql_install = y] | [$ command_mysql_install = y]; then
Echo "installation is starting ...... "
Sleep 2
Fi
CD/root/lnmp + memcached
Useradd-S/sbin/nologin-M MySQL
Echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
Echo "~ Install the cmake tool ~ "
Echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
Tar-zxf cmake-2.8.10.2.tar.gz-C/usr/src/
CD/usr/src/cmake-2.8.10.2/
./Bootstrap -- prefix =/usr/local/cmake
Make & make install
Echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
Echo "~ Install MySQL database ~ "
Echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
CD/root/lnmp + memcached
Tar-zxf mysql-5.5.13.tar.gz-C/usr/src/
CD/usr/src/mysql-5.5.13/
/Usr/local/cmake/bin/cmake-dcmake_install_prefix =/usr/local/MySQL-dsysconfdir =/etc-dmysql_datadir =/usr/local/MySQL/data-dmysql_tcp_port = 3306- dmysql_unix_addr =/tmp/mysqld. sock-dmysql_user = mysql-dextra_charsets = All-dwith_readline = 1-dwith_ssl = system-dwith_embedded_server = 1-denabled_local_infile = 1-dwith_innobase_storage_engine = 1
If [$? -EQ 0]; then
Echo "the configuration is complete and compilation and installation will begin soon"
Else
Echo "configuration failed. Please check! "
Exit
Fi
Make & make install
If [$? -EQ 0]; then
Echo "MySQL installation is complete, preparation for initialization"
Else
Echo "MySQL Installation failed. Please check! "
Exit
Fi
CD/usr/local/MySQL/
Chown-r mysql. MySQL.
./Scripts/mysql_install_db -- user = MySQL
CDS/usr/src/mysql-5.5.13/support-files/
CP my-medium.cnf/etc/My. CNF
CP mysql. Server/etc/init. d/mysqld
Chmod + x/etc/init. d/mysqld
Chkconfig -- add mysqld
Service mysqld Start>/dev/null
CD/usr/local/MySQL/
./Scripts/mysql_install_db -- user = MySQL
Export Path =/usr/local/MySQL/bin/: $ path
Echo "Export Path =/usr/local/MySQL/bin: $ path">/etc/bashrc
Echo "/usr/local/MySQL/lib/">/etc/lD. So. conf
Ldconfig
If [$? -EQ 0]; then
Echo "MySQL initialization completed"
Else
Echo "MySQL initialization failed. Please check! "
Exit
Fi
}
Installphp (){
Echo "##############################"
Echo "# Start to install the PHP service #"
Echo "##############################"
Read-P "is about to install the PHP service. Continue? (Y/n) "command_php_install
If [$ command_php_install = N] | [$ command_php_install = N]; then
Echo "installation canceled"
Exit
Elif [$ command_php_install = y] | [$ command_php_install = y]; then
CD/root/lnmp + memcached
Echo "start to install PHP"
Fi
Echo "##############################"
Echo "# Install the PHP dependency package #"
Echo "##############################"
Tar-zxf mhash-0.9.9.9.tar.gz-C/usr/src
CD/usr/src/mhash-0.9.9.9
./Configure
Make & make install
If [$? -EQ 0]; then
Echo "mhash installation completed"
Else
Echo "mhash Installation failed"
Exit
Fi
Sleep 2
CD/root/lnmp + memcached
Tar-zxf libmcrypt-2.5.8.tar.gz-C/usr/src
CD/usr/src/libmcrypt-2.5.8
./Configure
Make & make install
CD libltdl/
./Configure -- With-gmetad -- enable-gexec-enable-ltdl-install
Make & make install
If [$? -EQ 0]; then
Echo "libmcrypt installation completed"
Else
Echo "libmcrypt Installation failed"
Exit
Fi
Sleep 2
CD/root/lnmp + memcached
Tar-zxf libiconv-1.13.tar.gz-C/usr/src
CD/usr/src/libiconv-1.13
./Configure
Make & make install
If [$? -EQ 0]; then
Echo "libconv installation completed"
Else
Echo "libconv Installation failed"
Exit
Fi
Sleep 2
CD/root/
Ln-SV/usr/local/lib/libmcrypt */usr/lib/
Ln-SV/usr/local/lib/libmhash. */usr/lib/
Ldconfig-V
Echo "###################################### ########"
Echo "# Start to install the PHP Main Program #"
Echo "###################################### ########"
CD/root/lnmp + memcached
Tar-zxf php-5.4.9.tar.gz-C/usr/src/
CD/usr/src/php-5.4.9
. /Configure -- prefix =/usr/local/php5nginx -- With-config-file-Path =/usr/local/php5nginx/etc -- With-mysql =/usr/local/MySQL -- with-mysqli =/usr/local/MySQL/bin/mysql_config -- With-iconv-Dir =/usr/local -- With-FreeType-dir -- With-JPEG-dir --- PNG-dir -- With-zlib -- With-libxml-Dir =/usr -- enable-XML -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline -optimization -- With-curl -- With-curlwrappers -- enable-mbregex -- enable-FPM -- enable-mbstring -- With-mcrypt -- With-Gd -- enable-Gd-native-TTF -- -OpenSSL -- With-mhash -- enable-pcntl -- enable-sockets -- With-LDAP-sasl -- With-XMLRPC -- enable-zip -- enable-soap
If [$? -EQ 0]; then
Echo "PHP configuration complete"
Else
Echo "PHP configuration failed. Please check it! "
Exit
Fi
Make zend_extra_libs = '-liconv'
Make install
If [$? -EQ 0]; then
Echo "PHP installation is complete, preparation for initialization"
Else
Echo "PHP installation failed. Please check! "
Exit
Fi
Cp php. ini-production/usr/local/php5nginx/etc/PHP. ini
CP/usr/local/php5nginx/etc/php-fpm.conf.default/usr/local/php5nginx/etc/php-fpm.conf
CD/usr/src/php-5.4.9/SAPI/FPM/
CP init. d. php-FPM/etc/init. d/PHP-FPM
Chmod + x/etc/init. d/PHP-FPM
Chkconfig -- add PHP-FPM
Service PHP-FPM start
If [$? -EQ 0]; then
Echo "php initialization completed"
Else
Echo "php initialization failed. Please check! "
Exit
Fi
}

Case $1 in
Nginx)
Installnginx ;;
MySQL)
Installmysql ;;
PHP)
Installphp ;;
Lnmp)
Installnginx
Installmysql
Installphp ;;
*)
Echo "This script can install nginx, MySQL, PHP, and build the lnmp platform as a whole. Enter the services to install. Example: Sh nginx. Sh lnmp ";;
Esac

When using this script, you can add execution permissions to the script:

Chmod + x lnmp. Sh

Use it directly. /lnmp. sh installation can be executed. Note that this script must specify the part to be installed. For example, to install MySQL, enter it during execution. /lnmp. sh MySQL.

If you install the lnmp platform on a bare metal, you can use./lnmp. Sh lnmp to build the lnmp platform.

Because we may execute the Script Multiple times during installation, we can save the yum installation part in the script as a script or encapsulate it as a function, add a case after the script for calling.

This article from the "cigarette head network management" blog, please be sure to keep this source http://8838848.blog.51cto.com/8828848/1571248

Lnmp + FastCGI platform build script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.