在Nginx服务器上怎么安装配置博客程序Typecho

这篇文章主要介绍了在Nginx服务器上怎么安装配置博客程序Typecho的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇在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伪静态

 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提示数据数据库信息,即可完成安装。

在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服务器无法实现伪静态化,在后台设置不成功

这主要是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换成你自己的实际域名和实际目录存放地址

关于“在Nginx服务器上怎么安装配置博客程序Typecho”这篇文章内容就介绍到这里,感谢各位的阅读!相信大家对“在Nginx服务器上怎么安装配置博客程序Typecho”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程之家行业资讯频道。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