您的位置:首页 > 其它

教你如何去掉优酷网的30秒广告

2013-04-02 09:42 429 查看
Web1的IP地址我们设置为172.16.6.1,Web2的IP地址我们设置为172.16.6.2

一、配置Web1上的NFS服务:首先检查nfs-utils 是否安装;
# rpm -q nfs-utils
# service portmap status 确保portmap服务的开启
# service nfs start 启动nfs服务
# chkconfig nfs on
# vim /etc/exports
/vhosts 172.16.6.2(rw)
保存退出

Web1上编译安装mysql-5.5.20:

1、准备数据存放的文件系统

新建一个逻辑卷,并将其挂载至特定目录:
首先要有一个8e格式的磁盘分区,我们以sda5为例;
创建物理卷:pvcreate /dev/sda5
创建卷组:vgcreate myvg /dev/sda5
创建逻辑卷:lvcreate -L 4G -n mydata myvg
格式化:mkfs -t ext3 /dev/myvg/mydata

# vim /etc/fstab
开机自动挂载至/mydata目录
/dev/myvg/mydata /mydata ext3 defults 0 0

这里设定其逻辑卷的挂载目录为/mydata,而后需要创建/mydata/data目录做为mysql数据的存放目录。

2、新建用户以安全方式运行进程:

# groupadd -r mysql
# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
# chown -R mysql:mysql /mydata/data

3、安装并初始化mysql-5.5.20

首先下载平台对应的mysql版本至本地

# tar xf mysql-5.5.19-linux2.6-i686.tar.gz -C /usr/local
# cd /usr/local/
# ln -sv mysql-5.5.19-linux2.6-i686 mysql
# cd mysql

# chown -R mysql:mysql .
# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
# chown -R root .

4、为mysql提供主配置文件:

# cd /usr/local/mysql
# cp support-files/my-large.cnf /etc/my.cnf

并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:
thread_concurrency = 2

另外还需要添加如下行指定mysql数据文件的存放位置:
datadir = /mydata/data

5、为mysql提供sysV服务脚本:

# cd /usr/local/mysql
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

添加至服务列表:
# chkconfig --add mysqld
# chkconfig mysqld on

# mysql -uroot -p
>grant privileges on discuz.* to discuz@localhost identified by 'sungao'
>flush privileges

编辑discuz配置文件:
# vim config.inc.php
$ dbhost = 'localhost'
$ dbuser = 'dzuser'
$ dbpw = 'sungao'
$ dbname = 'discuz'

安装httpd-2.4.1

1、解决依赖关系

httpd-2.4.1需要较新版本的apr和apr-util,因此需要事先对其进行升级,共需要如下4个软件包:
apr-1.4.6-1.i386.rpm
apr-devel-1.4.6-1.i386.rpm
apr-util-1.4.1-1.i386.rpm
apr-util-devel-1.4.1-1.i386.rpm

下载完成之后,使用“rpm -Uvh”进行升级即可。

另外,httpd-2.4.1编译过程也要依赖于pcre-devel软件包,需要事先安装。这个直接用yum安装即可。

2、编译安装httpd-2.4.1

首先下载httpd-2.4.1到本地。而后执行如下命令进行编译安装过程:

# tar xf httpd-2.4.1.tar.bz2
# cd httpd-2.4.1
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-

cgi --enable-rewrite --with-zlib
# make
# make install

3、修改httpd的主配置文件,设置其Pid文件的路径

编辑/etc/httpd/httpd.conf,添加如下行即可:
PidFile "/var/run/httpd.pid"

4、提供SysV服务脚本/etc/rc.d/init.d/httpd,内容如下:

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|

configtest}"
exit 1
esac

exit $RETVAL

而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/httpd

加入服务列表:
# chkconfig --add httpd

这样httpd服务就安装好了,可以使用service httpd start 启动了。

安装php-5.3.10

首先下载源码包至本地目录。

# tar xf php-5.3.10.tar.bz2
# cd php-5.3.10
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql
--with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml- dir=/usr
--enable-xml --with-apxs2=/usr/local/apache/bin/apxs

说明:如果前面第1步解决依赖关系时安装mcrypt相关的两个rpm包,此./configure命令还可以带上--with-mcrypt

选项以让php支持mycrpt扩展。

# make
# make test
# make intall

为php提供配置文件:
# cp php.ini-production /usr/local/php/lib/php.ini

3、 编辑apache配置文件httpd.conf,以apache支持php

# vim /etc/httpd/httpd.conf
1、添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

2、定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html

# cd /usr/local/apache/htdocs
# vim index.php
<?php
phpinfo():
?>
编辑如下内容,让php连接数据库测试
<?php
$link=mysql_connect('localhost','root','');
if ($link)
echo "Successful!";
else
echo "Failure...";

mysql_close();
?>

而后重新启动httpd,或让其重新载入配置文件即:
service httpd reload或 service httpd restart
即可测试php是否已经可以正常使用。

编辑Web1的httpd主配置文件
DocumentRoot 改为/www/htdocs

Apache基于https工作协议的配置:
一、首先向CA申请数字证书:
#mkdir /etc/httpd/ssl
#cd /etc/httpd/ssl
#openssl genrsa 1024 >httpd.conf
#openssl req -new -key httpd.conf -out httpd.csr
填写相关信息后,CA会颁发httpd.crt文件将其cp到/etc/httpd/ssl/目录下

二、在httpd文件中启用ssl功能
vim /etc/httpd/httpd.conf
定位到#Include /etc/httpd/extra/httpd-ssl.conf行,去掉#号,将ssl的配置文件包含进主文件中,启动ssl功



三、配置ssl的配置文件:
vim httpd-ssl.conf
<VirtualHost 172.16.6.1:443>

定位至SSLCertificateFile行,修改为:SSLCertificateFile "/etc/httpd/ssl/http.crt"
定位至SSLCertificateKeyFile行,修改为:SSLCertificateKeyFile "/etc/httpd/ssl/http.key"

Web2上用上述同样方法编译安装httpd和php

# showmount -a 172.16.6.1
# mkdir -pv /www/htdocs
# mount -t nfs 172.16.6.1:/www/htdocs /www/htdocs

注意:在Web2上编译安装php的时候需要mysql的头文件,所以需要实现安装mysql

按照刚才给Web1的方法配置Web2 使其能基于https协议工作

在Web1上:
# mkdir /www/phpmyadmin
# tar xf phpMyadmin-3.4.10.1.tar.bz2
# mv phpMyadmin/* /www/phpmyadmin

# vim httpd-ssl.conf
<VirtualHost 172.16.6.1:443>

# General setup for the virtual host
DocumentRoot "/www/phpmyadmin"
ServerName www.magedu.com:443
ServerAdmin admin@magedu.com
ErrorLog "/usr/local/apache/logs/error_log"
TransferLog "/usr/local/apache/logs/access_log"
Alias /phpmyadmin /www/phpmyadmin

使phpmyadmin基于https协议访问

在Web2上:

# mkdir /www/wordpress
# tar xf wordpress-3.3.1.tar.bz2
# mv phpMyadmin/* /www/wordpress

# vim httpd-ssl.conf
<VirtualHost 172.16.6.2:443>

# General setup for the virtual host
DocumentRoot "/www/wordpress"
ServerName www.magedu.com:443
ServerAdmin admin@magedu.com
ErrorLog "/usr/local/apache/logs/error_log"
TransferLog "/usr/local/apache/logs/access_log"
Alias /blog /www/wordpress

本文出自 “bleachLinux” 博客,请务必保留此出处http://9081520.blog.51cto.com/4384407/809914
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: