第一步:wordpress更换域名,网站无法访问-“恭喜,LNMP安装包安装成功”-解决方法
接着前一篇的文章,域名更新之后,无法访问网站的,这里还需要修改nginx.conf配置,这个文件再如下目录,用FileZilla连接下载修改上传就行。
/usr/local/nginx/conf/nginx.conf
下面是我的Server配置:
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/default;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}
include vhost/*.conf;
}
server_name 并未包含任何值,但是再最后一句include了一个config配置文件,配置主要再这个里面,那我们找到他,也在这个路径下可以找到。
/usr/local/nginx/conf/vhost/www.blogtextbooks.com.conf
我们打开文件看Server配置,
server
{
listen 80;
#listen [::]:80;
server_name www.blogtextbook.com ;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.blogtextbooks.com;
include wordpress.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
这个配置主要是这句话server_name www.blogtextbook.com ;这个是我的新域名,旧的域名是www.blogtextbooks.com,新域名少了个s,在这里修改一下,保存然后清除浏览器缓存,再登陆网站就能成功访问了。