模板酷站

电脑版
提示:原网页已由神马搜索转码, 内容由www.mb5u.com提供.

Yii学习总结之安装配置(2)_PHP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:使用php的HTTP请求的库Requests实现美女图片墙这篇文章主要介绍了使用php的HTTP请求的库Requests实现美女图片墙的方法,十分简单实用,需要的朋友可以参考下 使用百度的接口获取美女图片,并用瀑布流的形式展示到自己的页面中。 github项目地址:https://github.com/CraryPrimitiveMan/pretty 最终效果如下: 点开百

1. 开启apache的mod_rewrite模块,去掉LoadModule rewrite_module modules/mod_rewrite.so前的"#"符号,确保<Directory "..."></Directory>中有"AllowOverride All"。
2. 在项目中的/protected/config/main.php中添加代码:

 

代码如下:
'components'=>array(
...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,//注意false不要用引号括上
'rules'=>array(
'sites'=>'site/index',
),
),
...
),

 

3.配置服务器,Yii可以在Apache和Nginx下配置

1)Apache

在Apache服务器下,Yii需要配置.htaccess文件。配置如下

 

代码如下:
RewriteEngine on
# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)
RedirectMatch 403 /\..*$
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

 

2)Nginx

Yii可以使用Nginx和PHP的FPM SAPI。配置如下

 

代码如下:
server {
set $host_path "/www/mysite";
access_log /www/mysite/log/access.log main;
server_name mysite;
root $host_path/htdocs;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}

 

使用如上配置,你可以在php.ini中设置cgi.fix_pathinfo=0,这样可以避免许多不必要的系统的stat()调用。

基本安装和配置就到这里~~

分享:PHP实现加密的几种方式介绍这篇文章主要介绍了PHP实现加密的几种方式,非常全面实用,都是项目中经常需要用到的,需要的朋友可以参考下 PHP中的加密方式有如下几种 1. MD5加密 string md5 ( string $str [, bool $raw_output = false ] ) 参数 str -- 原始字符串。 raw_output -- 如果可选的 raw

上一页
2/2
下一页
来源:模板无忧/所属分类:PHP教程/更新时间:2015-03-12
最新评论:

暂时还没人评论! 快来抢沙发啊!


匿名评论
相关PHP教程