美文网首页
linux下使用多个wordpress(指向不同域名)

linux下使用多个wordpress(指向不同域名)

作者: wmelon | 来源:发表于2019-04-28 12:56 被阅读0次

最开始的想法是安装两个nginx,指向不同的端口,后来失败了;

之后想在一个nginx中建两个html文件夹,然后再conf中的server中root指向这两个不同的html文件夹,可是可以,但是静态文件访问不了。

后来想到了用重定向的方式来,两个不同的server的root都指同一个html文件夹,在html文件夹下增加index.php和index_wp.php文件,用于重定向到对应的wordpress项目中


clipboard.png

index.php:

/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/blog/wp-blog-header.php' );

index_wp.php:

/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );

conf配置:

blog文件夹对应的conf:

server {
        listen       80;
        server_name  ********; #域名


        location / {
          index  index.php;
         }
        error_page   502  /error.html;
          location = /error.html {
          root   html;
          }
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

wordpress文件夹对应的conf:

这里的location / 中的index 设置为index_wp.php index.php,就会在html目录中先找index_wp.php文件,没有再找index.php文件,之后进入了wordpress文件夹后找不到index_wp.php文件就会接着找index.php文件。如果只设置了index_wp.php的话在进入后台文件是会报403错误

server {
        listen       80;
        server_name ********;


        location / {
          index  index_wp.php index.php;
         }
        error_page   502  /error.html;
          location = /error.html {
          root   html;
          }
       
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
  }   

这样就可以了!

链接:https://wmelon.cn/146.html

相关文章

  • linux下使用多个wordpress(指向不同域名)

    最开始的想法是安装两个nginx,指向不同的端口,后来失败了; 之后想在一个nginx中建两个html文件夹,然后...

  • 配置XAMPP中Apache的Virtual Host功能

    配置网站中常有使用将多个域名指向同一IP,并期待HTTP服务器对使用不同域名的访问返回不同结果的情况。正好现在要给...

  • nginx用起来真是又爱又恨

    今天在docker上配置了一下多个域名,当然多个域名都指向80端口啊,可是原来都是好好的,怎在dockers上就是...

  • Apache域名301跳转

    首先,我们来了解一下什么是域名跳转: 按自己的理解来说,就是你有多个域名,想指向一台服务器,使用一个服务器的资源 ...

  • Saas项目配置hosts文件

    简介 通过域名前缀来区分不同租户的Saas项目,在本地调试时可以通过配置hosts文件,将多个自定义域名指向127...

  • RHCE.2021.学习笔记.15篇

    Red Hat Enterprise Linux 下使用BIND提供域名解析服务

  • 跳转配置

    假设你想在Linux Nginx中用不同的域名访问不同的目录,这时就要配置多个vhost,具体配置如下,假设网站根...

  • linux apache下虚拟主机配置方法!

    linux apache下虚拟主机配置方法 假设IP是192.168.1.183,有两个域名指向该IP,分别是21...

  • 如何快速实现 Wordpress 博客域名更换?

    如题,如何快速更换使用 Wordpress 搭建的网站、博客的域名,除了在域名服务商那更换域名的解析和 web服务...

  • wordpress搬家换域名

    如果你看到这篇文章,说明你已经在使用wordpress了,那么直接切入正题:wordpress怎么搬家或者更换域名...

网友评论

      本文标题:linux下使用多个wordpress(指向不同域名)

      本文链接:https://www.haomeiwen.com/subject/cijdnqtx.html