centos 下zend framework安装手册

来源:互联网 发布:大连贵金属看盘软件 编辑:程序博客网 时间:2024/06/05 17:36

1.下载zend framework。链接自己找。

2.解压安装包。

3.cd bin;

    ./zf.sh --help

     提示PHP Fatal error:  Cannot access self:: when no class scope is active in /root/zend/library/Zend/Tool/Framework/Provider/Signature.php on line 355

    这个是因为使用的是php5.1的原因。因为centos 提供的php的安装包是5.1。而zend推荐使用php5.2。

   所以先升级到php5.2。方法如下:

[root@QA-Server ~]# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
[root@QA-Server ~]# vim /etc/yum.repos.d/utterramblings.repo
[root@QA-Server ~]# vim /etc/yum.repos.d/utterramblings.repo

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

[root@QA-Server ~]# yum update php

 

升级完成。

执行./zf.sh --help。应该没有问题了。

然后执行./zf.sh show version 也会出错,提示你没有include_path。

然后错误提示,执行相关的设置就可以了。

 

安装完成后,

 

zf.sh create project  proejct_name创建你的项目结构。

具体见zh.sh --help

然后将安装包中library->Zend 复制到你的项目中library下。

配置apache或者nginx到你的public。

注意添加rewrite规则。

然后就可以访问你的页面了

 

Create a virtual host

Within your httpd.conf (or httpd-vhosts.conf on some systems), you will need to do two things. First, ensure that the NameVirtualHost is defined; typically, you will set it to a value of "*:80". Second, define a virtual host:

  1. <VirtualHost *:80>
  2.     ServerName quickstart.local
  3.     DocumentRoot /path/to/quickstart/public
  4.  
  5.     SetEnv APPLICATION_ENV "development"
  6.  
  7.     <Directory /path/to/quickstart/public>
  8.         DirectoryIndex index.php
  9.         AllowOverride All
  10.         Order allow,deny
  11.         Allow from all
  12.     </Directory>
  13. </VirtualHost>

There are several things to note. First, note that the DocumentRoot setting specifies the public subdirectory of our project; this means that only files under that directory can ever be served directly by the server. Second, note the AllowOverride, Order, and Allow directives; these are to allow us to use htacess files within our project. During development, this is a good practice, as it prevents the need to constantly restart the web server as you make changes to your site directives; however, in production, you should likely push the content of your htaccess file into your server configuration and disable this. Third, note the SetEnv directive. What we are doing here is setting an environment variable for your virtual host; this variable will be picked up in the index.php and used to set the APPLICATION_ENV constant for our Zend Framework application. In production, you can omit this directive (in which case it will default to the value "production") or set it explicitly to "production".

 

 

在Nginx上配置ZendFramework

location / {
if (!-e $request_filename) {
rewrite . /index.php last;
break;
}
}


Apache设置环境变量是使用SetEnv APPLICATION_ENV development,在Nginx里对应的语法是:

fastcgi_param APPLICATION_ENV development;

对应的配置文件nginx/conf/fastcgi_params

 

 

 

原创粉丝点击