1. mysql的安装
a) 下载(为了适应32位系统)mysql-5.5.15-linux2.6-i686.tar.gz
b) 解压缩与拆包,并将以前安装过的与mysql相关的包卸载
[root@localhost5~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/
[root@localhost5~]# rpm -qa |grep mysql
mysql-libs-5.1.71-1.el6.i686
[root@localhost5~]# yum --disablerepo=\* --enablerepo=c6-media remove mysql-libs -y
c) 数据库所属组的创建和处理
[root@localhost5~]# id mysql
id: mysql: Nosuch user
[root@localhost5~]# groupadd mysql
[root@localhost5~]# useradd -r -g mysql mysql
d) 准备操作
[root@localhost5~]# cd /usr/local/
[root@localhost5local]# ls
bin games lib mysql-5.5.15-linux2.6-i686 share
etc include libexec sbin src
[root@localhost5local]# ln -s mysql-5.5.15-linux2.6-i686 mysql
[root@localhost5local]# ls
bin games lib mysql sbin src
etc include libexec mysql-5.5.15-linux2.6-i686 share
[root@localhost5local]# cd mysql
[root@localhost5mysql]# chown -R mysql:mysql .
#查看是否安装libaio包,如果没有安装下一步骤会出错,到时只需挂在光盘安装即可
[root@localhost5mysql]# rpm -qa |grep libaio
libaio-0.3.107-10.el6.i686
#以系统管理员mysql身份执行安装初始数据库的脚本文件
root@localhost5mysql]# ./scripts/mysql_install_db --user=mysql
[root@localhost5mysql]# chown -R root .
[root@localhost5mysql]# chown -R mysql data/
e) 配置
若在mysql目录下产生了my.cnf文件,将其拷贝到/etc目录下,由于版本或者是系统的原因在这儿并没有产生此文件,我们无需理会,继续下一步的配置
#对控制脚本的操作
[root@localhost5mysql]# cp -p support-files/mysql.server /etc/init.d/mysqld
#查看mysql的启动是否正常
[root@localhost5mysql]# service mysqld start
StartingMySQL... SUCCESS!
[root@localhost5mysql]# service mysqld restart
Shutting downMySQL. SUCCESS!
Starting MySQL..SUCCESS!
[root@localhost5mysql]# netstat -tupln |grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4241/mysqld
#将mysql和mysqladmin工具加到系统搜索路径中
[root@localhost5mysql]# vim /etc/profile
执行一下使改动生效
[root@localhost5mysql]# . /etc/profile
f) 为数据库制定系统账户和密码
[root@localhost5mysql]# mysqladmin -u root -p password '123'
#默认密码为空
Enter password:
[root@localhost5mysql]# mysql -u root -p
#输入密码“123”
Enter password:
#测试查看
mysql> showdatabases;
+--------------------+
| Database |
+--------------------+
|information_schema |
| mysql |
|performance_schema |
| test |
+--------------------+
4 rows in set(0.00 sec)
g) 后续处理操作
[root@localhost5mysql]# chkconfig --add mysqld
[root@localhost5mysql]# chkconfig mysqld on
[root@localhost5mysql]# chkconfig --list |grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#库文件的处理
[root@localhost5mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@localhost5mysql]# ldconfig
[root@localhost5mysql]# ldconfig -pv |grep mysql
libtcmalloc_minimal.so.0 (libc6) =>/usr/local/mysql/lib/libtcmalloc_minimal.so.0
libmysqlclient.so.18 (libc6) =>/usr/local/mysql/lib/libmysqlclient.so.18
libmysqlclient.so (libc6) =>/usr/local/mysql/lib/libmysqlclient.so
#头文件的处理
[root@localhost5mysql]# cd /usr/include/
[root@localhost5include]# ln -s /usr/local/mysql/include/ mysql
#手册的处理
[root@localhost5~]# vim /etc/man.config
2. http的安装
a) 下载httpd(httpd-2.4.4.tar.bz2 apr-1.4.6.tar.gz apr-util-1.5.1.tar.gz)
b) 解压缩与拆包
[root@localhost5~]# tar -zxvf apr-1.4.6.tar.gz -C/usr/local/src/
[root@localhost5~]# tar -zxvf apr-util-1.5.1.tar.gz -C/usr/local/src/
[root@localhost5~]# tar -jxvf httpd-2.4.4.tar.bz2 -C/usr/local/src/
c) apr配置操作
[root@localhost5~]# cd /usr/local/src/apr-1.4.6/
#安装开发工具,否则在配置的时候会出错
[root@localhost5apr-1.4.6]# yum --disablerepo=\* --enablerepo=c6-media groupinstall"Development tools" -y
[root@localhost5apr-1.4.6]# ./configure --prefix=/usr/local/apr
#编译并安装
[root@localhost5apr-1.4.6]# make && make install
d) apr-util的配置操作
[root@localhost5apr-1.4.6]# cd ../apr-util-1.5.1/
[root@localhost5apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-utils --with-apr=/usr
/local/apr/bin/apr-1-config
[root@localhost5apr-util-1.5.1]# make && make install
----------------------------------------------------------------------
/usr/bin/install-c -m 644 aprutil.exp /usr/local/apr-utils/lib
/usr/bin/install-c -m 755 apu-config.out /usr/local/apr-utils/bin/apu-1-config
e) httpd的配置操作
#准备:安装pcre-devel,openssl-devel
[root@localhost5~]# yum --disablerepo=\* --enablerepo=c6-media install pcre-devel –y
[root@localhost5~]# yum --disablerepo=\* --enablerepo=c6-media install openssl-devel -y
#配置选项
-------------------------------------------------------------------------------------------
./configure \
--prefix=/usr/local/apache \
--sysconfdir=/etc/httpd\
--enable-so \
--enable-ssl \
--enable-rewrite \
--with-apr=/usr/local/apr/bin/apr-1-config\
--with-apr-util=/usr/local/apr-utils/bin/apu-1-config\
--with-pcre \
-with-z \
--enable-mpms-shared=all\
-----------------------------------------------------------------------------------------------
[root@localhost5apr-util-1.5.1]# cd ../httpd-2.4.4/
[root@localhost5httpd-2.4.4]# ./configure \
>--prefix=/usr/local/apache \
>--sysconfdir=/etc/httpd \
> --enable-so\
>--enable-ssl \
>--enable-rewrite \
>--with-apr=/usr/local/apr/bin/apr-1-config \
>--with-apr-util=/usr/local/apr-utils/bin/apu-1-config \
>--with-pcre \
>-with-z \
>--enable-mpms-shared=all
#编译并安装
[root@localhost5httpd-2.4.4]# make && make install
f) httpd工具的处理
[root@localhost5~]# vim /etc/profile
[root@localhost5~]# . /etc/profile
[root@localhost5~]# httpd -k start
AH00557: httpd:apr_sockaddr_info_get() failed for localhost5
AH00558: httpd:Could not reliably determine the server's fully qualified domain name, using127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@localhost5~]# netstat -tupln |grep httpd
tcp 0 0 :::80 :::* LISTEN 4207/httpd
#关闭防火墙和selinux
宿主机访问http://192.168.2.102/,页面显示“Itworks!”说明安装且启动成功
g) 进入httpd的安装目录下做头文件和手册的后续处理
#man手册的处理vim/etc/man.config MANPATH /usr/local/apache/man
[root@localhost5~]# vim /etc/man.config
#头文件的处理 cd/usr/include/ ln -s/usr/local/apache/include apache
[root@localhost5~]# cd /usr/local/include/
[root@localhost5include]# ln -s /usr/local/apache/include apache
h) 控制脚本的编辑
[root@localhost5~]# cd /etc/init.d/
[root@localhost5init.d]# touch httpd
[root@localhost5init.d]# chmod a+x httpd
[root@localhost5init.d]# vim httpd
---------------------------------------------------------脚本内容-----------------------------------------------------------
# /bin/bash
prog=/usr/local/apache/bin/httpd
lockfile=/var/lock/subsys/httpd
# description: the apache server
# chkconfig: 2345 88 44
start() {
if[ -e $lockfile ];then
echo "The apache is started"
else
echo "The apache server is starting......"
sleep 1
$prog -k start && echo "ok" && touch $lockfile || echo "failed"
fi
}
stop() {
if[ ! -e $lockfile ];then
echo "The apache is stoped"
else
echo "The apache server is stoping......"
sleep 1
$prog -k stop && echo "ok" && rm -rf $lockfile || echo "failed"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage:start|stop|restart"
esac
---------------------------------------------------------------------------------------------------------------------------------
#测试:chkconfig--add httpd checkconfig --list |grephttpd
#杀死以前的httpd pkill -9 httpd service httpd start
[root@localhost5init.d]# service httpd start
The apacheserver is starting......
AH00557: httpd:apr_sockaddr_info_get() failed for localhost5
AH00558: httpd: Could not reliably determine the server's fullyqualified domain name, using 127.0.0.1. Set the 'ServerName' directive globallyto suppress this message
ok
#netstat -tupln|grep httpd
[root@localhost5init.d]# netstat -tupln |grep httpd
tcp 0 0 :::80 :::* LISTEN 4623/httpd
i)
3. php的安装
a) 下载(php-5.5.8.tar.bz2)
b) 解压并拆解
[root@localhost5~]# tar -jxvf php-5.5.8.tar.bz2 -C/usr/local/src/
[root@localhost5~]# cd /usr/local/src/php-5.5.8/
c) 配置操作
#准备:安装libxml2-devel
#./configure
--------------------------------------------------------------------------------------------------------------------------
[root@localhost5php-5.5.8]# ./configure \
>--prefix=/usr/local/php \
>--with-config-file-path=/etc/php \
>--with-config-file-scan-dir=/etc/php5.d \
>--with-apxs2=/usr/local/apache/bin/apxs \
>--with-mysql=/usr/local/mysql \
>--with-pdo-mysql=/usr/local/mysql \
>--with-mysqli=/usr/local/mysql/bin/mysql_config \
>--enable-mbstring=all\
> --with-gd
d) 编译并安装(编译过程需要很长一段时间,为了减少不必要的麻烦,我们使用screen工具)
安装screen
[root@localhost5 php-5.5.8]# yum--disablerepo=\* --enablerepo=c6-media install screen –y
[root@localhost5 php-5.5.8]# screen
#ctrl+A+D离开screen开启的终端 screen -ls 查看 screen -r id 恢复
[root@localhost5 php-5.5.8]# screen
[detached]
[root@localhost5 php-5.5.8]# screen -ls
There is a screen on:
17760.pts-0.localhost5 (Detached)
1 Socket in /var/run/screen/S-root.
[root@localhost5 php-5.5.8]# screen -r17760
#在产生的终端中操作
[root@localhost5 php-5.5.8]# pwd
/usr/local/src/php-5.5.8
[root@localhost5 php-5.5.8]# make&& make install
# 创建为配置文件制定的目录
[root@localhost5 php-5.5.8]# mkdir /etc/php/etc/php5.d
#
[root@localhost5 php-5.5.8]# cpphp.ini-production /etc/php/php.ini
[root@localhost5 php-5.5.8]# service httpdrestart
e) 测试http与php的连接
#对配置文档的编辑
[root@localhost5htdocs]# vim /etc/httpd/httpd.conf
[root@localhost5 htdocs]# service httpd restart
[root@localhost5php-5.5.8]# cd /usr/local/apache/htdocs/
[root@localhost5htdocs]# vim index.php
在PC机*问http://192.168.2.102/,出现php的页面证明连接成功
f) 测试http与mysql的连接
[root@localhost5htdocs]# vim index.php
在PC机*问http://192.168.2.102/,出现连接的页面证明连接成功,关闭mysql服务再次访问出现没有连接
4. 安装及配置应用
a) phpwind
Ø 将下载好的phpwind解压
[root@localhost5~]# unzip phpwind_v9.0_gbk.zip
Ø 将upload更名后放在apache的站点目录下
[root@localhost5~]# mv phpwind_v9.0_gbk/upload /usr/local/apache/htdocs/phpwind
Ø PC访问httpd://192.168.2.102/phpwind
Ø 第一步检测环境时,会因为某些文件夹不可写出现警告,所以进入到server端对其权限进行修改,使其可写;
[root@localhost5phpwind]# chmod -R o+w attachment/ conf/ data/ html/ src/ themes/ windid/
Ø 点击“重新检测”,无警告时点击“下一步”,进入第二步:创建数据库
Ø 点击“创建数据”,安装成功
b) phpmyadmin
Ø 将下载好的phpmyadmin解压
[root@localhost5~]# unzip phpMyAdmin-3.5.8-all-languages.zip
Ø 将解压后产生的phpMyAdmin-3.5.8-all-languages更名后放入站点目录
[root@localhost5~]# mv phpMyAdmin-3.5.8-all-languages /usr/local/apache/htdocs/phpmyadmin
Ø PC访问http://192.168.2.102/phpmyadmin
Ø 填写用户名和密码之后,点击“执行”即可登陆管理server端的mysql数据库
c) Wordpress
Ø 将下载好的wordpress解压
[root@localhost5~]# unzip wordpress-3.8-zh_CN.zip
Ø 将解压后产生的wordpress目录放到站点目录
[root@localhost5~]# mv wordpress /usr/local/apache/htdocs/wordpress
Ø PC访问http://192.168.2.102/wordpress
Ø 点击“创建配置文件”,然后再点击“现在就开始!”填写信息
Ø 此时还需要创建一个叫wordpress的数据库,我们就利用phpmyadmin创建一个数据库;
Ø 点击“提交”
Ø 由上图提示,还需要进入wordpress目录创建一个wp-config.php的文件,内容就是蓝色区域的所有内容
[root@localhost5htdocs]# cd wordpress/
[root@localhost5wordpress]# vim wp-config.php
[root@localhost5wordpress]# service httpd restart
Ø 点击“进行安装”,填写登陆信息
Ø 点击“安装”
Ø 点击“登录”即可登陆管理
5. 压力测试
[root@localhost5 wordpress]# ab -n 1000 -c 500 http://192.168.2.102/wordpress
ConcurrencyLevel: 500
Timetaken for tests: 1.684 seconds
Completerequests: 1000
Failedrequests: 0
Writeerrors: 0
Non-2xxresponses: 1000
Totaltransferred: 477000 bytes
HTMLtransferred: 239000 bytes
Requestsper second: 593.93 [#/sec] (mean)
Time perrequest: 841.852 [ms] (mean)
Time perrequest: 1.684 [ms] (mean, acrossall concurrent requests)
Transferrate: 276.66 [Kbytes/sec]received
6. 安装php的xcache工具,实现缓存机制,提高web访问性能
Ø 将下载好的xcache解压并拆包
[root@localhost5 ~]# tar -zxvf xcache-3.1.0.tar.gz -C/usr/local/src/
[root@localhost5 ~]# cd /usr/local/src/xcache-3.1.0/
[root@localhost5 xcache-3.1.0]# ll configure
ls: cannot access configure: No such file or directory
Ø 使用phpize工具产生configure文件
[root@localhost5xcache-3.1.0]# /usr/local/php/bin/phpize
Configuring for:
PHP ApiVersion: 20121113
Zend Module ApiNo: 20121212
Zend ExtensionApi No: 220121212
[root@localhost5xcache-3.1.0]# ll configure
-rwxr-xr-x 1root root 463336 Aug 25 06:15 configure
Ø 使xcache成为php的一种加速模块
[root@localhost5xcache-3.1.0]# ./configure \
>--enable-xcache \
>--with-php-config=/usr/local/php/bin/php-config
Ø 编译安装
[root@localhost5xcache-3.1.0]# make && make install
----------------------------------------------------------------------
Build complete.
Don't forget torun 'make test'.
Installingshared extensions:
/usr/local/php/lib/php/extensions/no-debug-zts-20121212/
Ø 配置
[root@localhost5xcache-3.1.0]# cd /usr/local/php/lib/php/extensions/no-debug-zts-
20121212/
[root@localhost5no-debug-zts-20121212]# cp xcache.so /etc/php5.d/
[root@localhost5no-debug-zts-20121212]# cd
[root@localhost5~]# cd /usr/local/src/xcache-3.1.0/
[root@localhost5xcache-3.1.0]# ll *.ini
-rw-r--r-- 11000 513 3112 Sep 25 2013 xcache.ini
-rw-r--r-- 11000 513 656 Oct 10 2013 xcache-test.ini
-rw-r--r-- 11000 513 2574 Jun 18 2013xcache-zh-gb2312.ini
[root@localhost5xcache-3.1.0]# cp xcache.ini /etc/php5.d/
[root@localhost5xcache-3.1.0]# vim /etc/php5.d/xcache.ini
[root@localhost5xcache-3.1.0]# service httpd restart
Ø 查看xcache的信息
[root@localhost5~]# vim /usr/local/apache/htdocs/index.php
Ø PC访问http://192.168.2.102/
Ø 再次进行压力测试,试与没有安装xcache之前比较
[root@localhost5wordpress]# ab -n 1000 -c 500 http://192.168.2.102/wordpress
ConcurrencyLevel: 500
Time taken fortests: 0.290 seconds
Completerequests: 1000
Failedrequests: 0
Writeerrors: 0
Non-2xxresponses: 1000
Totaltransferred: 477000 bytes
HTMLtransferred: 239000 bytes
Requests persecond: 3450.30 [#/sec] (mean)
Time perrequest: 144.915 [ms] (mean)
Time perrequest: 0.290 [ms] (mean, acrossall concurrent requests)
Transferrate: 1607.22 [Kbytes/sec] received