分页: 1 / 1

ADSL实现虚拟服务器篇之Debian+Apache+WordPress

发表于 : 2009-06-04 8:07
npgmis
之前写过一篇"ADSL利用花生壳DDNS服务实现虚拟目录服务器",这是使用Ubuntu+nginx实现的,今天又做了个测试使用ADSL实现虚拟服务器篇之Debian+Apache,各位请指点.
1,安装AMP(apache,mysql,php)
#apt-get install apache2 mysql-server php5-common php5-mysql libapache2-mod-php5
安装包说明:

apache2 Web Server
mysql5-server Mysql服务器
php5-common php配置文件及相关信息
php5-mysql php与mysql需要此包
libapache2-mod-php5 apache与php连接模块
配置文件说明:
因为Debian的配置文件与CentOS的有些不同,CentOS是由/etc/httpd/conf/httpd.conf文件配置
apache,而Debian是由模块形式组成,其主配置文件为/etc/apache2/apache2.conf
以上第一步安装完成就可以写个phpinfo测试下了.PHP我是不懂了,只会这个phpinfo,呵呵
#vi /var/www/info.php
<?
phpinfo();
?>
2,配置PHP5支持Mysql
默认情况下PHP5已经不支持Mysql了,所以需要手动修改php.ini
#vi /etc/php5/apache2/php.ini
;extension=mysql.so
3,配置mysql用户的密码(此root非debian的root)
root密码:
#mysqladmin -uroot password '123456'
数据库及用户权限创建:
mysql -uroot -p 123456
mysql>create database dg2009;
mysql>use dg2009;
mysql>grant all on dg2009.* to dg2009_user@localhost;
mysql>use mysql;
mysql>update user set password=password("123456") where user="dg2009_user";
mysql>flush privileges;
4,现在是开始虚拟主机配置了,先看虚拟主机配置文件吧
#cat /etc/apache2/sites-enable/000-default
NameVirtualHost *:80
<VirtualHost *>
ServerAdmin twork@21cn.com
ServerName dg2009.vicp.net
DocumentRoot /var/www/dg2009
</VirtualHost>
<VirtualHost *>
ServerAdmin twork@21cn.com
ServerName 23day.vicp.net
DocumentRoot /var/www/23day
</VirtualHost>
<VirtualHost *>
ServerAdmin twork@21cn.com
ServerName blogwp.vicp.net
DocumentRoot /var/www/blogwp
</VirtualHost>
这是我的虚拟主机配置文件,但有个问题,在执行/etc/init.d/apache2 restart的时候会提示以下错误,但虚拟主机可以启动正常使用,这个问题还没搞懂!
debian:/etc/init.d/apache2 restart
Restarting web server: apache2[Wed Jun 03 20:53:38 2009] [error] VirtualHost *:80 -- mixing * por
ts and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined res
ults
[Wed Jun 03 20:53:38 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Jun 03 20:53:38 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
... waiting [Wed Jun 03 20:53:39 2009] [error] VirtualHost *:80 -- mixing * ports and non-* port
s with a NameVirtualHost address is not supported, proceeding with undefined results
[Wed Jun 03 20:53:39 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Jun 03 20:53:39 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
.
5,配置WordPress的永久链接
要使用wordpress的永久链接,需要启用mod_rewrite模块,开启方法:
#ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enable/rewrite.load
在/etc/apache2/apache2.conf配置文件中添加以下信息,具体怎么实现的,还没明白!
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
6,安装WordPress(略)
7,花生壳DDNS安装,其方法以我了解有三种方法可以实现:
(1)如果是局域网,可以在你自己的XP电脑上安装花生壳Windows客户端
(2)下载花生壳Linux客户端
(3)如果使用路由器,一般的路由器都支持花生壳动态域名服务,路由器需要做端口转发(端口映射)
到这一步,所有的配置都完成,可以访问测试下了
http://dg2009.vicp.net
http://23day.vicp.net
http://blogwp.vicp.net
以上有两点不明白的地方,希望有高手路过指点下,在此先谢谢了!
转载请注明出处:智康博客

Re: ADSL实现虚拟服务器篇之Debian+Apache+WordPress

发表于 : 2009-06-04 15:12
cwb526
能写详细点不能?呵呵!
qq群20836766欢迎加入!

Re: ADSL实现虚拟服务器篇之Debian+Apache+WordPress

发表于 : 2009-12-02 21:07
bzhao
这是作者遗漏的:
cp wp-config-sample.php /etc/config-your_domain_name.php
把里面的域名,数据库的名字和密码改成刚刚设好的。

Ubuntu 14.04 必须是如下才行:
#/var/www/info.php:
<?php
phpinfo();
?>