在五花八门的语言里,PHP作为我第一个觉得欣赏的理由,就是它的简单和快捷,因为它封装了许多的常用函数。PHP作为网站中一种算作比较流行的语言,也产生各种优秀的框架。我所接触过的有zend framework 1、think php、yii框架,这些框架中属zend framework似乎不太尽人意,因为作为官方的框架,大家给予的期望也是比较高的,但是在国内这个框架用的并不多。可是我作为一个还算比较忠实的PHP爱好者,我还是用zend framework 1搭建了第一个属于自己的网站——仿动网论坛。不说曾经了,zend framework 2似乎是去年出来的吧,我也捣鼓过一段时间,因为后来工作的关系,我逐渐很少去研究这个了。现在国内的这方面资料还非常稀缺,虽然有人已经翻译了官方的文档,但是我想对于初学者来说还是很难上手。特别是搭建开发环境的,我就更少看见了,要么是笼统的概括,要么就是凌乱的东拼西凑。本文供给那些想要了解新框架的人,也同时为自己做一个笔记,因为这些东西随着时间的推移是会渐渐淡忘的。

首先看看市面上流行的有哪些框架,统计可能对国内来说有些偏差。

1、第一步,安装你的web开发环境

你可以去找一些集成lnmp的脚本,或者使用我提供的这个脚本进行基础的环境安装,下面的代码下载后保存为install_web_develop.sh,怎么运行请百度shell脚本运行。

  1. #!/bin/bash
  2. #filename:test.sh
  3. #author:viticm
  4. #createtime:-- ::
  5. #use: install web develop
  6. cUser=`whoami`
  7. cCommand=$
  8. cDownload=on
  9. cBase=no
  10. cWebUser=www
  11. cInstallFile=/web/
  12. cInstallPhpPath=/usr/local/php/
  13. cInstallNginxPath=/usr/local/nginx/
  14. cInstallMysqlPath=/usr/local/mysql/
  15. cPhpMakefile=/home/Makefile
  16. iSystemType=`getconf LONG_BIT`
  17. Arr_OpenPortList=""
  18. cTestDomain=www.baidu.com
  19.  
  20. ##### mysql config #####
  21. cMysqlDefaultPasswd=mysql
  22. cMysqlInstallPath=/usr/local/mysql/
  23. cMysqlConfUploadFile=`pwd`/my.cnf
  24. ##### mysql config #####
  25.  
  26. ####### PHP #######
  27. cDate_TimeZone="Asia/Shanghai"
  28. cDisplay_Errors=On
  29. cError_Reporting="E_ALL & ~E_NOTICE"
  30. cAllow_Call_Time_Pass_Reference=On
  31. ###### PHP ########
  32.  
  33. #### PHP-FPM CONFIGS ####
  34. pm_max_children=
  35. pm_start_servers=
  36. pm_min_spare_servers=
  37. pm_max_spare_servers=
  38. pm_max_requests=
  39. pm_user=${cWebUser}
  40. pm_group=${cWebUser}
  41. #### PHP-FPM CONFIGS ####
  42.  
  43. usage()
  44. {
  45. cat <<EOF
  46.  
  47. Usage: $ <params>
  48. -m or --mysql install mysql
  49. -n or --nginx install nginx
  50. -p or --php install php( and this can enter two params,like -p 5.3( 5.4 ) then install php what version is 5.3 )
  51.  
  52. EOF
  53. return
  54. }
  55.  
  56. # on OEL, /etc/issue states "Enterprise Linux Enterprise Linux Server"
  57. SUPPORTED_OS='CentOS|Red Hat Enterprise Linux Server|Enterprise Linux Enterprise Linux Server|Fedora|SUSE|Debian GNU/Linux|Ubuntu|Oracle Linux Server'
  58.  
  59. if ! egrep -q "$SUPPORTED_OS" /etc/issue ; then
  60. cat <<EOF
  61.  
  62. Unable to install: Your distribution is not suitable for installation using
  63. Zend's DEB/RPM repositories.
  64.  
  65. EOF
  66. exit
  67. fi
  68.  
  69. # -v or --version
  70. if [ "$1" = "-v" -o "$1" = "--version" ]; then
  71. echo "`basename $0` version 1.0.1"
  72. usage
  73. exit
  74. fi
  75.  
  76. # -h or --help
  77. if [ "$1" = "-h" -o "$1" = "--help" ]; then
  78. usage
  79. exit
  80. fi
  81.  
  82. MYUID=`id -u > /dev/null`
  83. if [ ! -z "$MYUID" ]; then
  84. if [ $MYUID != ]; then
  85. echo "You need root privileges to run this script.";
  86. #exit
  87. fi
  88. else
  89. echo "Could not detect UID";
  90. exit
  91. fi
  92.  
  93. cat <<EOF
  94. Hit ENTER to install web develop, or Ctrl+C to abort now.
  95. EOF
  96. # give read a parameter, as it required in dash
  97. read answer
  98.  
  99. #Base
  100. function InstallBasePackage()
  101. {
  102. echo
  103. echo "************************************************************************"
  104. echo "* Start install Base package( vim git wget base for mysql php nginx ). *"
  105. echo "************************************************************************"
  106. #clean iptables
  107. # echo -e "\e[0;36;1mfirst will clean iptables,please wait.\e[0m"
  108. # iptables -F
  109. # iptables -X
  110. # iptables -Z
  111. if [[ ${cBase} == "ok" ]] ; then
  112. echo -e "\e[0;35;1myour base is ok,now will not install base package.\e[0m"
  113. else
  114. #it will download from network .
  115. echo -e "\e[0;33;1mnow will test your network if worked,please wait some time.\e[0m"
  116. ping -c ${cTestDomain}
  117. if [[ $? -ne ]] ; then
  118. echo -e "\e[0;31;1myour network not worked,please check it.\e[0m"
  119. exit
  120. else
  121. echo -e "\e[0;35;1myour network is worked,now will download from your network.\e[0m"
  122. fi
  123. fi
  124. if [[ ${cBase} == "no" ]] ; then
  125. #vim
  126. # yum -y install vim
  127. yum -y install ctags
  128. yum -y install cscope
  129. yum -y install ntp
  130. #git
  131. yum -y install git
  132. #wget
  133. yum -y install wget
  134. #gcc
  135. yum -y install yum-fastestmirror
  136. yum -y install 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 bzip2 bzip2-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-servers
  137. #Nginx
  138. yum -y install pcre-devel zlib-devel readline-devel
  139. #Php
  140. yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
  141. #Mysql
  142. yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*
  143. #bc
  144. yum -y install bc
  145. fi
  146.  
  147. #synchronous time
  148. chkconfig ntpd on
  149. ntpdate cn.pool.ntp.org
  150. hwclock --systohc
  151. #config ulimit configs
  152. echo now will config limit allow handles.
  153. echo "* soft nofile 2048" >> /etc/security/limits.conf
  154. echo "* hard nofile 32768" >> /etc/security/limits.conf
  155. echo "config limits is ok, remember reboot your server."
  156. if [[ $? -ne ]] ; then
  157. echo -e "\e[0;31;1minstall base is failed.\e[0m"
  158. exit
  159. fi
  160. echo
  161. echo "**************************************"
  162. echo "* Install base package is completed. *"
  163. echo "**************************************"
  164.  
  165. }
  166. #Mysql
  167. function InstallMysql()
  168. {
  169. echo
  170. echo "**********************************************"
  171. echo "* Start install mysql( Percona-Server-5.6 ). *"
  172. echo "**********************************************"
  173. local cMysqlPackage="Percona-Server-5.6.10-alpha60.2.tar.gz"
  174. local cMysqlPackageDir="Percona-Server-5.6.10-alpha60.2"
  175. if [[ ${cBase} == "no" ]] ; then
  176. yum -y install make
  177. yum -y install cmake
  178. yum -y install libtermcap-devel
  179. yum -y install patch
  180. yum -y install perl
  181. yum -y install bison
  182. fi
  183.  
  184. if [[ ${cDownload} == "off" ]] ; then
  185. cd ${cInstallFile}
  186. fi
  187. if [ -x ./${cMysqlPackageDir} ]
  188. then
  189. #rm -fr Percona-Server-5.1.
  190. echo "Percona is exists,use it."
  191. else
  192. if [ -f ./${cMysqlPackage} ]
  193. then
  194. tar -zxvf ${cMysqlPackage}
  195. else
  196. wget -c http://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
  197. if [[ $? -ne ]] ; then
  198. echo "download mysql is failed,please check your network."
  199. exit
  200. fi
  201. sleep
  202. tar -zxvf ${cMysqlPackage}
  203. fi
  204. fi
  205. echo "start install mysql"
  206. sleep
  207. #delete mysql install directory
  208. cd ${cMysqlPackageDir}
  209. if [[ "" != `ps -A | grep mysqld` ]]; then
  210. PRINTWARNING "mysql is install and run now will uninstall it, or Ctrl+C to abort now."
  211. read answer
  212. service mysql stop
  213. # make clean
  214. # make uninstall
  215. rm -rf ${cMysqlInstallPath}
  216. fi
  217.  
  218. CC=gcc CFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -O3" CXX=g++ CXXFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -felide-constructors -fno-rtti -O3"
  219. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  220. -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
  221. -DDEFAULT_CHARSET=utf8 \
  222. -DDEFAULT_COLLATION=utf8_general_ci \
  223. -DWITH_EXTRA_CHARSETS=all \
  224. -DWITH_MYISAM_STORAGE_ENGINE= \
  225. -DWITH_INNOBASE_STORAGE_ENGINE= \
  226. -DWITH_READLINE= \
  227. -DENABLED_LOCAL_INFILE= \
  228. -DMYSQL_DATADIR=/var/mysql/data
  229. sleep
  230. make -j4 && make install
  231.  
  232. groupadd mysql
  233. useradd -g mysql mysql
  234. cd ${cMysqlInstallPath} && chown -R mysql . && chgrp -R mysql .
  235. echo "make install is ok"
  236.  
  237. sleep
  238. mkdir -p /var/mysql/data && chown mysql:mysql /var/mysql/ -R
  239. if [[ -f ${cMysqlConfUploadFile} ]] ; then
  240. cp ${cMysqlConfUploadFile} /etc/my.cnf
  241. else
  242. cp ${cMysqlInstallPath}support-files/my-default.cnf /etc/my.cnf
  243. #sed "s/skip-locking/external-locking/g" -i /etc/my.cnf
  244. #sed "s/#innodb_/innodb_/g" -i /etc/my.cnf
  245. #sed -i '32 i\default-storage-engine=InnoDB' -i /etc/my.cnf
  246. fi
  247. ${cMysqlInstallPath}/scripts/mysql_install_db --basedir=${cMysqlInstallPath}/ --user=mysql --datadir=/var/mysql/data
  248. ln -s /usr/local/mysql/lib/libmysqlclient.so. /usr/lib/libmysqlclient.so.
  249. echo "install_db Initialize the database is complete"
  250. sleep
  251. echo "Try to start the database"
  252. cp ${cMysqlInstallPath}support-files/mysql.server /etc/init.d/mysql
  253. cp ${cMysqlInstallPath}/bin/mysql /usr/sbin/
  254. service mysql start
  255. cd ${cMysqlInstallPath} && chown -R mysql . && chgrp -R mysql .
  256. echo "Database startup is complete"
  257. sleep
  258.  
  259. echo "Change your password after 10 seconds"
  260. sleep
  261. cd ${cMysqlInstallPath} && ./bin/mysqladmin -uroot password ${cMysqlDefaultPasswd}
  262. if [[ "" == `cat /etc/rc.d/rc.local | grep "service mysql start"` ]] ; then
  263. echo "service mysql start" >> /etc/rc.d/rc.local
  264. fi
  265. if [[ $? -ne ]] ; then
  266. echo -e "\e[0;31;1mInstallation fails, check the above error\e[0m"
  267. exit
  268. else
  269. echo -e "\e[0;34;1mCongratulations, the installation was successful.Directory:"${cMysqlInstallPath}"\e[0m"
  270. fi
  271. echo
  272. echo "**********************************************************"
  273. echo "* Install Mysql is completed.( Use Percona-Server-5.6 ). *"
  274. echo "**********************************************************"
  275.  
  276. }
  277.  
  278. #Nginx
  279. function InstallNginx()
  280. {
  281. cd ${cInstallFile}
  282. local cNginxPackage=tengine-2.0..tar.gz
  283. local cNginxPackageDir=tengine-2.0.
  284. echo
  285. echo "***************************************"
  286. echo "* Start install Nginx( Use tengine ). *"
  287. echo "***************************************"
  288. #if [[ "" != `ps -A | grep nginx` ]]; then
  289. # PRINTWARNING "mysql is install and run now will uninstall it, or Ctrl+C to abort now."
  290. # service nginx stop
  291. # make uninstall
  292. # rm -rf ${cInstallNginxPath}
  293. # fi
  294.  
  295. groupadd www
  296. useradd -g www www
  297. if [[ ${cDownload} == "on" ]] ; then
  298. echo -e "\e[0;33;1mnow download package form website,check your network if failed!\e[0m"
  299. #Nginx 1.3.
  300. if [[ -f ${cInstallFile}${cNginxPackage} ]] ; then
  301. echo ${cNginxPackage} is found.
  302. else
  303. echo now will download ${cNginxPackage} from network.
  304. wget -c http://tengine.taobao.org/download/${cNginxPackage}
  305. fi
  306. #openssl
  307. if [[ -f ${cInstallFile}openssl-1.0.1c.tar.gz ]] ; then
  308. echo openssl-1.0.1c.tar.gz is found.
  309. else
  310. echo now will download openssl-1.0.1c.tar.gz from network.
  311. wget -c http://www.openssl.org/source/openssl-1.0.1c.tar.gz
  312. fi
  313. #Nginx(pcre)
  314. # if [[ -f ${cInstallFile}pcre-8.30.tar.gz ]] ; then
  315. # echo pcre-8.30.tar.gz is found.
  316. # else
  317. # echo now will download pcre-8.30.tar.gz from network.
  318. # wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.tar.gz
  319. # fi
  320. bExit=`echo $?`
  321. if [[ ${bExit} != ]] ; then
  322. echo -e "\e[0;31;1mdownload package is failed,Please check your network.\e[0m"
  323. exit
  324. fi
  325. fi
  326. #install pcre
  327. # tar -zxvf pcre-8.30.tar.gz && cd pcre-8.30/ && ./configure
  328. # make -s -j4 && make install
  329. # cd ../
  330. #install openssl
  331. if [[ -d openssl-1.0.1c ]] ; then
  332. PRINTUSEDIR openssl-1.0.1c
  333. else
  334. tar zxvf openssl-1.0.1c.tar.gz #&& cd openssl-1.0.1c
  335. fi
  336.  
  337. # ./config --prefix=/usr/local/ --openssldir=/usr/local/openssl-1.0.1c shared zlib-dynamic enable-camellia enable-tlsext -fPIC
  338. # make && make install && cd ../
  339. #install nginx
  340. if [[ -d ${cNginxPackageDir} ]] ; then
  341. PRINTUSEDIR ${cNginxPackageDir}
  342. else
  343. tar -xzvf ${cNginxPackage}
  344. fi
  345. cd ${cInstallFile}${cNginxPackageDir}
  346. make clean
  347. ./configure --user=${cWebUser} --group=${cWebUser} \
  348. --prefix=${cInstallNginxPath} \
  349. --sbin-path=${cInstallNginxPath}sbin/nginx \
  350. --conf-path=${cInstallNginxPath}conf/nginx.conf \
  351. --with-http_stub_status_module \
  352. --lock-path=/var/run/nginx.lock \
  353. --pid-path=/var/run/nginx.pid \
  354. --with-openssl=../openssl-1.0.1c \
  355. --with-pcre-jit
  356. sleep
  357. make && make install
  358. bExit=`echo $?`
  359. if [[ ${bExit} != ]] ; then
  360. echo -e "\e[0;31;1minstall nginx have some error,you can read it.\e[0m"
  361. exit
  362. else
  363. echo -e "\e[0;34;1mgood luck! install nginx sucess! \e[0m"
  364. fi
  365. #if install nginx is sucess,then will config it.
  366. # echo "Now will config the nginx,please wait."
  367.  
  368. if [[ -f ${cNginxConfFile} ]] ; then
  369. cp -n ${cNginxConfFile} ${cInstallNginxPath}conf/nginx.conf
  370. else
  371. sed -e "2 c\user ${cWebUser};" -i ${cInstallNginxPath}conf/nginx.conf
  372. fi
  373. #start nginx and set start on boot
  374. echo ${cInstallNginxPath}sbin/nginx >> /etc/rc.d/rc.local
  375. ${cInstallNginxPath}sbin/nginx
  376. #open port and
  377. iptables -I INPUT -p tcp --dport -j ACCEPT
  378. iptables -I OUTPUT -p tcp --sport -j ACCEPT
  379. iptables -I INPUT -p tcp --dport -j ACCEPT
  380. iptables -I OUTPUT -p tcp --sport -j ACCEPT
  381. /etc/rc.d/init.d/iptables save
  382. service iptables restart
  383. echo
  384. echo "***********************************************"
  385. echo "* Install Nginx is completed.( Use tengine ). *"
  386. echo "***********************************************"
  387.  
  388. }
  389.  
  390. #PHP
  391. function InstallPHP()
  392. {
  393. cd ${cInstallFile}
  394. echo
  395. echo "**********************************************"
  396. echo "* Start install PHP.( Default version 5.3 ). *"
  397. echo "**********************************************"
  398.  
  399. local cPhpVersion=${}
  400. local cPhpPackage=""
  401. local cPhpPackageDir=""
  402. if [[ -z ${cPhpVersion} ]]; then
  403. echo install default php version 5.3
  404. cPhpVersion="5.3"
  405. cPhpPackage="php-5.3.28.tar.bz2"
  406. cPhpPackageDir="php-5.3.28"
  407. else
  408. if [[ "5.3" != ${cPhpVersion} && "5.4" != ${cPhpVersion} ]]; then
  409. Useage
  410. exit
  411. else
  412. if [[ "5.3" == ${cPhpVersion} ]]; then
  413. cPhpPackage="php-5.3.28.tar.bz2"
  414. cPhpPackageDir="php-5.3.28"
  415. else
  416. cPhpPackage="php-5.4.15.tar.bz2"
  417. cPhpPackageDir="php-5.4.15"
  418. fi
  419. fi
  420. fi
  421.  
  422. if [[ ${cDownload} == "on" ]] ; then
  423. echo now download package form website,check your network if failed!
  424. #PHP5.3.14
  425. if [[ -f ${cInstallFile}${cPhpPackage} ]] ; then
  426. echo ${cPhpPackage} is found.
  427. else
  428. echo now will download php package from network.
  429. wget -c http://cn.php.net/distributions/${cPhpPackage}
  430. fi
  431. #PHP
  432. if [[ -f ${cInstallFile}mcrypt-2.6..tar.gz ]] ; then
  433. echo mcrypt-2.6..tar.gz is found.
  434. else
  435. echo now will download mcrypt-2.6..tar.gz from network.
  436. wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
  437. fi
  438.  
  439. if [[ -f ${cInstallFile}mhash-0.9.9.9.tar.gz ]] ; then
  440. echo mhash-0.9.9.9.tar.gz is found.
  441. else
  442. echo now will download mhash-0.9.9.9.tar.gz from network.
  443. wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
  444. fi
  445.  
  446. if [[ -f ${cInstallFile}libmcrypt-2.5..tar.gz ]] ; then
  447. echo libmcrypt-2.5..tar.gz is found.
  448. else
  449. echo now will download libmcrypt-2.5..tar.gz from network.
  450. wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
  451. fi
  452.  
  453. if [[ -f ${cInstallFile}libiconv-1.14.tar.gz ]] ; then
  454. echo libiconv-1.14.tar.gz is found.
  455. else
  456. echo now will download libiconv-1.14.tar.gz from network.
  457. wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
  458. fi
  459.  
  460. if [[ -f ${cInstallFile}memcache-3.0..tgz ]] ; then
  461. echo memcache-3.0..tgz is found.
  462. else
  463. echo now will download memcache-3.0..tgz from network.
  464. wget http://pecl.php.net/get/memcache-3.0.6.tgz
  465. fi
  466.  
  467. if [[ -f ${cInstallFile}PDO_MYSQL-1.0..tgz ]] ; then
  468. echo PDO_MYSQL-1.0..tgz is found.
  469. else
  470. echo now will download PDO_MYSQL-1.0..tgz from network.
  471. wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
  472. fi
  473. bExit=`echo $?`
  474. if [[ ${bExit} != ]] ; then
  475. echo -e "\e[0;31;1mdownload package failed,you can check your network if can work.\e[0m"
  476. exit
  477. fi
  478. fi
  479. echo "install some plugin for php"
  480. #
  481. if [[ -d libiconv-1.14/ ]] ; then
  482. PRINTUSEDIR libiconv-1.14/
  483. else
  484. tar -zxvf libiconv-1.14.tar.gz && cd libiconv-1.14/
  485. fi
  486. ./configure --prefix=/usr/local
  487. make -s -j4 && make install && cd ../
  488. sleep
  489. #
  490. if [[ -d libmcrypt-2.5./ ]] ; then
  491. PRINTUSEDIR libmcrypt-2.5./
  492. else
  493. tar -zxvf libmcrypt-2.5..tar.gz && cd libmcrypt-2.5./
  494. fi
  495. ./configure && make && make install
  496. /sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install
  497. make -s -j4 && make install && cd ../ && cd ../
  498. sleep
  499. #
  500. if [[ -d mhash-0.9.9.9/ ]] ; then
  501. PRINTUSEDIR mhash-0.9.9.9/
  502. else
  503. tar -zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/
  504. fi
  505. ./configure
  506. make -s -j4 && make install && cd ../
  507. sleep
  508. #
  509. ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
  510. ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
  511. ln -s /usr/local/lib/libmcrypt.so. /usr/lib/libmcrypt.so.
  512. ln -s /usr/local/lib/libmcrypt.so.4.4. /usr/lib/libmcrypt.so.4.4.
  513. ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
  514. ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
  515. ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
  516. ln -s /usr/local/lib/libmhash.so. /usr/lib/libmhash.so.
  517. ln -s /usr/local/lib/libmhash.so.2.0. /usr/lib/libmhash.so.2.0.
  518. ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
  519. sleep
  520. #
  521. /sbin/ldconfig
  522. if [[ -d mcrypt-2.6./ ]] ; then
  523. PRINTUSEDIR mcrypt-2.6./
  524. else
  525. tar -zxvf mcrypt-2.6..tar.gz && cd mcrypt-2.6./
  526. fi
  527. ./configure
  528. make -s -j4 && make install && cd ../
  529. sleep
  530. bExit=`echo $?`
  531. if [[ ${bExit} != ]] ; then
  532. echo -e "\e[0;31;1minstall package false,please read the errors.\e[0m"
  533. exit
  534. fi
  535. echo install plugin for php is completed.
  536. echo now will install php, version is ${cPhpVersion}
  537. # OR SYSTEM LIB MUST BE DIFFERENT
  538. if [[ ${iSystemType} == ]] ; then
  539. cp -frp /usr/lib64/libldap* /usr/lib
  540. fi
  541. #
  542. cd ${cInstallFile}
  543. if [[ -d ${cPhpPackageDir} ]] ; then
  544. PRINTUSEDIR ${cPhpPackageDir}
  545. else
  546. tar -xjvf ${cPhpPackage}
  547. cd ${cPhpPackageDir}
  548. fi
  549. ./configure --prefix=${cInstallPhpPath} \
  550. --with-config-file-path=${cInstallPhpPath}etc \
  551. --with-iconv-dir=/usr/local/ --with-freetype-dir \
  552. --with-mysql=${cInstallMysqlPath} \
  553. --with-mysqli=${cInstallMysqlPath}bin/mysql_config \
  554. --with-jpeg-dir --with-png-dir --with-zlib \
  555. --with-mhash --enable-sockets --enable-ftp \
  556. --with-libxml-dir --enable-xml --disable-rpath \
  557. --enable-safe-mode --enable-bcmath \
  558. --enable-shmop --enable-sysvsem \
  559. --enable-inline-optimization --with-curl \
  560. --with-curlwrappers \
  561. --enable-mbregex \
  562. --enable-mbstring --with-mcrypt --with-gd \
  563. --enable-gd-native-ttf --with-openssl --with-mhash \
  564. --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl \
  565. --enable-fpm \
  566. --with-xmlrpc --enable-zip --enable-soap \
  567. --without-pear;
  568. make -s -j4 ZEND_EXTRA_LIBS='-liconv'
  569. make install
  570. cp php.ini-production ${cInstallPhpPath}etc/php.ini
  571. ln -s ${cInstallPhpPath}bin/php /usr/sbin/php
  572. #now we can config php.ini
  573. sed "538 c\display_errors = ${cDisplay_Errors}" -i ${cInstallPhpPath}etc/php.ini
  574. sed "521 c\error_reporting = ${cError_Reporting}" -i ${cInstallPhpPath}etc/php.ini
  575. sed "334 c\allow_call_time_pass_reference = ${cAllow_Call_Time_Pass_Reference}" -i ${cInstallPhpPath}etc/php.ini
  576. sed "1008 c\date.timezone = ${cDate_TimeZone}" -i ${cInstallPhpPath}etc/php.ini
  577. bExit=`echo $?`
  578. if [[ ${bExit} != ]] ; then
  579. echo -e "\e[0;31;1minstall PHP failed,you can read the errors or send email to me.\e[0m"
  580. exit
  581. fi
  582. echo -------------------------------end-----------------------------------
  583. cd ${cInstallFile}
  584. echo "######################install Extensions for PHP#################"
  585. echo -------------------------------start---------------------------------
  586. if [[ -d memcache-3.0./ ]] ; then
  587. PRINTUSEDIR memcache-3.0./
  588. else
  589. tar -zxvf memcache-3.0..tgz
  590. cd memcache-3.0./
  591. fi
  592. ${cInstallPhpPath}bin/phpize
  593. ./configure --with-php-config=${cInstallPhpPath}bin/php-config
  594. sleep
  595. make -s -j4 && make install && cd ../
  596. if [[ -d PDO_MYSQL-1.0./ ]] ; then
  597. PRINTUSEDIR PDO_MYSQL-1.0./
  598. else
  599. tar -zxvf PDO_MYSQL-1.0..tgz
  600. cd PDO_MYSQL-1.0./
  601. fi
  602. ${cInstallPhpPath}bin/phpize
  603. ./configure --with-php-config=${cInstallPhpPath}bin/php-config --with-pdo-mysql=${cInstallMysqlPath}
  604. make -s -j4 && make install && cd ../
  605. echo "[PDO_MYSQL]" >> ${cInstallPhpPath}etc/php.ini
  606. echo "extension=pdo_mysql.so" >> ${cInstallPhpPath}etc/php.ini
  607. if [[ $? -ne ]] ; then
  608. echo -e "\e[0;31;1minstall extensions for php is failed.\e[0m"
  609. exit
  610. fi
  611. sleep
  612. #PHP-FPM
  613. /usr/sbin/groupadd ${cWebUser} && /usr/sbin/useradd -g ${cWebUser} ${cWebUser}
  614. mkdir -p /var/log/nginx && chmod +w /var/log/nginx &&chown -R ${cWebUser}:${cWebUser} /var/log/nginx
  615. mkdir -p /data/${cWebUser} && chmod +w /data/${cWebUser} && chown -R ${cWebUser}:${cWebUser} /data/${cWebUser}
  616. cp -n ${cInstallPhpPath}etc/php-fpm.conf.default ${cInstallPhpPath}etc/php-fpm.conf
  617. if [[ -f ${cPhpFpmConfFile} ]] ; then
  618. cp -n ${cPhpFpmConfFile} ${cInstallPhpPath}etc/php-fpm.conf
  619. else
  620. sed "s/;pid = /pid = /g" -i ${cInstallPhpPath}etc/php-fpm.conf
  621. sed "s/;error_log = /error_log = /g" -i ${cInstallPhpPath}etc/php-fpm.conf
  622. sed "s/pm.max_children = .*/pm.max_children = ${pm_max_children}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  623. sed "s/pm.start_servers = .*/pm.start_servers = ${pm_start_servers}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  624. sed "s/pm.min_spare_servers =.*/pm.min_spare_servers = ${pm_min_spare_servers}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  625. sed "s/pm.max_spare_servers =.*/pm.max_spare_servers = ${pm_max_spare_servers}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  626. sed "s/pm.max_requests =.*/pm.max_spare_servers = ${pm_max_requests}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  627. sed "s/user =.*/user = ${pm_user}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  628. sed "s/group =.*/group = ${pm_group}/" -i ${cInstallPhpPath}etc/php-fpm.conf
  629. fi
  630. #start php-fpm and set start on boot
  631. cp ${cInstallFile}${cPhpPackageDir}/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
  632. chmod +x /etc/rc.d/init.d/php-fpm
  633. echo service php-fpm start >> /etc/rc.d/rc.local
  634. service php-fpm start
  635. bExit=`echo $?`
  636. if [[ ${bExit} != ]] ; then
  637. echo -e "\e[0;31;1minstall Extensions for PHP failed! \e[0m"
  638. exit
  639. else
  640. echo -e "\e[0;34;1mgood luck! you install Extensions for PHP is secess! \e[0m"
  641. fi
  642. }
  643.  
  644. #download tips
  645. function DownloadTip()
  646. {
  647. if [[ ${cDownload} == "on" ]] ; then
  648. echo -e "\e[0;35;1mDownload is on,the package will download from website.Please check your network is worked.\e[0m"
  649. else
  650. echo -e "\e[0;30;1mDownload is off,make sure your package is Existing.\e[0m"
  651. #if download if off,now can download from our svn.
  652. fi
  653.  
  654. if [[ -f ${cOtherOfflinePackageFile} ]] ; then
  655. tar -xzvf ${cOtherOfflinePackageFile} -C ${cInstallFile}
  656. fi
  657. }
  658. #this function can use insert string above last line
  659. #this have two parameters,one is string another is file path.
  660. #string ervery line must be division by '|'
  661. function InsertStrAboveLastLine()
  662. {
  663. oldIFS=$IFS
  664. IFS="|"
  665. for item in $
  666. do
  667. iInsertLine=`awk 'END{print NR}' $`
  668. cNewItem=`echo ${item} | sed '/^$/d'`
  669. if [[ ${cNewItem} != "" ]] ; then
  670. #echo this is null
  671. #else
  672. #echo item:${cNewItem}
  673. sed -e "${iInsertLine} i\ ${cNewItem}" -i $
  674. fi
  675. #iInsertLine=`awk 'END{print NR}' ${cTestFile}`
  676. #sed -e "${iInsertLine} i\ ${item}" -i ${cTestFile}
  677. done
  678. IFS=$oldIFS
  679. }
  680. #@desc: set iptable rules
  681. #@param: void
  682. #@return: void
  683. function SetIptables()
  684. {
  685. Arr_OpenPortList="${1}"
  686. echo now will config iptables, open port list is:
  687. PrintArrList "${Arr_OpenPortList}"
  688. for port in ${Arr_OpenPortList}
  689. do
  690. iptables -I INPUT -i eth0 -p tcp --dport ${port} -j ACCEPT
  691. iptables -I OUTPUT -o eth0 -p tcp --sport ${port} -j ACCEPT
  692. done
  693. /etc/init.d/iptables save
  694. service iptables restart
  695. }
  696. #@desc: print array list
  697. #@param: array
  698. #@return void
  699. function PrintArrList()
  700. {
  701. Arr_List="${1}"
  702. for item in ${Arr_List}
  703. do
  704. echo -e "\e[0;33;1m${item}\e[0m"
  705. done
  706. }
  707.  
  708. #@desc:print use dir str
  709. #@param: string dirname
  710. #@return: void
  711. function PRINTUSEDIR()
  712. {
  713. cDirName=$
  714. echo ${cDirName} is found, use it and make uninstall.
  715. cd ${cDirName} && make uninstall
  716. }
  717. #@desc print red error and exit
  718. #@param string $cErrorStr
  719. #@return void
  720. function PRINTERR()
  721. {
  722. cErrorStr=${}
  723. echo -e "\e[0;31;1mERROR:${cErrorStr}\e[0m"
  724. exit
  725. }
  726.  
  727. #@desc print yellow warning and not exit
  728. #@param string $cWarningStr
  729. #@return void
  730. function PRINTWARNING()
  731. {
  732. cWarningStr=${}
  733. echo -e "\e[0;33;1mWARNING:${cWarningStr}\e[0m"
  734. }
  735. #create install file
  736. if [[ $cCommand != -base ]] ; then
  737.  
  738. `mkdir -p ${cInstallFile}`
  739. bInstallFile=`echo $?`
  740. if [[ $bInstallFile != ]] ; then
  741. echo -e "\e[0;31;1mmake ${cInstallFile} file is failed! \e[0m"
  742. exit
  743. else
  744. cd ${cInstallFile}
  745. fi
  746. fi
  747.  
  748. ###################main##################
  749. if [[ $cCommand == "-base" ]] ; then
  750. DownloadTip
  751. # if [[ ${cDownload} == "off" ]] ; then
  752. # echo Download is off,please modify it.
  753. # exit
  754. # else
  755. InstallBasePackage
  756. #fi
  757. elif [[ $cCommand == "-m" || "--mysql" == ${cCommand} ]] ; then
  758. DownloadTip
  759. InstallMysql
  760. elif [[ $cCommand == "-n" || "--nginx" == ${cCommand} ]] ; then
  761. DownloadTip
  762. InstallNginx
  763. elif [[ $cCommand == "-p" || "--php" == ${cCommand} ]] ; then
  764. DownloadTip
  765. InstallPHP
  766. elif [[ $cCommand == "--test" ]] ; then
  767. InsertStrAboveLastLine "|1|2|3|4|5|" /home/test.txt
  768. else
  769. DownloadTip
  770. InstallBasePackage
  771. sleep
  772. InstallMysql
  773. sleep
  774. InstallPHP
  775. sleep
  776. InstallNginx
  777. sleep
  778. SetIptables "${Arr_OpenPortList}"
  779. exit
  780. fi

