#lanmp环境配置的主要文件. lib/common.conf. lib/common.sh. lib/mysql.sh. lib/apache.sh. lib/ Nginx.sh. lib/php.sh. lib/na.sh. lib/libiconv.sh. lib/eaccelerator.sh. lib/zend.sh. lib/pureftp.sh. lib/pcre.sh. lib/webconf.sh. lib/service.sh# above are reference function files, basically is the installation function of each module, Has analyzed several, the format is probably the same, basically is the order list. # determine if the installation package path exists, and if the log path exists and does not exist then establish [ -d $IN _src ] | | mkdir $IN _src[ -d $LOGPATH ] | | mkdir $LOGPATH # Determine the service modules that need to be installed ### echo "Select install 1 apache + php + mysql + zend + eaccelerator + pureftpd + phpmyadmin 2 nginx + php + mysql + zend + eAccelerator + pureftpd + phpmyadmin 3 nginx + apache + php + mysql + zend + eAccelerator + pureftpd + phpmyadmin 4 install all service 5 don ' T install is now "sleep 0.1read -p " please input 1,2,3,4,5: " SERVER_ID# Depending on the result of the read return, different numbers correspond to different mounting modules if [[ $SERVER _id == 2 ]]; then server= "Nginx" elif [[ $SERVER _id == 1 ]]; then Server= "Apache" elif [[ $SERVER _id == 3 ]]; then server= " Na "elif [[ $SERVER _id == 4 ]]; then server=" all "else exitfi# based on the results of the read return, determine the installed PHP version echo "select php version: 1 php-5.2.17 (default) 2 php-5.3.29 "sleep 0.1read -p "please input 1,2: "   php_ver_idif [[ $PHP _ver_id == 2 ]]; then php_ver= "5.3.29 "Else php_ver=" 5.2.17 "fi# judging the network situation ping -c 1 -t 1 www.wdlinux.cn >/dev/null 2>&1# to determine if the network is unblocked and not unblocked according to the status of the ping returned, add the DNS address if [[ $? == 2 ]]; then echo "nameserver 8.8.8.8nameserver 202.96.128.68" > /etc/resolv.conf echo "Dns err" fiping -c 1 -t 1 www.wdlinux.cn >/dev/null 2>&1# according to the result of Ping, judge whether to the official website unblocked, not general error if [[ $? == 2 ]]; then echo "Dns err" exitfi# determines whether the operating system is centos or  REDHAT&NBSP based on the value of the $OS_RL variable, and configures yum.conf if [ $OS _rl == 1 ]; then sed -i ' s/^exclude=/#exclude =/g ' /etc/ yum.conffi# depending on the result of the variable, different operating systems, installation of the initial preparatory workMake different if [ $OS _rl == 2 ]; then #ubuntu系列的操作系统, ready to install some packages. service apache2 stop 2>/dev/null service mysql stop 2>/dev/null service pure-ftpd stop 2>/ dev/null apt-get update apt-get remove -y apache2 apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-common mysql-client mysql-server php5 php5-fpm pure-ftpd pure-ftpd-common pure-ftpd-mysql 2>/dev/ null apt-get -y autoremove [ -f /etc/mysql/ my.cnf ] && mv /etc/mysql/my.cnf /etc/mysql/my.cnf.lanmpsave apt-get install -y gcc g++ make autoconf libltdl-dev libgd2-xpm-dev libfreetype6 libfreetype6-dev libxml2-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libssl-dev patch libmcrypt-dev libmhash-dev libncurses5-dev libreadline-dev bzip2 libcap-dev ntpdate diffutils exim4 iptables unzip sudo if [ $X 86 == 1 ]; then ln - Sf /usr/lib/x86_64-linux-gnu/libpng* /usr/lib/ ln -sf /usr/lib/x86_64-linux-gnu/liBjpeg* /usr/lib/ else ln -sf /usr/lib/i386-linux-gnu/libpng* /usr/lib/ ln - sf /usr/lib/i386-linux-gnu/libjpeg* /usr/lib/ fielse # The centos series. rpm --import lanmp/RPM-GPG-KEY.dag.txt [ $R 6 == 1 ] && el= "El6" | | el= "El5" rpm -ivh http://pkgs.repoforge.org/rpmforge-release/ Rpmforge-release-0.5.3-1. $el. rf.$ (uname -m). RPM    YUM INSTALL -Y GCC gcc-c++ make sudo autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel bzip2 libcap-devel ntp sysklogd diffutils sendmail iptables unzip if [ $X 86 == 1 ]; then ln -sf /usr/lib64/libjpeg.so /usr/lib/ ln -sf /usr/lib64/libpng.so /usr/lib/ fi ln -sf /usr/share/zoneinfo/asia/shanghai /etc/localtimefi# Check Time Ntpdate tiger.sina.com.cnhwclock -w# determines whether the custom installation file directory exists, does not exist, and re-establishes the if [ ! -d $IN _dir ]; then mkdir -p $IN _dir/{etc,init.d,wdcp_bk/conf} mkdir -p /www/web #根据OS_RL的值, conduct operating system judgment, do different service processing. if [ $OS _rl == 2 ]; then /etc/init.d/ apparmor stop >/dev/null 2>&1 update-rc.d -f apparmor remove >/dev/null 2>&1 apt-get remove -y apparmor apparmor-utils >/dev/null 2>&1 ogroup=$ (awk -f ': ' '/x:1000:/ {print $1} ' /etc/group) [ -n "$ogroup"  ] && groupmod -g 1010 $ogroup >/dev/null 2>&1 ouser=$ (awk -f ': ' '/x:1000:/ {print $1} ' /etc/ passwd) [ -n "$ouser" ] && Usermod -u 1010 -g 1010 $ouser >/dev/null 2>&1 adduser --system --group --home /nonexistent --no-create-home mysql >/dev/null 2>&1 else setenforce 0 sed -i ' s/selinux=enforcing/selinux=disabled/g ' /etc/selinux/config service httpd stop >/dev/null 2>&1 service mysqld stop >/dev/null 2>&1 chkconfig --level 35 httpd off >/dev/null 2>&1 chkconfig --level 35 mysqld off >/dev/null 2>&1 chkconfig --level 35 sendmail off >/dev/null 2>&1 groupadd -g 27 mysql >/dev/null 2>&1 useradd -g 27 -u 27 -d /dev/null -s /sbin/nologin mysql >/dev/null 2>&1 fi groupadd -g 1000 www >/dev/null 2>&1 useradd -g 1000 -u 1000 -d /dev/null -s /sbin/nologin www >/dev/null 2>&1fi# Download Installer #wget_down is a download function, previously defined cd $IN _src[ $IN _dir = "/www/wdlinux" ] | | IN_DIR_ME=1if [ $SERVER == "Apache" ]; then wget_ down $HTTPD _duelif [ $SERVER == "Nginx"  ]; THEN    WGet_down $NGINX _du $PHP _fpm $PCRE _dufiif [ $X 86 == "1" ]; then wget_down $ZENDX 86_duelse wget_down $ZEND _dufiwget_ down $MYSQL _du $PHP _du $EACCELERATOR _du $VSFTPD _du $PHPMYADMIN _du# define function functions to perform initialization in_all { na_ins server= "Nginx"; php_ins eaccelerator_ins zend_ins rm -f $php _inf $eac _inf $zend _inf server= "Apache"; php_ins Eaccelerator_ins zend_ins} #其他服务的初始化mysql_insif [ $SERVER == "All" ]; then in_allelse ${SERVER}_ins php_ins eaccelerator_ins zend_insfipureftpd_insstart_ Srvlanmp_in_finsh
WDCP Environment Build shell script analysis--lanmp.sh