php中yaf框架的服務器配置


1  yaf 擴展

wget http://pecl.php.net/get/yaf-3.0.4.tgz 
   /usr/local/php/bin/phpize
    ./configure --with-php-config=/usr/local/php/bin/php-config
   make && make install
 echo "extension=yaf.so" >> /usr/local/php/etc/php.ini

2 yafconf 擴展

wget http://pecl.php.net/get/yaconf-1.0.2.tgz
 /usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config
  make && make install 
echo "extension=yaconf.so" >> /usr/local/php/etc/php.ini

3   yafconf 配置,在php.ini中 需要填寫配置文件的目錄

1
yaconf.directory = / yaconf

  關於PHP如何獲取配置參數,參看 http://blog.jobbole.com/90405/

4  nginx 虛擬服務器的配置

  nginx 對yaf 的配置中需要增加一條 url 重定向,否則yaf 的路由控制訪問的時候會報404錯誤

 

復制代碼
  server {
        listen       80;
        root   /home/wwwroot/sssm;
        index index.php index.html index.htm;
        server_name   sssm.test.zhonghuass.cn;
        include       mime.types;
        default_type  application/octet-stream;
        client_header_buffer_size 1024k;
        large_client_header_buffers 4 1024k;
        client_max_body_size 8m;
        gzip off;
    rewrite ^/admin/public/images/(.*\.(js|ico|gif|jpg|png|css|bmp|html|xls)$) /admin/public/images/$1 last;

# 注意,下面這個URL 重定向一定要加上。 if (!-e $request_filename) { rewrite ^/(.*) /index.php?$1 last; } location / { root /home/wwwroot/sssm; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root /home/wwwroot/sssm; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } access_log /home/wwwlogs/sssm/access.log main; error_log /home/wwwlogs/sssm/error.log error; }
復制代碼

 

5  如果是apache 需要在虛擬服務的配置文件中添加一下規則

復制代碼
<VirtualHost *:80>
    ServerName jinkang
    DocumentRoot D:/wamp64/wwwroot/
    <Directory  "D:/wamp64/wwwroot/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* index.php
    </Directory>
</VirtualHost>
復制代碼

或者在代碼根目錄下新建文件 .htaccess

內容為 

復制代碼

RewriteEngine On
RewriteRule ^/Api/(.*) /Api/index.php
RewriteRule ^/admin/(.*) /admin/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

復制代碼

 

yaconf  配置  yaconf.directory=/tmp/yaconf/  (注意后綴)

application/library/Db.php    public function __construct($dbname = 'gjml')   數據庫標識

application/library/Yaconf.php     $m['gjml']=$e; 

application/Bootstrap.php     

Yaf_Registry::set('db', new Db('gjml'));

在yaconf.directory 下創建文件 db.ini

s.hostname = "122"
s.username = "12"
s.password = "12"
s.port = "3306"
s.database = "12"
s.charset = "utf8"
s.debug = "1"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM