先在www.no-ip.org上申请账号luyx30@126.com,在此账号下注册2级域名xmhome.no-ip.org和mailgirl.no-ip.org。

并在CentOS下载安装noip2:http://www.no-ip.com/downloads.php?page=linux,安装配置说明安装。

安装完后,在/etc/rc.d/rc.local中添加/usr/local/bin/noip2来开机启动noip2

(noip2 -S来查看配置后的数据,使用noip2 -C来重新配置。)

1.安装apache.

yum install httpd mysql-server mysql php php-mysql php-devel

2.配置apache:

Technorati 标签: ,,,

----按照httpd.conf的默认设置,不修改。

----在/etc/httpd/conf.d/目录下新建virtual.conf,配置2个虚拟主机xmhome和mailgirl,配置文件如下:

NameVirtualHost *:80
##set directory pemission
#jishigou
<Directory "/var/www/jishigou/">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>
#xweibo
<Directory "/var/www/xweibo/">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>
##set virtual hosts' DocumentRoot
#default DocumentRoot
<VirtualHost *:80>
        ServerName      www.wbtaobao.cn
        DocumentRoot    /var/www/html
</VirtualHost>
#jishigou for xmhome
<VirtualHost *:80>
        ServerName      xmhome.no-ip.org
        DocumentRoot    /var/www/xmhome
        CustomLog       /var/log/httpd/xmhome.access_log combined
</VirtualHost>
#xweibo for mailgirl
<VirtualHost *:80>
        ServerName      mailgirl.no-ip.org
        DocumentRoot    /var/www/mailgirl
        CustomLog       /var/log/httpd/mailgirl.access_log combined
</VirtualHost>
----设置httpd的日志文件/etc/logrotate.d/httpd的logrotate,添加日志的压缩,配置文件如下:
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    compress
    delaycompress
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
 

3.下载记事狗微博系统和Xweibo系统到/var/www/目录下,分别改名为xmhome和mailgirl(前后对应):

----对xmhome配置日志文件分析软件:webalizer,修改/etc/webalizer.conf如下:

LogFile        /var/log/httpd/xmhome.access_log

OutputDir      /var/www/xmhome/protect/webalizer

Incremental    yes
----在/var/www/xmhome目录下新增受保护的目录protect,只有管理员才能进入:
--------mkdir protect
--------修改httpd.conf,添加以下数据:

##xmhome's protect directory for webalizer
<Directory "/var/www/xmhome/protect">
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
</Directory>

--------在protect目录下新建.htaccess文件:

AuthName “Protect for xmhome’s webalizer”

Authtype  Basic

AuthUserFile  /var/www/xmhome.passwd

require valid-user

--------建立能通过验证的用户:

htpasswd –c /var/www/xmhome.passwd root

-------将默认的webalizer数据拷贝到protect目录下:cp –a /var/www/usage/ /var/www/xmhome/protect webalizer

-------执行webalizer的分析工作,在shell执行:webalizer
----将复制进去的文档修改成默认的安全性上下文:restorecon –Rv xmhome  mailgirl
----因为安装过程中需要可写权限,顾先将权限设置成777: chmod –R 777 xmhome mailgirl

-------将httpd的日志备份文件进行压缩,在/etc/logrotate.d/httpd添加compress。

4.安装记事狗微博系统。在浏览器上输入xmhome.no-ip.org,安装安装提示一步一步操作。

----安装完成后可直接使用,且接入新浪微博与腾讯微博正常。(之前出现过有异常的情况)

5.安装Xweibo。在浏览器上输入mailgirl.no-ip.org,安装安装提示一步一步操作。

----安装过程中需要申请APP KEY和APP Secret,在此利用weibtaobao@sina.cn这个账号来申请:

CentOS6 web服务器apache配置全过程_apache

此过程中涉及到验证问题,顾在mailgirl目录下新建index.html文件,来通过验证,代码如下:

<html>
<head>
<title>猫女</title>
<meta property="wb:webmaster" content="2547a8279d62ee81" />
<meta http-equiv="refresh" content="0.5;url=http://mailgirl.no-ip.org/index.php">
</head>
<body>
</body>
</html>

 

注意:安装完成后,一定记得将目录跟文件的权限需要修改成755,同时因为涉及到上传头像等等写入数据的操作,需要将xmhome/data,xmhome/setting的权限设置成777。

但是一定要将xmhome/install和mailgirl/install文件夹的权限设置成400

6.由于个人计算机是小区宽带用户,无独立的公网IP,顾得在路由器上做端口映射,将web服务器的ip地址与mac绑定,并将80端口映射到192.168.1.117上,如下图:

CentOS6 web服务器apache配置全过程_centos_02

CentOS6 web服务器apache配置全过程_centos_03

7.放行防火墙规则/usr/local/firewall/iptables.rule  并在rc.local添加开机启动,iptables.rule文件如下:

#!/bin/bash

##firewall set
##luyx30  v1.0  2012-11-24

#define some parameter
EXTIF="eth0"
INNET="192.168.1.0/24"

##set kernel
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
for i in /proc/sys/net/ipv4/conf/*/{rp_filter,log_martians}; do
        echo "1" > $i
done
for i in /proc/sys/net/ipv4/conf/*/{accept_source_route,accept_redirects,send_redirects}; do
        echo "0" > $i
done

##clear rule,set default rule,open rule
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin; export PATH
iptables -F
iptables -X
iptables -Z
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

##allow some ICMP data
AICMP="0 3 3/4 4 11 12 14 16 18"
for tyicmp in $AICMP
do
        iptables -A INPUT -i $EXTIF -p icmp --icmp-type $tyicmp -j ACCEPT
done

##allow some services
iptables -A INPUT -p tcp -i $EXTIF --dport 80 --sport 1024:65534 -j ACCEPT  #HTTP
iptables -A INPUT -p tcp -s 192.168.1.0/24 -j ACCEPT #allow lan user
/etc/init.d/iptables save

 

7.至此安装配置完成,可登录xmhome.no-ip.org和mailgirl.no-ip.org进行测试。