Yii學(xué)習(xí)總結(jié)之安裝配置(2)_PHP教程
推薦:使用php的HTTP請求的庫Requests實(shí)現(xiàn)美女圖片墻這篇文章主要介紹了使用php的HTTP請求的庫Requests實(shí)現(xiàn)美女圖片墻的方法,十分簡單實(shí)用,需要的朋友可以參考下 使用百度的接口獲取美女圖片,并用瀑布流的形式展示到自己的頁面中。 github項(xiàng)目地址:https://github.com/CraryPrimitiveMan/pretty 最終效果如下: 點(diǎn)開百
1. 開啟apache的mod_rewrite模塊,去掉LoadModule rewrite_module modules/mod_rewrite.so前的"#"符號,確保<Directory "..."></Directory>中有"AllowOverride All"。
2. 在項(xiàng)目中的/protected/config/main.php中添加代碼:
代碼如下:
'components'=>array(
...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,//注意false不要用引號括上
'rules'=>array(
'sites'=>'site/index',
),
),
...
),
3.配置服務(wù)器,Yii可以在Apache和Nginx下配置
1)Apache
在Apache服務(wù)器下,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中設(shè)置cgi.fix_pathinfo=0,這樣可以避免許多不必要的系統(tǒng)的stat()調(diào)用。
基本安裝和配置就到這里~~
分享:PHP實(shí)現(xiàn)加密的幾種方式介紹這篇文章主要介紹了PHP實(shí)現(xiàn)加密的幾種方式,非常全面實(shí)用,都是項(xiàng)目中經(jīng)常需要用到的,需要的朋友可以參考下 PHP中的加密方式有如下幾種 1. MD5加密 string md5 ( string $str [, bool $raw_output = false ] ) 參數(shù) str -- 原始字符串。 raw_output -- 如果可選的 raw
- 使用php的HTTP請求的庫Requests實(shí)現(xiàn)美女圖片墻
- PHP實(shí)現(xiàn)加密的幾種方式介紹
- php使用parse_url和parse_str解析URL
- 在Windows XP下安裝Apache+MySQL+PHP環(huán)境
- PHP+APACHE實(shí)現(xiàn)網(wǎng)址偽靜態(tài)
- php使用unset()刪除數(shù)組中某個(gè)單元(鍵)的方法
- php實(shí)現(xiàn)兩個(gè)數(shù)組相加的方法
- php實(shí)現(xiàn)遞歸與無限分類的方法
- php實(shí)現(xiàn)多維數(shù)組中每個(gè)單元值(數(shù)字)翻倍的方法
- php中有關(guān)合并某一字段鍵值相同的數(shù)組合并的改進(jìn)
- php模擬服務(wù)器實(shí)現(xiàn)autoindex效果的方法
- php瀏覽歷史記錄的方法
- 相關(guān)鏈接:
- 教程說明:
PHP教程-Yii學(xué)習(xí)總結(jié)之安裝配置(2)
。