Heim > Betrieb und Instandhaltung > Nginx > So installieren und konfigurieren Sie das Blogging-Programm Typecho auf dem Nginx-Server

So installieren und konfigurieren Sie das Blogging-Programm Typecho auf dem Nginx-Server

王林
Freigeben: 2023-05-13 20:31:04
nach vorne
1322 Leute haben es durchsucht

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
Nach dem Login kopieren

这样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; } }
Nach dem Login kopieren

3.登陆phpmyadmin,新建数据库,一定要提前建立数据库,如果直接安装typecho会提示“对不起,无法连接数据库,请先检查数据库配置再继续进行安装”

4.访问http://www.cxy.cc/install.php 按提示数据数据库信息,即可完成安装。

So installieren und konfigurieren Sie das Blogging-Programm Typecho auf dem Nginx-Server

5.一些常见问题的解决
(1)安装完typecho只有首页能访问,访问其它页页面报404错误。
问题在于typecho需要pathinfo功能,nginx需要配置才能支持此功能,解决办法见第二步。

一般的出现这种情况时,nginx.conf里的的location设置都是类似这样

location ~ .*\.php$
Nach dem Login kopieren

要支持pathinfo,要改成

location ~ .*\.php(\/.*)*$
Nach dem Login kopieren

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

cgi.fix_pathinfo = 1
Nach dem Login kopieren

(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;
  }
Nach dem Login kopieren

:!:注意把以上配置中的yourdomain换成你自己的实际域名和实际目录存放地址

Das obige ist der detaillierte Inhalt vonSo installieren und konfigurieren Sie das Blogging-Programm Typecho auf dem Nginx-Server. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Verwandte Etiketten:
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
Nginx-Lastausgleichsproblem
Aus 1970-01-01 08:00:00
0
0
0
Fehler beim Neustart von Nginx
Aus 1970-01-01 08:00:00
0
0
0
Nginx-Lastausgleich
Aus 1970-01-01 08:00:00
0
0
0
Nginx-Default.conf-Problem
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage