一,Windows10安装配置yaf
下面有nginx与Apache的站点配置
Yaf官方文档:http://www.laruence/manual/index.html
第一步:安装PHP扩展配置Yaf
下载Yaf扩展:http://pecl.php/package/yaf
None-Thread Safe 就是非线程安全,在执行时不进行线程(thread)安全检查;
Thread Safe 就是线程安全,执行时会进行线程(thread)安全检查,
以防止有新要求就启动新线程的 CGI 执行方式耗尽系统资源。
non-thread-safe 非线程安全 与 IIS搭配环境
thread-safe 线程安全 与 apache搭配环境
第二步:下载解压包,将 php_yaf.dll 拷贝至 php环境的 ext目录 下
php.ini
;php_yaf
extension=php_yaf.dll
重新启动Apache,查看phpinfo()信息,如下图表示扩展安装成功
<?php
echo phpinfo();
二,yaf 生成 PHP框架
1, 在Github下载Yaf项目生成目录压缩文件 在Github下载Yaf项目生成目录压缩文件
Github下载地址:https://github/laruence/yaf
2, 解压后在 yaf-master\yaf-master\tools\cg 目录下
按住 Ctrl + shift 在右键打开 Windows PowerShell
PS E:\yaf\tools\cg> php yaf_cg 项目名(yaf_test)
在 E:\yaf\tools\cg\output\中生成 一个项目文件夹(便是PHP框架)
3, apache 配置 ( yaf_test = 项目名 )
配置文件: E:\wamp64\bin\apache\apache2.4.35\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName www.vue_plan
ServerAlias vue_plan
DocumentRoot "E:/wamp64/www/projects/vue_plan"
<Directory "E:/wamp64/www/projects/vue_plan">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
nginx 配置站点:
位置 : vim /etc/nginx/nginx.conf
server {
listen 80; # 端口号
server_name www.vue_plan vue_plan; # 站点域名
root /var/www/html; # 站点读取目录
index index.html index.htm index.php; # 默认读取文件
localtion / {
}
location ~ .php${
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; # 站点会以这里为标准读取
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html{
}
error_page 500 502 503 504 /50x.html
location = /50x.html{
}
}
server {
listen 80; # 监听端口
server_name www.vue_plan vue_plan; # 站点域名
root /var/www/html; # 站点根目录
index index.html index.htm index.php; # 默认导航页
location / {
# WordPress固定链接URL重写
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
# PHP配置
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
上面的配置不行,看这个实例:
server {
listen 80;
server_name www.vue_plan;
root /var/www/html;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php last;
}
location ~ \.php$ {
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
在Nginx上配置多个站点 https://wwwblogs/Erick-L/p/7066564.html
4, host Windows10 配置
位置: C:\WINDOWS\System32\drivers\etc\host
127.0.0.1 www.vue_plan
4,yaf框架目录结构
+ public
|- index.php //入口文件
|- .htaccess //重写规则
|+ css
|+ img
|+ js
+ conf
|- application.ini //配置文件
+ application
|+ controllers
|- Index.php //默认控制器
|+ views
|+ index //控制器
|- index.phtml //默认视图
|+ modules //其他模块
|+ library //本地类库
|+ models //model目录
|+ plugins //插件目录
具体方法参考鸟哥的文档:
http://www.laruence/manual/tutorial.firstpage.html#tutorial.directory
更多推荐
Windows10安装配置yaf
发布评论