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"
php中yaf框架的服务器配置
原文地址:https://www.cnblogs.com/fandong1314/p/8295636.html