【发布时间】:2015-04-02 05:56:09
【问题描述】:
我有两个域名(例如 site1.com 和 site2.com),并设置了 CNAMES 来运行博客(例如 blog.site1.com 和 blog.site2.com)。在单独的服务器上,我正在运行带有 mysql-server 的 VPS (NGINX) 服务器来运行两个 wordpress 博客。
我能找到的最好的指导是link。但是,他们使用的是 Apache 虚拟主机。所以使用 Nginx 我做了以下事情:
cd /etc/nginx/sites-available
sudo cp default site1.com
sudo cp default site2.com
在 site1.com 服务器块中,我修改了以下内容:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
#root /usr/share/nginx/html;
root /home/ubuntu/www/blog.site1.com;
index index.php;
server_name blog.site1.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
site2.com nginx 服务器块也设置了类似的更改。然后为 ~/sites-enabled/ 文件设置符号链接。然后我更改了 site1.com 和 site2.com 中每个 wordpress 目录的 wp-config.php。
site1.com (wp-config.php)
/** The name of the database for WordPress */
define('DB_NAME', 'FirstDatabase');
/** MySQL database username */
define('DB_USER', 'FirstUser');
/** MySQL database password */
define('DB_PASSWORD', 'FirstPassword');
site2.com (wp-config.php)
/** The name of the database for WordPress */
define('DB_NAME', 'SecondDatabase');
/** MySQL database username */
define('DB_USER', 'SecondUser');
/** MySQL database password */
define('DB_PASSWORD', 'SecondPassword');
当我导航到 blog.site1.com 或 blog.site2.com 时,我会看到 wordpress 安装页面。
在我完成其中一个 wordpress 站点的安装后出现问题。即使我为每个 wordpress 安装实例指定了单独的数据库,两个站点都显示相同的 wordpress 实例。由于 wp-config.php 文件清楚地显示了单独的定义,我不确定错误在哪里。有人可以提供纠正这个问题的指导吗?
【问题讨论】:
标签: php mysql wordpress ubuntu nginx