typecho比wordpress更輕,更專注于寫的享受。
現在大多的虛擬機運行環境都是lnmp,安裝教程安裝typecho可能會遇到404,數據配置錯誤問題。
把這兩天安裝typecho的步驟寫下來給大家參考.
typecho安裝方法
1.下載
1
2
3
4
|
#網站目錄 cd /usr/local/nginx/html/ wget https: //github .com /typecho/typecho/releases/download/v0 .9-13.12.12-release /0 .9.13.12.12.-release. tar .gz -O typecho. tar .gz tart -zxvf typecho. tar .gz |
這樣typecho的源代碼放到了/usr/local/nginx/html/build
2.配置nginx的虛擬機(修改www.cxy.cc為你的域名),nginx配置typecho偽靜態
1
|
upstream php { server 127.0.0.1:9000; } server { server_name www.cxy.cc; root html/build; access_log logs/wcxy.access.log main; error_log logs/wcxy.error.log; index index.php list.php; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } if ( !-e $request_filename ) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*.php(/.*)*$ { fastcgi_index index.php; include fastcgi.conf; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_intercept_errors on; fastcgi_pass php; } location /status { #stub_status on; access_log off; } location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*.(js|css)?$ { expires 12h; } } |
3.登陸phpmyadmin,新建數據庫,一定要提前建立數據庫,如果直接安裝typecho會提示“對不起,無法連接數據庫,請先檢查數據庫配置再繼續進行安裝”
4.訪問http://www.cxy.cc/install.php 按提示數據數據庫信息,即可完成安裝。
5.一些常見問題的解決
(1)安裝完typecho只有首頁能訪問,訪問其它頁頁面報404錯誤。
問題在于typecho需要pathinfo功能,nginx需要配置才能支持此功能,解決辦法見第二步。
一般的出現這種情況時,nginx.conf里的的location設置都是類似這樣
1
|
location ~ .*\.php$ |
要支持pathinfo,要改成
1
|
location ~ .*\.php(\/.*)*$ |
在某些老版本的php里面,可能還要打開php.ini里的cgi.fix_pathinfo
1
|
cgi.fix_pathinfo = 1 |
(2)Nginx服務器無法實現偽靜態化,在后臺設置不成功
這主要是nginx的rewrite沒有設置導致的
在nginx.conf里找到網站的server配置段,一般我們推薦如下的配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
server { listen 80; server_name yourdomain.com; root /home/yourdomain/www/; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } access_log logs/yourdomain.log combined; } |
:!:注意把以上配置中的yourdomain換成你自己的實際域名和實際目錄存放地址