在Nginx服務(wù)器上安裝配置博客程序Typecho的教程
typecho比wordpress更輕,更專注于寫的享受。
現(xiàn)在大多的虛擬機(jī)運(yùn)行環(huán)境都是lnmp,安裝教程安裝typecho可能會(huì)遇到404,數(shù)據(jù)配置錯(cuò)誤問題。
把這兩天安裝typecho的步驟寫下來給大家參考.
typecho安裝方法
1.下載
#網(wǎng)站目錄 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的虛擬機(jī)(修改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,新建數(shù)據(jù)庫,一定要提前建立數(shù)據(jù)庫,如果直接安裝typecho會(huì)提示“對(duì)不起,無法連接數(shù)據(jù)庫,請(qǐng)先檢查數(shù)據(jù)庫配置再繼續(xù)進(jìn)行安裝”
4.訪問http://www.cxy.cc/install.php 按提示數(shù)據(jù)數(shù)據(jù)庫信息,即可完成安裝。
5.一些常見問題的解決
(1)安裝完typecho只有首頁能訪問,訪問其它頁頁面報(bào)404錯(cuò)誤。
問題在于typecho需要pathinfo功能,nginx需要配置才能支持此功能,解決辦法見第二步。
一般的出現(xiàn)這種情況時(shí),nginx.conf里的的location設(shè)置都是類似這樣
location ~ .*\.php$
要支持pathinfo,要改成
location ~ .*\.php(\/.*)*$
在某些老版本的php里面,可能還要打開php.ini里的cgi.fix_pathinfo
cgi.fix_pathinfo = 1
(2)Nginx服務(wù)器無法實(shí)現(xiàn)偽靜態(tài)化,在后臺(tái)設(shè)置不成功
這主要是nginx的rewrite沒有設(shè)置導(dǎo)致的
在nginx.conf里找到網(wǎng)站的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換成你自己的實(shí)際域名和實(shí)際目錄存放地址
相關(guān)文章
linux(centos5.5)/windows下nginx開啟phpinfo模式功能的配置方法分享
某站點(diǎn)用到結(jié)合phpinfo功能的urlrewrite,在nginx中需要在nginx.conf文件中進(jìn)行配置才可支持phpinfo2013-02-02

nginx實(shí)現(xiàn)一個(gè)域名配置多個(gè)laravel項(xiàng)目的方法示例

Nginx配置之實(shí)現(xiàn)多臺(tái)服務(wù)器負(fù)載均衡