在Nginx服務器上怎么安裝配置博客程序Typecho

1.下載

#網站目錄 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偽靜態(tài)

?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會提示“對不起,無法連接數據庫,請先檢查數據庫配置再繼續(xù)進行安裝”

4.訪問http://www.cxy.cc/install.php 按提示數據數據庫信息,即可完成安裝。

在Nginx服務器上怎么安裝配置博客程序Typecho

5.一些常見問題的解決
(1)安裝完typecho只有首頁能訪問,訪問其它頁頁面報404錯誤。
問題在于typecho需要pathinfo功能,nginx需要配置才能支持此功能,解決辦法見第二步。

一般的出現這種情況時,nginx.conf里的的location設置都是類似這樣

location?~?.*.php$

要支持pathinfo,要改成

location?~?.*.php(/.*)*$

在某些老版本的php里面,可能還要打開php.ini里的cgi.fix_pathinfo

cgi.fix_pathinfo?=?1

(2)nginx服務器無法實現偽靜態(tài)化,在后臺設置不成功

這主要是nginx的rewrite沒有設置導致的

在nginx.conf里找到網站的server配置段,一般我們推薦如下的配置

??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換成你自己的實際域名和實際目錄存放地址

? 版權聲明
THE END
喜歡就支持一下吧
點贊6 分享