用VPS安装wordpress,打开域名一直显示404 not found,是什么原因造成的,如何解决?

2013-06-25 23:01:24 +08:00
 yousurm
wordpress的文件和配置都已经弄好,放在/root/domains/blog/public_html/ 下
数据库和域名解析也准备就绪

域名也已经指向/root/domains/blog/
/root/vhost.sh的指令也执行过了

但是目前打开sin.cityfall.com安装wordpress的时候,显示404 not found,请问该如何解决?
1516 次点击
所在节点    VPS
33 条回复
donald
2013-06-25 23:04:14 +08:00
你不是放在public_html下,域名也应该指向public_html下啊。
AstroProfundis
2013-06-25 23:04:52 +08:00
目测你放博客的地方和域名指向的地方不一样
yousurm
2013-06-25 23:07:43 +08:00
@AstroProfundis @donald 已重新指向 还是不可以~
donald
2013-06-25 23:10:41 +08:00
@yousurm 把你nginx的error log贴上来
donald
2013-06-25 23:11:50 +08:00
@yousurm 最好还有部分的conf内容
Ansonyi
2013-06-25 23:13:30 +08:00
Rewrite的问题?或者权限?
yousurm
2013-06-25 23:17:02 +08:00
@Ansonyi 权限也已经修改成777
yousurm
2013-06-25 23:20:09 +08:00
@donald
是这个吗?


#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
manoon
2013-06-25 23:43:46 +08:00
一般的小博客。。。用apache多方便,整 nginx这么复杂做什么。
@yousurm 你把errorlog注释掉了。。。
yousurm
2013-06-25 23:49:44 +08:00
@manoon 搞不懂啊 第一次用VPS弄主机 Lnmp是别人帮我弄好的,目前想自己新建个博客 搞不明白了。errorlog不知道该如何去除注释 囧。。。。
manoon
2013-06-25 23:54:20 +08:00
想学习NGINX相关的东西,就踏踏实实把相关的文档看完。
如果只想搭个博客的话。
直接yum install httpd php mysql php-* mysql-* 然后简单的编辑一下配置文件,就足够了。
iCodex
2013-06-25 23:56:54 +08:00
初学者建议用apache,nginx还是以后熟悉之后再说吧。
donald
2013-06-26 00:53:13 +08:00
@yousurm 。。。你这个刚装上什么都没有配置啊。。。网上找点教程看一下吧,要改动的地方太多了
itommy
2013-06-26 00:58:54 +08:00
可以重来的话,LAMP 就好了,有很详细的 tutorial 在 digital ocean 的官网上

https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04

要是继续坚持 nginx 的话:

https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04
yousurm
2013-06-26 08:13:55 +08:00
@donald 这个VPS上之前已经有别人帮我安装好一个域名的博客。那意思是说,要新建网站的话,所有东西都要重新配置一遍是吗? 还有具体哪些东西是需要重新配置的?
yousurm
2013-06-26 08:14:24 +08:00
@itommy 好的 我晚上研究一下~
yousurm
2013-06-26 08:15:40 +08:00
@manoon @iCodex 单纯想配置一个网站呢~ 等网页端熟悉了 再考虑了解这些
yexiaoxing
2013-06-26 08:16:04 +08:00
用的是lnmp吧,看nginx下有没有vhost目录,贴出来
yousurm
2013-06-26 08:18:56 +08:00
@yexiaoxing 嗯 是的 Vhost.sh是这样的:

#!/bin/bash

# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, use sudo sh $0"
exit 1
fi

clear
echo "========================================================================="
echo "Add Virtual Host for LNMP V0.9 , Written by Licess "
echo "========================================================================="
echo "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux "
echo "This script is a tool to add virtual host for nginx "
echo "For more information please visit http://www.lnmp.org/"
echo ""
echo "========================================================================="

if [ "$1" != "--help" ]; then


domain="www.lnmp.org"
echo "Please input domain:"
read -p "(Default domain: www.lnmp.org):" domain
if [ "$domain" = "" ]; then
domain="www.lnmp.org"
fi
if [ ! -f "/usr/local/nginx/conf/vhost/$domain.conf" ]; then
echo "==========================="
echo "domain=$domain"
echo "==========================="
else
echo "==========================="
echo "$domain is exist!"
echo "==========================="
fi