install_web_develop.sh

2、安装官方基本框架

使用官方提供的基础骨架进行安装,十分便利,我想有许多的朋友还不知道吧。

  1. cd ~/work #进入到你的工作目录,这里只是一个例子
  2. git clone https://github.com/viticm/ZendSkeletonApplication
  3. cd ZendSkeletonApplication
  4. php composer.phar self-update
  5. php composer.phar install # 正式开始安装zf2,网速慢的请耐心等待
  6. mkdir /data/www/zf2/ && cp ../ZendSkeletonApplication/* /data/www/zf2/ -r # 把当前目录拷贝到网站目录下

php composer.phar self-update #运行截图

php composer.phar install #运行截图,如果你无法访问外网的话,该文章对你的帮助就不太大了

3、配置你的nginx.conf

如果你用我的脚本安装,则配置文件为/usr/local/nginx/conf/nginx.conf

  1. server {
  2. listen 80;
  3. server_name zf2.local.com; #域名
  4. root /data/www/zf2/public; #你的网站目录
  5. index index.php;
  6. #charset utf-8;
  7. location ~* \.(js|ico|gif|jpg|png|css|jpeg|swf)$ {
  8. access_log off;
  9. expires 2d;
  10. }
  11.  
  12. location / {
  13. if (!-f $request_filename) {
  14. rewrite ^(.+)$ /index.php?$1& last;
  15. }
  16. }
  17.  
  18. location ~ \.php$ {
  19. #root /var/www/html/public;
  20. fastcgi_pass 127.0.0.1:9000; #如果你的php-fpm的监听端口不是这个,请设置
  21. fastcgi_index index.php;
  22. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  23. include fastcgi_params;
  24. }
  25.  
  26. # deny access to .htaccess files, if Apache’s document root
  27. # concurs with nginx’s one
  28. #
  29. location ~ /\.ht {
  30. deny all;
  31. }
  32. }

4、开始浏览你的网站

到此zend framework 2的开发环境就彻底搭建完成了。

将域名和你的IP绑定,或更改host添加192.168.200.132 zf2.local.com到你的配置中。

搭建PHP官方框架zend framework 2(LINUX)的更多相关文章

  1. 高性能Web框架Zend Framework

    Zend Framework (ZF)是用 PHP 5.3及更高版本来开发 Web 程序和服务的开源框架.ZF用100% 面向对象编码实现. ZF的组件结构独一无二,每个组件几乎不依靠其他组件.这样的 ...

  2. 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建、调试输出和建立时间系统

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  3. 嵌入式框架Zorb Framework搭建二:环形缓冲区的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  4. 嵌入式框架Zorb Framework搭建三:列表的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  5. 嵌入式框架Zorb Framework搭建四:状态机的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  6. 嵌入式框架Zorb Framework搭建五:事件的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  7. 嵌入式框架Zorb Framework搭建六:定时器的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  8. 嵌入式框架Zorb Framework搭建七:任务的实现

    我是卓波,我是一名嵌入式工程师,我万万没想到我会在这里跟大家吹牛皮. 嵌入式框架Zorb Framework搭建过程 嵌入式框架Zorb Framework搭建一:嵌入式环境搭建.调试输出和建立时间系 ...

  9. Zend Framework 框架搭建

    通过手工方法搭建Zend Framework的MVC框架结构.首先看一下zend framework mvc的目录结构 1. 在根目录下面创建 public ,并在 public 下创建 index. ...

随机推荐

  1. 关于clientWidth scrollWidth offsetWidth的理解

    clientWidth:元素可见区域的宽度  clientWidth=padding+width-滚动条 scrollWidth:元素实际内容的宽度 scrollWidth=padding+width ...

  2. Stickup – 轻松实现元素固定效果的 jQuery 插件

    粘贴是一个简单的 jQuery 插件,在页面滚动的时候固定一个元素到浏览器窗口的顶部,让其总是保持在视图中可见.这个插件作用于多页的网站,但是对于单页的布局有额外的功能.借助 CSS,还可以实现当前视 ...

  3. Vis.js – 基于浏览器的动态 JavaScript 可视化库

    Vis.js 是一个动态的,基于浏览器的可视化库.该库被设计为易于使用,能处理大量的动态数据.该库由以下几部分组成:一是数据集和数据视图,基于灵活的键/值数据集,可以添加,更新和删除项目,订阅数据集变 ...

  4. 使用nodejs+express+socketio+mysql搭建聊天室

    使用nodejs+express+socketio+mysql搭建聊天室 nodejs相关的资料已经很多了,我也是学习中吧,于是把socket的教程看了下,学着做了个聊天室,然后加入简单的操作mysq ...

  5. SharePoint 2013 版本号和相关问题介绍

    今天查SharePoint 补丁,无意间发现一个非常好的链接,分享给大家! 这里面有SharePoint近期的版本号,而且不断更新,还有每个补丁可能带来的问题,对于服务器经常需要打补丁的那是非常有用, ...

  6. Adobe Flash player 10 提示:Error#2044:未处理的IOErrorEvent. text=Error#2036:加载未完成 的解决方法

    在“我的电脑”上单击鼠标右键,选择管理,在管理窗口的左栏中打开“服务和应用程序”,点击“服务”,在右边窗口中双击打开名称为“Smart Card”的服务,“常规”->“启动类型”选为自动,“登录 ...

  7. git之一

    1.Git是什么Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理.Git 是 ...

  8. (视频) 《快速创建网站》3.4 网站改版3分钟搞定 - WordPress主题安装和备份

    本文是<快速创建网站>系列的第8篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 访问本系列目录,请点击:http://devopshub.cn/tag ...

  9. (视频) 开源,免费和跨平台 - MVP ComCamp 2015 KEYNOTE

    2015年1月31日,作为KEYNOTE演讲嘉宾,我和来自全国各地的开发人员分享了作为一名MVP的一些体会. Keynote – Open Source, Free Tools and Cross P ...

  10. teiid入门

    teiid,是jboss组件中进行数据虚拟化的部件(data virtualization).但是对teiid的介绍比较少,这里记录一下我的学习过程. 一.编译安装teiid teiid的安装,可以选 ...