在五花八门的语言里,PHP作为我第一个觉得欣赏的理由,就是它的简单和快捷,因为它封装了许多的常用函数。PHP作为网站中一种算作比较流行的语言,也产生各种优秀的框架。我所接触过的有zend framework 1、think php、yii框架,这些框架中属zend framework似
在五花八门的语言里,PHP作为我第一个觉得欣赏的理由,就是它的简单和快捷,因为它封装了许多的常用函数。PHP作为网站中一种算作比较流行的语言,也产生各种优秀的框架。我所接触过的有zend framework 1、think php、yii框架,这些框架中属zend framework似乎不太尽人意,因为作为官方的框架,大家给予的期望也是比较高的,但是在国内这个框架用的并不多。可是我作为一个还算比较忠实的PHP爱好者,我还是用zend framework 1搭建了第一个属于自己的网站——仿动网论坛。不说曾经了,zend framework 2似乎是去年出来的吧,我也捣鼓过一段时间,因为后来工作的关系,我逐渐很少去研究这个了。现在国内的这方面资料还非常稀缺,虽然有人已经翻译了官方的文档,但是我想对于初学者来说还是很难上手。特别是搭建开发环境的,我就更少看见了,要么是笼统的概括,要么就是凌乱的东拼西凑。本文供给那些想要了解新框架的人,也同时为自己做一个笔记,因为这些东西随着时间的推移是会渐渐淡忘的。
你可以去找一些集成lnmp的脚本,或者使用我提供的这个脚本进行基础的环境安装,下面的代码下载后保存为install_web_develop.sh,怎么运行请百度shell脚本运行。
#!/bin/<span>bash #filename:test.</span><span>sh</span><span> #author:viticm #createtime:</span><span>2013</span>-<span>5</span>-<span>31</span> <span>11</span>:<span>12</span>:<span>03</span><span> #use: </span><span>install</span><span> web develop cUser</span>=`<span>whoami</span><span>` cCommand</span>=$<span>1</span><span> cDownload</span>=<span>on cBase</span>=<span>no cWebUser</span>=<span>www cInstallFile</span>=/web/<span> cInstallPhpPath</span>=/usr/local/php/<span> cInstallNginxPath</span>=/usr/local/nginx/<span> cInstallMysqlPath</span>=/usr/local/mysql/<span> cPhpMakefile</span>=/home/<span>Makefile iSystemType</span>=<span>`getconf LONG_BIT` Arr_OpenPortList</span>=<span>""</span><span> cTestDomain</span>=<span>www.baidu.com ##### mysql config ##### cMysqlDefaultPasswd</span>=<span>mysql cMysqlInstallPath</span>=/usr/local/mysql/<span> cMysqlConfUploadFile</span>=`<span>pwd</span>`/<span>my.cnf ##### mysql config ##### ####### PHP ####### cDate_TimeZone</span>=<span>"</span><span>Asia/Shanghai</span><span>"</span><span> cDisplay_Errors</span>=<span>On cError_Reporting</span>=<span>"</span><span>E_ALL & ~E_NOTICE</span><span>"</span><span> cAllow_Call_Time_Pass_Reference</span>=<span>On ###### PHP ######## #### PHP</span>-<span>FPM CONFIGS #### pm_max_children</span>=<span>64</span><span> pm_start_servers</span>=<span>20</span><span> pm_min_spare_servers</span>=<span>5</span><span> pm_max_spare_servers</span>=<span>35</span><span> pm_max_requests</span>=<span>1024</span><span> pm_user</span>=<span>${cWebUser} pm_group</span>=<span>${cWebUser} #### PHP</span>-<span>FPM CONFIGS #### usage() { </span><span>cat</span> EOF Usage: $<span>0</span> <params> -m or --mysql <span>install</span><span> mysql </span>-n or --nginx <span>install</span><span> nginx </span>-p or --php <span>install</span> php( and this can enter two params,like -p <span>5.3</span>( <span>5.4</span> ) <span>then</span> <span>install</span> php what version is <span>5.3</span><span> ) EOF return </span><span>0</span><span> } # on OEL, </span>/etc/issue states <span>"</span><span>Enterprise Linux Enterprise Linux Server</span><span>"</span><span> SUPPORTED_OS</span>=<span>'</span><span>CentOS|Red Hat Enterprise Linux Server|Enterprise Linux Enterprise Linux Server|Fedora|SUSE|Debian GNU/Linux|Ubuntu|Oracle Linux Server</span><span>'</span> <span>if</span> ! <span>egrep</span> -q <span>"</span><span>$SUPPORTED_OS</span><span>"</span> /etc/issue ; <span>then</span> <span>cat</span> EOF Unable to <span>install</span>: Your distribution is not suitable <span>for</span><span> installation using Zend</span><span>'</span><span>s DEB/RPM repositories. </span> <span> EOF exit </span><span>1</span> <span>fi</span><span> # </span>-v or --<span>version </span><span>if</span> [ <span>"</span><span>$1</span><span>"</span> = <span>"</span><span>-v</span><span>"</span> -o <span>"</span><span>$1</span><span>"</span> = <span>"</span><span>--version</span><span>"</span> ]; <span>then</span> <span>echo</span> <span>"</span><span>`basename $0` version 1.0.1</span><span>"</span><span> usage exit </span><span>0</span> <span>fi</span><span> # </span>-h or --<span>help </span><span>if</span> [ <span>"</span><span>$1</span><span>"</span> = <span>"</span><span>-h</span><span>"</span> -o <span>"</span><span>$1</span><span>"</span> = <span>"</span><span>--help</span><span>"</span> ]; <span>then</span><span> usage exit </span><span>0</span> <span>fi</span><span> MYUID</span>=`<span>id</span> -u <span>2</span>> /dev/<span>null</span><span>` </span><span>if</span> [ ! -z <span>"</span><span>$MYUID</span><span>"</span> ]; <span>then</span> <span>if</span> [ $MYUID != <span>0</span> ]; <span>then</span> <span>echo</span> <span>"</span><span>You need root privileges to run this script.</span><span>"</span><span>; #exit </span><span>2</span> <span>fi</span> <span>else</span> <span>echo</span> <span>"</span><span>Could not detect UID</span><span>"</span><span>; exit </span><span>2</span> <span>fi</span> <span>cat</span> EOF Hit ENTER to <span>install</span> web develop, or Ctrl+<span>C to abort now. EOF # give read a parameter, as it required </span><span>in</span><span> dash read answer #Base </span><span>function</span><span> InstallBasePackage() { </span><span>echo</span> <span>echo</span> <span>"</span><span>************************************************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Start install Base package( vim git wget base for mysql php nginx ). *</span><span>"</span> <span>echo</span> <span>"</span><span>************************************************************************</span><span>"</span><span> #clean iptables # </span><span>echo</span> -e <span>"</span><span>\e[0;36;1mfirst will clean iptables,please wait.\e[0m</span><span>"</span><span> # iptables </span>-<span>F # iptables </span>-<span>X # iptables </span>-<span>Z </span><span>if</span> [[ ${cBase} == <span>"</span><span>ok</span><span>"</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;35;1myour base is ok,now will not install base package.\e[0m</span><span>"</span> <span>else</span><span> #it will download from network . </span><span>echo</span> -e <span>"</span><span>\e[0;33;1mnow will test your network if worked,please wait some time.\e[0m</span><span>"</span> <span>ping</span> -c <span>5</span><span> ${cTestDomain} </span><span>if</span> [[ $? -ne <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1myour network not worked,please check it.\e[0m</span><span>"</span><span> exit </span><span>1</span> <span>else</span> <span>echo</span> -e <span>"</span><span>\e[0;35;1myour network is worked,now will download from your network.\e[0m</span><span>"</span> <span>fi</span> <span>fi</span> <span>if</span> [[ ${cBase} == <span>"</span><span>no</span><span>"</span> ]] ; <span>then</span><span> #vim # </span><span>yum</span> -y <span>install</span><span> vim </span><span>yum</span> -y <span>install</span><span> ctags </span><span>yum</span> -y <span>install</span><span> cscope </span><span>yum</span> -y <span>install</span><span> ntp #git </span><span>yum</span> -y <span>install</span><span> git #</span><span>wget</span> <span>yum</span> -y <span>install</span> <span>wget</span><span> #</span><span>gcc</span> <span>yum</span> -y <span>install</span> <span>yum</span>-<span>fastestmirror </span><span>yum</span> -y <span>install</span> <span>gcc</span> <span>gcc</span>-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel <span>bzip2</span> <span>bzip2</span>-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-<span>servers #Nginx </span><span>yum</span> -y <span>install</span> pcre-devel zlib-devel readline-<span>devel #Php </span><span>yum</span> -y <span>install</span> gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-<span>devel #Mysql </span><span>yum</span> -y <span>install</span> bison <span>gcc</span> <span>gcc</span>-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*<span> #bc </span><span>yum</span> -y <span>install</span><span> bc </span><span>fi</span><span> #synchronous </span><span>time</span><span> chkconfig ntpd on ntpdate cn.pool.ntp.org hwclock </span>--<span>systohc #config ulimit configs </span><span>echo</span><span> now will config limit allow handles. </span><span>echo</span> <span>"</span><span>* soft nofile 2048</span><span>"</span> >> /etc/security/<span>limits.conf </span><span>echo</span> <span>"</span><span>* hard nofile 32768</span><span>"</span> >> /etc/security/<span>limits.conf </span><span>echo</span> <span>"</span><span>config limits is ok, remember reboot your server.</span><span>"</span> <span>if</span> [[ $? -ne <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall base is failed.\e[0m</span><span>"</span><span> exit </span><span>1</span> <span>fi</span> <span>echo</span> <span>echo</span> <span>"</span><span>**************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Install base package is completed. *</span><span>"</span> <span>echo</span> <span>"</span><span>**************************************</span><span>"</span><span> } #Mysql </span><span>function</span><span> InstallMysql() { </span><span>echo</span> <span>echo</span> <span>"</span><span>**********************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Start install mysql( Percona-Server-5.6 ). *</span><span>"</span> <span>echo</span> <span>"</span><span>**********************************************</span><span>"</span><span> local cMysqlPackage</span>=<span>"</span><span>Percona-Server-5.6.10-alpha60.2.tar.gz</span><span>"</span><span> local cMysqlPackageDir</span>=<span>"</span><span>Percona-Server-5.6.10-alpha60.2</span><span>"</span> <span>if</span> [[ ${cBase} == <span>"</span><span>no</span><span>"</span> ]] ; <span>then</span> <span>yum</span> -y <span>install</span> <span>make</span> <span>yum</span> -y <span>install</span><span> cmake </span><span>yum</span> -y <span>install</span> libtermcap-<span>devel </span><span>yum</span> -y <span>install</span> <span>patch</span> <span>yum</span> -y <span>install</span> <span>perl</span> <span>yum</span> -y <span>install</span><span> bison </span><span>fi</span> <span>if</span> [[ ${cDownload} == <span>"</span><span>off</span><span>"</span> ]] ; <span>then</span><span> cd ${cInstallFile} </span><span>fi</span> <span>if</span> [ -x ./<span>${cMysqlPackageDir} ] </span><span>then</span><span> #</span><span>rm</span> -fr Percona-Server-<span>5.1</span>.<span>62</span> <span>echo</span> <span>"</span><span>Percona is exists,use it.</span><span>"</span> <span>else</span> <span>if</span> [ -f ./<span>${cMysqlPackage} ] </span><span>then</span> <span>tar</span> -<span>zxvf ${cMysqlPackage} </span><span>else</span> <span>wget</span> -c http:<span>//</span><span>www.percona.com/redir/downloads/Percona-Server-5.6/Percona-Server-5.6.10-alpha60.2/source/Percona-Server-5.6.10-alpha60.2.tar.gz</span> <span>if</span> [[ $? -ne <span>0</span> ]] ; <span>then</span> <span>echo</span> <span>"</span><span>download mysql is failed,please check your network.</span><span>"</span><span> exit </span><span>1</span> <span>fi</span> <span>sleep</span> <span>3</span> <span>tar</span> -<span>zxvf ${cMysqlPackage} </span><span>fi</span> <span>fi</span> <span>echo</span> <span>"</span><span>start install mysql</span><span>"</span> <span>sleep</span> <span>3</span><span> #delete mysql </span><span>install</span><span> directory cd ${cMysqlPackageDir} </span><span>if</span> [[ <span>""</span> != `<span>ps</span> -A | <span>grep</span> mysqld` ]]; <span>then</span><span> PRINTWARNING </span><span>"</span><span>mysql is install and run now will uninstall it, or Ctrl+C to abort now.</span><span>"</span><span> read answer service mysql stop # </span><span>make</span><span> clean # </span><span>make</span><span> uninstall </span><span>rm</span> -<span>rf ${cMysqlInstallPath} </span><span>fi</span><span> CC</span>=<span>gcc</span> CFLAGS=<span>"</span><span>-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -O3</span><span>"</span> CXX=g++ CXXFLAGS=<span>"</span><span>-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -felide-constructors -fno-rtti -O3</span><span>"</span><span> cmake </span>-DCMAKE_INSTALL_PREFIX=/usr/local/<span>mysql \ </span>-DMYSQL_UNIX_ADDR=/tmp/<span>mysql.sock \ </span>-DDEFAULT_CHARSET=<span>utf8 \ </span>-DDEFAULT_COLLATION=<span>utf8_general_ci \ </span>-DWITH_EXTRA_CHARSETS=<span>all \ </span>-DWITH_MYISAM_STORAGE_ENGINE=<span>1</span><span> \ </span>-DWITH_INNOBASE_STORAGE_ENGINE=<span>1</span><span> \ </span>-DWITH_READLINE=<span>1</span><span> \ </span>-DENABLED_LOCAL_INFILE=<span>1</span><span> \ </span>-DMYSQL_DATADIR=/var/mysql/<span>data </span><span>sleep</span> <span>3</span> <span>make</span> -j4 && <span>make</span> <span>install</span><span> groupadd mysql useradd </span>-<span>g mysql mysql cd ${cMysqlInstallPath} </span>&& <span>chown</span> -R mysql . && <span>chgrp</span> -<span>R mysql . </span><span>echo</span> <span>"</span><span>make install is ok</span><span>"</span> <span>sleep</span> <span>3</span> <span>mkdir</span> -p /var/mysql/data && <span>chown</span> mysql:mysql /var/mysql/ -<span>R </span><span>if</span> [[ -f ${cMysqlConfUploadFile} ]] ; <span>then</span> <span>cp</span> ${cMysqlConfUploadFile} /etc/<span>my.cnf </span><span>else</span> <span>cp</span> ${cMysqlInstallPath}support-files/my-default.cnf /etc/<span>my.cnf #</span><span>sed</span> <span>"</span><span>s/skip-locking/external-locking/g</span><span>"</span> -i /etc/<span>my.cnf #</span><span>sed</span> <span>"</span><span>s/#innodb_/innodb_/g</span><span>"</span> -i /etc/<span>my.cnf #</span><span>sed</span> -i <span>'</span><span>32 i\default-storage-engine=InnoDB</span><span>'</span> -i /etc/<span>my.cnf </span><span>fi</span><span> ${cMysqlInstallPath}</span>/scripts/mysql_install_db --basedir=${cMysqlInstallPath}/ --user=mysql --datadir=/var/mysql/<span>data </span><span>ln</span> -s /usr/local/mysql/lib/libmysqlclient.so.<span>18</span> /usr/lib/libmysqlclient.so.<span>18</span> <span>echo</span> <span>"</span><span>install_db Initialize the database is complete</span><span>"</span> <span>sleep</span> <span>3</span> <span>echo</span> <span>"</span><span>Try to start the database</span><span>"</span> <span>cp</span> ${cMysqlInstallPath}support-files/mysql.server /etc/init.d/<span>mysql </span><span>cp</span> ${cMysqlInstallPath}/bin/mysql /usr/sbin/<span> service mysql start cd ${cMysqlInstallPath} </span>&& <span>chown</span> -R mysql . && <span>chgrp</span> -<span>R mysql . </span><span>echo</span> <span>"</span><span>Database startup is complete</span><span>"</span> <span>sleep</span> <span>3</span> <span>echo</span> <span>"</span><span>Change your password after 10 seconds</span><span>"</span> <span>sleep</span> <span>10</span><span> cd ${cMysqlInstallPath} </span>&& ./bin/mysqladmin -<span>uroot password ${cMysqlDefaultPasswd} </span><span>if</span> [[ <span>""</span> == `<span>cat</span> /etc/rc.d/rc.local | <span>grep</span> <span>"</span><span>service mysql start</span><span>"</span>` ]] ; <span>then</span> <span>echo</span> <span>"</span><span>service mysql start</span><span>"</span> >> /etc/rc.d/<span>rc.local </span><span>fi</span> <span>if</span> [[ $? -ne <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1mInstallation fails, check the above error\e[0m</span><span>"</span><span> exit </span><span>1</span> <span>else</span> <span>echo</span> -e <span>"</span><span>\e[0;34;1mCongratulations, the installation was successful.Directory:</span><span>"</span>${cMysqlInstallPath}<span>"</span><span>\e[0m</span><span>"</span> <span>fi</span> <span>echo</span> <span>echo</span> <span>"</span><span>**********************************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Install Mysql is completed.( Use Percona-Server-5.6 ). *</span><span>"</span> <span>echo</span> <span>"</span><span>**********************************************************</span><span>"</span><span> } #Nginx </span><span>function</span><span> InstallNginx() { cd ${cInstallFile} local cNginxPackage</span>=tengine-<span>2.0</span>.<span>0</span>.<span>tar</span><span>.gz local cNginxPackageDir</span>=tengine-<span>2.0</span>.<span>0</span> <span>echo</span> <span>echo</span> <span>"</span><span>***************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Start install Nginx( Use tengine ). *</span><span>"</span> <span>echo</span> <span>"</span><span>***************************************</span><span>"</span> <span>#if</span> [[ "" != `ps -A | grep nginx` ]]; then<span> # PRINTWARNING </span><span>"</span><span>mysql is install and run now will uninstall it, or Ctrl+C to abort now.</span><span>"</span><span> # service nginx stop # </span><span>make</span><span> uninstall # </span><span>rm</span> -<span>rf ${cInstallNginxPath} # </span><span>fi</span><span> groupadd www useradd </span>-<span>g www www </span><span>if</span> [[ ${cDownload} == <span>"</span><span>on</span><span>"</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;33;1mnow download package form website,check your network if failed!\e[0m</span><span>"</span><span> #Nginx </span><span>1.3</span>.<span>0</span> <span>if</span> [[ -f ${cInstallFile}${cNginxPackage} ]] ; <span>then</span> <span>echo</span><span> ${cNginxPackage} is found. </span><span>else</span> <span>echo</span><span> now will download ${cNginxPackage} from network. </span><span>wget</span> -c http:<span>//</span><span>tengine.taobao.org/download/${cNginxPackage}</span> <span>fi</span><span> #openssl </span><span>if</span> [[ -f ${cInstallFile}openssl-<span>1.0</span>.1c.<span>tar</span>.gz ]] ; <span>then</span> <span>echo</span> openssl-<span>1.0</span>.1c.<span>tar</span><span>.gz is found. </span><span>else</span> <span>echo</span> now will download openssl-<span>1.0</span>.1c.<span>tar</span><span>.gz from network. </span><span>wget</span> -c http:<span>//</span><span>www.openssl.org/source/openssl-1.0.1c.tar.gz</span> <span>fi</span><span> #Nginx(pcre) # </span><span>if</span> [[ -f ${cInstallFile}pcre-<span>8.30</span>.<span>tar</span>.gz ]] ; <span>then</span><span> # </span><span>echo</span> pcre-<span>8.30</span>.<span>tar</span><span>.gz is found. # </span><span>else</span><span> # </span><span>echo</span> now will download pcre-<span>8.30</span>.<span>tar</span><span>.gz from network. # </span><span>wget</span> http:<span>//</span><span>nchc.dl.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.tar.gz</span> # <span>fi</span><span> bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1mdownload package is failed,Please check your network.\e[0m</span><span>"</span><span> exit </span><span>fi</span> <span>fi</span><span> #</span><span>install</span><span> pcre # </span><span>tar</span> -zxvf pcre-<span>8.30</span>.<span>tar</span>.gz && cd pcre-<span>8.30</span>/ && ./<span>configure # </span><span>make</span> -s -j4 && <span>make</span> <span>install</span><span> # cd ..</span>/<span> #</span><span>install</span><span> openssl </span><span>if</span> [[ -d openssl-<span>1.0</span>.1c ]] ; <span>then</span><span> PRINTUSEDIR openssl</span>-<span>1.0</span><span>.1c </span><span>else</span> <span>tar</span> zxvf openssl-<span>1.0</span>.1c.<span>tar</span>.gz #&& cd openssl-<span>1.0</span><span>.1c </span><span>fi</span><span> # .</span>/config --prefix=/usr/local/ --openssldir=/usr/local/openssl-<span>1.0</span>.1c shared zlib-dynamic enable-camellia enable-tlsext -<span>fPIC # </span><span>make</span> && <span>make</span> <span>install</span> && cd ../<span> #</span><span>install</span><span> nginx </span><span>if</span> [[ -d ${cNginxPackageDir} ]] ; <span>then</span><span> PRINTUSEDIR ${cNginxPackageDir} </span><span>else</span> <span>tar</span> -<span>xzvf ${cNginxPackage} </span><span>fi</span><span> cd ${cInstallFile}${cNginxPackageDir} </span><span>make</span><span> clean .</span>/configure --user=${cWebUser} --group=<span>${cWebUser} \ </span>--prefix=<span>${cInstallNginxPath} \ </span>--sbin-path=${cInstallNginxPath}sbin/<span>nginx \ </span>--conf-path=${cInstallNginxPath}conf/<span>nginx.conf \ </span>--with-<span>http_stub_status_module \ </span>--lock-path=/var/run/<span>nginx.lock \ </span>--pid-path=/var/run/<span>nginx.pid \ </span>--with-openssl=../openssl-<span>1.0</span><span>.1c \ </span>--with-pcre-<span>jit </span><span>sleep</span> <span>10</span> <span>make</span> && <span>make</span> <span>install</span><span> bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall nginx have some error,you can read it.\e[0m</span><span>"</span><span> exit </span><span>else</span> <span>echo</span> -e <span>"</span><span>\e[0;34;1mgood luck! install nginx sucess! \e[0m</span><span>"</span> <span>fi</span> <span>#if</span> install nginx is sucess,then will config it.<span> # </span><span>echo</span> <span>"</span><span>Now will config the nginx,please wait.</span><span>"</span> <span>if</span> [[ -f ${cNginxConfFile} ]] ; <span>then</span> <span>cp</span> -n ${cNginxConfFile} ${cInstallNginxPath}conf/<span>nginx.conf </span><span>else</span> <span>sed</span> -e <span>"</span><span>2 c\user ${cWebUser};</span><span>"</span> -i ${cInstallNginxPath}conf/<span>nginx.conf </span><span>fi</span><span> #start nginx and set start on boot </span><span>echo</span> ${cInstallNginxPath}sbin/nginx >> /etc/rc.d/<span>rc.local ${cInstallNginxPath}sbin</span>/<span>nginx #open port </span><span>3306</span> and <span>80</span><span> iptables </span>-I INPUT -p tcp --dport <span>80</span> -<span>j ACCEPT iptables </span>-I OUTPUT -p tcp --sport <span>80</span> -<span>j ACCEPT iptables </span>-I INPUT -p tcp --dport <span>3306</span> -<span>j ACCEPT iptables </span>-I OUTPUT -p tcp --sport <span>3306</span> -<span>j ACCEPT </span>/etc/rc.d/init.d/<span>iptables save service iptables restart </span><span>echo</span> <span>echo</span> <span>"</span><span>***********************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Install Nginx is completed.( Use tengine ). *</span><span>"</span> <span>echo</span> <span>"</span><span>***********************************************</span><span>"</span><span> } #PHP </span><span>function</span><span> InstallPHP() { cd ${cInstallFile} </span><span>echo</span> <span>echo</span> <span>"</span><span>**********************************************</span><span>"</span> <span>echo</span> <span>"</span><span>* Start install PHP.( Default version 5.3 ). *</span><span>"</span> <span>echo</span> <span>"</span><span>**********************************************</span><span>"</span><span> local cPhpVersion</span>=${<span>2</span><span>} local cPhpPackage</span>=<span>""</span><span> local cPhpPackageDir</span>=<span>""</span> <span>if</span> [[ -z ${cPhpVersion} ]]; <span>then</span> <span>echo</span> <span>install</span> default php version <span>5.3</span><span> cPhpVersion</span>=<span>"</span><span>5.3</span><span>"</span><span> cPhpPackage</span>=<span>"</span><span>php-5.3.28.tar.bz2</span><span>"</span><span> cPhpPackageDir</span>=<span>"</span><span>php-5.3.28</span><span>"</span> <span>else</span> <span>if</span> [[ <span>"</span><span>5.3</span><span>"</span> != ${cPhpVersion} && <span>"</span><span>5.4</span><span>"</span> != ${cPhpVersion} ]]; <span>then</span><span> Useage exit </span><span>1</span> <span>else</span> <span>if</span> [[ <span>"</span><span>5.3</span><span>"</span> == ${cPhpVersion} ]]; <span>then</span><span> cPhpPackage</span>=<span>"</span><span>php-5.3.28.tar.bz2</span><span>"</span><span> cPhpPackageDir</span>=<span>"</span><span>php-5.3.28</span><span>"</span> <span>else</span><span> cPhpPackage</span>=<span>"</span><span>php-5.4.15.tar.bz2</span><span>"</span><span> cPhpPackageDir</span>=<span>"</span><span>php-5.4.15</span><span>"</span> <span>fi</span> <span>fi</span> <span>fi</span> <span>if</span> [[ ${cDownload} == <span>"</span><span>on</span><span>"</span> ]] ; <span>then</span> <span>echo</span> now download package form website,check your network <span>if</span> failed!<span> #PHP5.</span><span>3.14</span> <span>if</span> [[ -f ${cInstallFile}${cPhpPackage} ]] ; <span>then</span> <span>echo</span><span> ${cPhpPackage} is found. </span><span>else</span> <span>echo</span><span> now will download php package from network. </span><span>wget</span> -c http:<span>//</span><span>cn.php.net/distributions/${cPhpPackage}</span> <span>fi</span><span> #PHP </span><span>if</span> [[ -f ${cInstallFile}mcrypt-<span>2.6</span>.<span>8</span>.<span>tar</span>.gz ]] ; <span>then</span> <span>echo</span> mcrypt-<span>2.6</span>.<span>8</span>.<span>tar</span><span>.gz is found. </span><span>else</span> <span>echo</span> now will download mcrypt-<span>2.6</span>.<span>8</span>.<span>tar</span><span>.gz from network. </span><span>wget</span> http:<span>//</span><span>ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz</span> <span>fi</span> <span>if</span> [[ -f ${cInstallFile}mhash-<span>0.9</span>.<span>9.9</span>.<span>tar</span>.gz ]] ; <span>then</span> <span>echo</span> mhash-<span>0.9</span>.<span>9.9</span>.<span>tar</span><span>.gz is found. </span><span>else</span> <span>echo</span> now will download mhash-<span>0.9</span>.<span>9.9</span>.<span>tar</span><span>.gz from network. </span><span>wget</span> http:<span>//</span><span>ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz</span> <span>fi</span> <span>if</span> [[ -f ${cInstallFile}libmcrypt-<span>2.5</span>.<span>8</span>.<span>tar</span>.gz ]] ; <span>then</span> <span>echo</span> libmcrypt-<span>2.5</span>.<span>8</span>.<span>tar</span><span>.gz is found. </span><span>else</span> <span>echo</span> now will download libmcrypt-<span>2.5</span>.<span>8</span>.<span>tar</span><span>.gz from network. </span><span>wget</span> http:<span>//</span><span>ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz</span> <span>fi</span> <span>if</span> [[ -f ${cInstallFile}libiconv-<span>1.14</span>.<span>tar</span>.gz ]] ; <span>then</span> <span>echo</span> libiconv-<span>1.14</span>.<span>tar</span><span>.gz is found. </span><span>else</span> <span>echo</span> now will download libiconv-<span>1.14</span>.<span>tar</span><span>.gz from network. </span><span>wget</span> http:<span>//</span><span>ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz</span> <span>fi</span> <span>if</span> [[ -f ${cInstallFile}memcache-<span>3.0</span>.<span>6</span>.tgz ]] ; <span>then</span> <span>echo</span> memcache-<span>3.0</span>.<span>6</span><span>.tgz is found. </span><span>else</span> <span>echo</span> now will download memcache-<span>3.0</span>.<span>6</span><span>.tgz from network. </span><span>wget</span> http:<span>//</span><span>pecl.php.net/get/memcache-3.0.6.tgz</span> <span>fi</span> <span>if</span> [[ -f ${cInstallFile}PDO_MYSQL-<span>1.0</span>.<span>2</span>.tgz ]] ; <span>then</span> <span>echo</span> PDO_MYSQL-<span>1.0</span>.<span>2</span><span>.tgz is found. </span><span>else</span> <span>echo</span> now will download PDO_MYSQL-<span>1.0</span>.<span>2</span><span>.tgz from network. </span><span>wget</span> http:<span>//</span><span>pecl.php.net/get/PDO_MYSQL-1.0.2.tgz</span> <span>fi</span><span> bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1mdownload package failed,you can check your network if can work.\e[0m</span><span>"</span><span> exit </span><span>fi</span> <span>fi</span> <span>echo</span> <span>"</span><span>install some plugin for php</span><span>"</span><span> #</span><span>1</span> <span>if</span> [[ -d libiconv-<span>1.14</span>/ ]] ; <span>then</span><span> PRINTUSEDIR libiconv</span>-<span>1.14</span>/ <span>else</span> <span>tar</span> -zxvf libiconv-<span>1.14</span>.<span>tar</span>.gz && cd libiconv-<span>1.14</span>/ <span>fi</span><span> .</span>/configure --prefix=/usr/<span>local </span><span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ <span>sleep</span> <span>1</span><span> #</span><span>2</span> <span>if</span> [[ -d libmcrypt-<span>2.5</span>.<span>8</span>/ ]] ; <span>then</span><span> PRINTUSEDIR libmcrypt</span>-<span>2.5</span>.<span>8</span>/ <span>else</span> <span>tar</span> -zxvf libmcrypt-<span>2.5</span>.<span>8</span>.<span>tar</span>.gz && cd libmcrypt-<span>2.5</span>.<span>8</span>/ <span>fi</span><span> .</span>/configure && <span>make</span> && <span>make</span> <span>install</span> /sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-<span>install</span> <span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ && cd ../ <span>sleep</span> <span>2</span><span> #</span><span>3</span> <span>if</span> [[ -d mhash-<span>0.9</span>.<span>9.9</span>/ ]] ; <span>then</span><span> PRINTUSEDIR mhash</span>-<span>0.9</span>.<span>9.9</span>/ <span>else</span> <span>tar</span> -zxvf mhash-<span>0.9</span>.<span>9.9</span>.<span>tar</span>.gz && cd mhash-<span>0.9</span>.<span>9.9</span>/ <span>fi</span><span> .</span>/<span>configure </span><span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ <span>sleep</span> <span>3</span><span> #</span><span>4</span> <span>ln</span> -s /usr/local/lib/libmcrypt.la /usr/lib/<span>libmcrypt.la </span><span>ln</span> -s /usr/local/lib/libmcrypt.so /usr/lib/<span>libmcrypt.so </span><span>ln</span> -s /usr/local/lib/libmcrypt.so.<span>4</span> /usr/lib/libmcrypt.so.<span>4</span> <span>ln</span> -s /usr/local/lib/libmcrypt.so.<span>4.4</span>.<span>8</span> /usr/lib/libmcrypt.so.<span>4.4</span>.<span>8</span> <span>ln</span> -s /usr/local/lib/libmhash.a /usr/lib/<span>libmhash.a </span><span>ln</span> -s /usr/local/lib/libmhash.la /usr/lib/<span>libmhash.la </span><span>ln</span> -s /usr/local/lib/libmhash.so /usr/lib/<span>libmhash.so </span><span>ln</span> -s /usr/local/lib/libmhash.so.<span>2</span> /usr/lib/libmhash.so.<span>2</span> <span>ln</span> -s /usr/local/lib/libmhash.so.<span>2.0</span>.<span>1</span> /usr/lib/libmhash.so.<span>2.0</span>.<span>1</span> <span>ln</span> -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-<span>config </span><span>sleep</span> <span>1</span><span> #</span><span>5</span> /sbin/<span>ldconfig </span><span>if</span> [[ -d mcrypt-<span>2.6</span>.<span>8</span>/ ]] ; <span>then</span><span> PRINTUSEDIR mcrypt</span>-<span>2.6</span>.<span>8</span>/ <span>else</span> <span>tar</span> -zxvf mcrypt-<span>2.6</span>.<span>8</span>.<span>tar</span>.gz && cd mcrypt-<span>2.6</span>.<span>8</span>/ <span>fi</span><span> .</span>/<span>configure </span><span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ <span>sleep</span> <span>2</span><span> bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall package false,please read the errors.\e[0m</span><span>"</span><span> exit </span><span>fi</span> <span>echo</span> <span>install</span> plugin <span>for</span><span> php is completed. </span><span>echo</span> now will <span>install</span><span> php, version is ${cPhpVersion} #</span><span>64</span> OR <span>32</span><span> SYSTEM LIB MUST BE DIFFERENT </span><span>if</span> [[ ${iSystemType} == <span>64</span> ]] ; <span>then</span> <span>cp</span> -frp /usr/lib64/libldap* /usr/<span>lib </span><span>fi</span><span> #</span><span>6</span><span> cd ${cInstallFile} </span><span>if</span> [[ -d ${cPhpPackageDir} ]] ; <span>then</span><span> PRINTUSEDIR ${cPhpPackageDir} </span><span>else</span> <span>tar</span> -<span>xjvf ${cPhpPackage} cd ${cPhpPackageDir} </span><span>fi</span><span> .</span>/configure --prefix=<span>${cInstallPhpPath} \ </span>--with-config-<span>file</span>-path=<span>${cInstallPhpPath}etc \ </span>--with-iconv-<span>dir</span>=/usr/local/ --with-freetype-<span>dir</span><span> \ </span>--with-mysql=<span>${cInstallMysqlPath} \ </span>--with-mysqli=${cInstallMysqlPath}bin/<span>mysql_config \ </span>--with-jpeg-<span>dir</span> --with-png-<span>dir</span> --with-<span>zlib \ </span>--with-mhash --enable-sockets --enable-<span>ftp</span><span> \ </span>--with-libxml-<span>dir</span> --enable-xml --disable-<span>rpath \ </span>--enable-safe-mode --enable-<span>bcmath \ </span>--enable-shmop --enable-<span>sysvsem \ </span>--enable-inline-optimization --with-<span>curl \ </span>--with-<span>curlwrappers \ </span>--enable-<span>mbregex \ </span>--enable-mbstring --with-mcrypt --with-<span>gd \ </span>--enable-gd-native-ttf --with-openssl --with-<span>mhash \ </span>--enable-pcntl --enable-sockets --with-ldap --with-ldap-<span>sasl \ </span>--enable-<span>fpm \ </span>--with-xmlrpc --enable-<span>zip</span> --enable-<span>soap \ </span>--without-<span>pear; </span><span>make</span> -s -j4 ZEND_EXTRA_LIBS=<span>'</span><span>-liconv</span><span>'</span> <span>make</span> <span>install</span> <span>cp</span> php.ini-production ${cInstallPhpPath}etc/<span>php.ini </span><span>ln</span> -s ${cInstallPhpPath}bin/php /usr/sbin/<span>php #now we can config php.ini </span><span>sed</span> <span>"</span><span>538 c\display_errors = ${cDisplay_Errors}</span><span>"</span> -i ${cInstallPhpPath}etc/<span>php.ini </span><span>sed</span> <span>"</span><span>521 c\error_reporting = ${cError_Reporting}</span><span>"</span> -i ${cInstallPhpPath}etc/<span>php.ini </span><span>sed</span> <span>"</span><span>334 c\allow_call_time_pass_reference = ${cAllow_Call_Time_Pass_Reference}</span><span>"</span> -i ${cInstallPhpPath}etc/<span>php.ini </span><span>sed</span> <span>"</span><span>1008 c\date.timezone = ${cDate_TimeZone}</span><span>"</span> -i ${cInstallPhpPath}etc/<span>php.ini bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall PHP failed,you can read the errors or send email to me.\e[0m</span><span>"</span><span> exit </span><span>fi</span> <span>echo</span> -------------------------------end-----------------------------------<span> cd ${cInstallFile} </span><span>echo</span> <span>"</span><span>######################install Extensions for PHP#################</span><span>"</span> <span>echo</span> -------------------------------start--------------------------------- <span>if</span> [[ -d memcache-<span>3.0</span>.<span>6</span>/ ]] ; <span>then</span><span> PRINTUSEDIR memcache</span>-<span>3.0</span>.<span>6</span>/ <span>else</span> <span>tar</span> -zxvf memcache-<span>3.0</span>.<span>6</span><span>.tgz cd memcache</span>-<span>3.0</span>.<span>6</span>/ <span>fi</span><span> ${cInstallPhpPath}bin</span>/<span>phpize .</span>/configure --with-php-config=${cInstallPhpPath}bin/php-<span>config </span><span>sleep</span> <span>1</span> <span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ <span>if</span> [[ -d PDO_MYSQL-<span>1.0</span>.<span>2</span>/ ]] ; <span>then</span><span> PRINTUSEDIR PDO_MYSQL</span>-<span>1.0</span>.<span>2</span>/ <span>else</span> <span>tar</span> -zxvf PDO_MYSQL-<span>1.0</span>.<span>2</span><span>.tgz cd PDO_MYSQL</span>-<span>1.0</span>.<span>2</span>/ <span>fi</span><span> ${cInstallPhpPath}bin</span>/<span>phpize .</span>/configure --with-php-config=${cInstallPhpPath}bin/php-config --with-pdo-mysql=<span>${cInstallMysqlPath} </span><span>make</span> -s -j4 && <span>make</span> <span>install</span> && cd ../ <span>echo</span> <span>"</span><span>[PDO_MYSQL]</span><span>"</span> >> ${cInstallPhpPath}etc/<span>php.ini </span><span>echo</span> <span>"</span><span>extension=pdo_mysql.so</span><span>"</span> >> ${cInstallPhpPath}etc/<span>php.ini </span><span>if</span> [[ $? -ne <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall extensions for php is failed.\e[0m</span><span>"</span><span> exit </span><span>1</span> <span>fi</span> <span>sleep</span> <span>5</span><span> #PHP</span>-<span>FPM </span>/usr/sbin/groupadd ${cWebUser} && /usr/sbin/useradd -<span>g ${cWebUser} ${cWebUser} </span><span>mkdir</span> -p /var/log/nginx && <span>chmod</span> +<span>w</span> /var/log/nginx &&<span>chown</span> -R ${cWebUser}:${cWebUser} /var/log/<span>nginx </span><span>mkdir</span> -p /data/${cWebUser} && <span>chmod</span> +<span>w</span> /data/${cWebUser} && <span>chown</span> -R ${cWebUser}:${cWebUser} /data/<span>${cWebUser} </span><span>cp</span> -n ${cInstallPhpPath}etc/php-fpm.conf.default ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>if</span> [[ -f ${cPhpFpmConfFile} ]] ; <span>then</span> <span>cp</span> -n ${cPhpFpmConfFile} ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>else</span> <span>sed</span> <span>"</span><span>s/;pid = /pid = /g</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/;error_log = /error_log = /g</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/pm.max_children = .*/pm.max_children = ${pm_max_children}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/pm.start_servers = .*/pm.start_servers = ${pm_start_servers}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/pm.min_spare_servers =.*/pm.min_spare_servers = ${pm_min_spare_servers}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/pm.max_spare_servers =.*/pm.max_spare_servers = ${pm_max_spare_servers}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/pm.max_requests =.*/pm.max_spare_servers = ${pm_max_requests}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/user =.*/user = ${pm_user}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>sed</span> <span>"</span><span>s/group =.*/group = ${pm_group}/</span><span>"</span> -i ${cInstallPhpPath}etc/php-<span>fpm.conf </span><span>fi</span><span> #start php</span>-<span>fpm and set start on boot </span><span>cp</span> ${cInstallFile}${cPhpPackageDir}/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-<span>fpm </span><span>chmod</span> +x /etc/rc.d/init.d/php-<span>fpm </span><span>echo</span> service php-fpm start >> /etc/rc.d/<span>rc.local service php</span>-<span>fpm start bExit</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ ${bExit} != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1minstall Extensions for PHP failed! \e[0m</span><span>"</span><span> exit </span><span>1</span> <span>else</span> <span>echo</span> -e <span>"</span><span>\e[0;34;1mgood luck! you install Extensions for PHP is secess! \e[0m</span><span>"</span> <span>fi</span><span> } #download tips </span><span>function</span><span> DownloadTip() { </span><span>if</span> [[ ${cDownload} == <span>"</span><span>on</span><span>"</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;35;1mDownload is on,the package will download from website.Please check your network is worked.\e[0m</span><span>"</span> <span>else</span> <span>echo</span> -e <span>"</span><span>\e[0;30;1mDownload is off,make sure your package is Existing.\e[0m</span><span>"</span> <span>#if</span> download if off,now can download from our svn. <span>fi</span> <span>if</span> [[ -f ${cOtherOfflinePackageFile} ]] ; <span>then</span> <span>tar</span> -xzvf ${cOtherOfflinePackageFile} -<span>C ${cInstallFile} </span><span>fi</span><span> } #this </span><span>function</span> can use insert <span>string</span> above <span>last</span><span> line #this have two parameters,one is </span><span>string</span> another is <span>file</span><span> path. #</span><span>string</span> ervery line must be division by <span>'</span><span>|</span><span>'</span> <span>function</span><span> InsertStrAboveLastLine() { oldIFS</span>=<span>$IFS IFS</span>=<span>"</span><span>|</span><span>"</span> <span>for</span> item <span>in</span> $<span>1</span> <span>do</span><span> iInsertLine</span>=`<span>awk</span> <span>'</span><span>END{print NR}</span><span>'</span> $<span>2</span><span>` cNewItem</span>=`<span>echo</span> ${item} | <span>sed</span> <span>'</span><span>/^$/d</span><span>'</span><span>` </span><span>if</span> [[ ${cNewItem} != <span>""</span> ]] ; <span>then</span><span> #</span><span>echo</span> this is <span>null</span> <span>#else</span><span> #</span><span>echo</span><span> item:${cNewItem} </span><span>sed</span> -e <span>"</span><span>${iInsertLine} i\ ${cNewItem}</span><span>"</span> -i $<span>2</span> <span>fi</span><span> #iInsertLine</span>=`<span>awk</span> <span>'</span><span>END{print NR}</span><span>'</span><span> ${cTestFile}` #</span><span>sed</span> -e <span>"</span><span>${iInsertLine} i\ ${item}</span><span>"</span> -<span>i ${cTestFile} </span><span>done</span><span> IFS</span>=<span>$oldIFS } #@desc: set iptable rules #@param: void #@return: void </span><span>function</span><span> SetIptables() { Arr_OpenPortList</span>=<span>"</span><span>${1}</span><span>"</span> <span>echo</span><span> now will config iptables, open port list is: PrintArrList </span><span>"</span><span>${Arr_OpenPortList}</span><span>"</span> <span>for</span> port <span>in</span><span> ${Arr_OpenPortList} </span><span>do</span><span> iptables </span>-I INPUT -i eth0 -p tcp --dport ${port} -<span>j ACCEPT iptables </span>-I OUTPUT -o eth0 -p tcp --sport ${port} -<span>j ACCEPT </span><span>done</span> /etc/init.d/<span>iptables save service iptables restart } #@desc: print array list #@param: array #@return void </span><span>function</span><span> PrintArrList() { Arr_List</span>=<span>"</span><span>${1}</span><span>"</span> <span>for</span> item <span>in</span><span> ${Arr_List} </span><span>do</span> <span>echo</span> -e <span>"</span><span>\e[0;33;1m${item}\e[0m</span><span>"</span> <span>done</span><span> } #@desc:print use </span><span>dir</span><span> str #@param: </span><span>string</span> <span>dirname</span><span> #@return: void </span><span>function</span><span> PRINTUSEDIR() { cDirName</span>=$<span>1</span> <span>echo</span> ${cDirName} is found, use it and <span>make</span><span> uninstall. cd ${cDirName} </span>&& <span>make</span><span> uninstall } #@desc print red error and exit #@param </span><span>string</span><span> $cErrorStr #@return void </span><span>function</span><span> PRINTERR() { cErrorStr</span>=${<span>1</span><span>} </span><span>echo</span> -e <span>"</span><span>\e[0;31;1mERROR:${cErrorStr}\e[0m</span><span>"</span><span> exit </span><span>1</span><span> } #@desc print yellow warning and not exit #@param </span><span>string</span><span> $cWarningStr #@return void </span><span>function</span><span> PRINTWARNING() { cWarningStr</span>=${<span>1</span><span>} </span><span>echo</span> -e <span>"</span><span>\e[0;33;1mWARNING:${cWarningStr}\e[0m</span><span>"</span><span> } #create </span><span>install</span> <span>file</span> <span>if</span> [[ $cCommand != -base ]] ; <span>then</span><span> `</span><span>mkdir</span> -<span>p ${cInstallFile}` bInstallFile</span>=`<span>echo</span> $?<span>` </span><span>if</span> [[ $bInstallFile != <span>0</span> ]] ; <span>then</span> <span>echo</span> -e <span>"</span><span>\e[0;31;1mmake ${cInstallFile} file is failed! \e[0m</span><span>"</span><span> exit </span><span>else</span><span> cd ${cInstallFile} </span><span>fi</span> <span>fi</span><span> ###################main################## </span><span>if</span> [[ $cCommand == <span>"</span><span>-base</span><span>"</span> ]] ; <span>then</span><span> DownloadTip # </span><span>if</span> [[ ${cDownload} == <span>"</span><span>off</span><span>"</span> ]] ; <span>then</span><span> # </span><span>echo</span><span> Download is off,please modify it. # exit # </span><span>else</span><span> InstallBasePackage #</span><span>fi</span> <span>elif</span> [[ $cCommand == <span>"</span><span>-m</span><span>"</span> || <span>"</span><span>--mysql</span><span>"</span> == ${cCommand} ]] ; <span>then</span><span> DownloadTip InstallMysql </span><span>elif</span> [[ $cCommand == <span>"</span><span>-n</span><span>"</span> || <span>"</span><span>--nginx</span><span>"</span> == ${cCommand} ]] ; <span>then</span><span> DownloadTip InstallNginx </span><span>elif</span> [[ $cCommand == <span>"</span><span>-p</span><span>"</span> || <span>"</span><span>--php</span><span>"</span> == ${cCommand} ]] ; <span>then</span><span> DownloadTip InstallPHP </span><span>elif</span> [[ $cCommand == <span>"</span><span>--test</span><span>"</span> ]] ; <span>then</span><span> InsertStrAboveLastLine </span><span>"</span><span>|1|2|3|4|5|</span><span>"</span> /home/<span>test.txt </span><span>else</span><span> DownloadTip InstallBasePackage </span><span>sleep</span> <span>3</span><span> InstallMysql </span><span>sleep</span> <span>3</span><span> InstallPHP </span><span>sleep</span> <span>3</span><span> InstallNginx </span><span>sleep</span> <span>3</span><span> SetIptables </span><span>"</span><span>${Arr_OpenPortList}</span><span>"</span><span> exit </span><span>0</span> <span>fi</span></params>
使用官方提供的基础骨架进行安装,十分便利,我想有许多的朋友还不知道吧。
cd ~/<span>work #进入到你的工作目录,这里只是一个例子 git clone https:</span><span>//</span><span>github.com/viticm/ZendSkeletonApplication</span> <span> cd ZendSkeletonApplication php composer.phar self</span>-<span>update php composer.phar </span><span>install</span><span> # 正式开始安装zf2,网速慢的请耐心等待 </span><span>mkdir</span> /data/www/zf2/ && <span>cp</span> ../ZendSkeletonApplication<span>/*</span><span> /data/www/zf2/ -r # 把当前目录拷贝到网站目录下</span>
php composer.phar self-update #运行截图
php composer.phar install #运行截图,如果你无法访问外网的话,该文章对你的帮助就不太大了
如果你用我的脚本安装,则配置文件为/usr/local/nginx/conf/nginx.conf
<span> server { listen </span>80<span>; server_name zf2.local.com; </span><span>#</span><span>域名</span> root /data/www/zf2/public; <span>#</span><span>你的网站目录</span> <span> index index.php; </span><span>#</span><span>charset utf-8;</span> location ~* \.(js|ico|gif|jpg|png|css|jpeg|<span>swf)$ { access_log off; expires 2d; } location </span>/<span> { </span><span>if</span> (!-<span>f $request_filename) { rewrite </span>^(.+)$ /index.php?$1&<span> last; } } location </span>~<span> \.php$ { </span><span>#</span><span>root /var/www/html/public;</span> fastcgi_pass 127.0.0.1:9000; <span>#</span><span>如果你的php-fpm的监听端口不是这个,请设置</span> <span> fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } </span><span>#</span><span> deny access to .htaccess files, if Apache’s document root</span> <span>#</span><span> concurs with nginx’s one</span> <span># </span> location ~ /<span>\.ht { deny all; } }</span>
到此zend framework 2的开发环境就彻底搭建完成了。
将域名和你的IP绑定,或更改host添加192.168.200.132 zf2.local.com到你的配置中。