echo "Do you want to add more domain name? (y/n)"
read add_more_domainame

if [ "$add_more_domainame" == 'y' ]; then

echo "Type domainname,example(bbs.vpser.net forums.vpser.net luntan.vpser.net):"
read moredomain
echo "==========================="
echo domain list="$moredomain"
echo "==========================="
moredomainame=" $moredomain"
fi

vhostdir="/home/wwwroot/$domain"
echo "Please input the directory for the domain:$domain :"
read -p "(Default directory: /home/wwwroot/$domain):" vhostdir
if [ "$vhostdir" = "" ]; then
vhostdir="/home/wwwroot/$domain"
fi
echo "==========================="
echo Virtual Host Directory="$vhostdir"
echo "==========================="

echo "==========================="
echo "Allow Rewrite rule? (y/n)"
echo "==========================="
read allow_rewrite

if [ "$allow_rewrite" == 'n' ]; then
rewrite="none"
else
rewrite="other"
echo "Please input the rewrite of programme :"
echo "wordpress,discuz,typecho,sablog,dabr rewrite was exist."
read -p "(Default rewrite: other):" rewrite
if [ "$rewrite" = "" ]; then
rewrite="other"
fi
fi
echo "==========================="
echo You choose rewrite="$rewrite"
echo "==========================="

echo "==========================="
echo "Allow access_log? (y/n)"
echo "==========================="
read access_log

if [ "$access_log" == 'n' ]; then
al="access_log off;"
else
echo "Type access_log name(Default access log file:$domain.log):"
read al_name
if [ "$al_name" = "" ]; then
al_name="$domain"
fi
alf="log_format $al_name '\$remote_addr - \$remote_user [\$time_local] \"\$request\" '
'\$status \$body_bytes_sent \"\$http_referer\" '
'\"\$http_user_agent\" \$http_x_forwarded_for';"
al="access_log /home/wwwlogs/$al_name.log $al_name;"
echo "==========================="
echo You access log file="$al_name.log"
echo "==========================="
fi

get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start create virtul host..."
char=`get_char`


if [ ! -d /usr/local/nginx/conf/vhost ]; then
mkdir /usr/local/nginx/conf/vhost
fi

echo "Create Virtul Host directory......"
mkdir -p $vhostdir
touch /home/wwwlogs/$al_name.log
echo "set permissions of Virtual Host directory......"
chmod -R 755 $vhostdir
chown -R www:www $vhostdir

if [ ! -f /usr/local/nginx/conf/$rewrite.conf ]; then
echo "Create Virtul Host ReWrite file......"
touch /usr/local/nginx/conf/$rewrite.conf
echo "Create rewirte file successful,now you can add rewrite rule into /usr/local/nginx/conf/$rewrite.conf."
else
echo "You select the exist rewrite rule:/usr/local/nginx/conf/$rewrite.conf"
fi

cat >/usr/local/nginx/conf/vhost/$domain.conf<<eof
$alf
server
{
listen 80;
server_name $domain$moredomainame;
index index.html index.htm index.php default.html default.htm default.php;
root $vhostdir;

include $rewrite.conf;
location ~ .*\.(php|php5)?$
{
try_files \$uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

$al
}
eof

echo "Test Nginx configure file......"
/usr/local/nginx/sbin/nginx -t
echo ""
echo "Restart Nginx......"
/usr/local/nginx/sbin/nginx -s reload

echo "========================================================================="
echo "Add Virtual Host for LNMP V0.9 , Written by Licess "
echo "========================================================================="
echo "For more information please visit http://www.lnmp.org/"
echo ""
echo "Your domain:$domain"
echo "Directory of $domain:$vhostdir"
echo ""
echo "========================================================================="
fi
yousurm
2013-06-26 08:19:40 +08:00
@yexiaoxing 之前别人帮我配置好,然后把原先的网站转移过来了。现在我想重新添加一个网站,用wordpress搭建。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/73621

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX