CentOS6.4+httpd2.4.4+mysql5.6.12+php5.4.16+xcache3.03(最新LAMP编译安装过程)

前端之家收集整理的这篇文章主要介绍了CentOS6.4+httpd2.4.4+mysql5.6.12+php5.4.16+xcache3.03(最新LAMP编译安装过程)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

大纲@H_404_2@

一、编译安装Apache @H_404_2@

二、安装MysqL数据库@H_404_2@

三、编译安装PHP@H_404_2@

四、整合Apache与PHP@H_404_2@

五、安装Xcache加速器@H_404_2@

六、启用服务器状态@H_404_2@

七、PHP连接MysqL测试@H_404_2@

八、安装Discuz论坛(Discuz_X3.0_SC_GBK)@H_404_2@

注:所有软件版本 CentOS6.4+httpd2.4.4+MysqL5.6.12+PHP5.4.16+xcache3.03 都是目前最新(所有的安装包点击这里下载)@H_404_2@

一、编译安装Apache @H_404_2@

1. 安装前准备@H_404_2@

修改yum源(163)@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[root@web ~] # yum install wget
[root@web ~] # wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
--2013-06-29 18:39:02-- http: //mirrors .163.com/.help /CentOS6-Base-163 .repo
@H_301_65@ Resolving mirrors.163.com... 123.58.173.106
Connecting to mirrors.163.com|123.58.173.106|:80... connected.
HTTP request sent,awaiting response... 200 OK
Length: 2006 (2.0K) [application /octet-stream ]
Saving to: a?CentOS6-Base-163.repo?
100%[================>] 2,006 --.-K /s in 0s
2013-06-29 18:39:02 (152 MB /s ) - a?CentOS6-Base-163.repoa? saved [2006 /2006 ]
[root@web ~] # cd /etc/yum.repos.d/
[root@web yum.repos.d] # mv CentOS-Base.repo CentOS-Base.repo.bak
[root@web yum.repos.d] # mv /root/CentOS6-Base-163.repo CentOS-Base.repo
[root@web yum.repos.d] # ls
CentOS-Base.repo CentOS-Media.repo
CentOS-Base.repo.bak CentOS-Vault.repo
CentOS-Debuginfo.repo
[root@web yum.repos.d] # yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@web yum.repos.d] # yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.7 kB 00:00
base /group_gz | 212 kB 00:00
base /filelists_db | 5.9 MB 00:01
base /primary_db | 4.4 MB 00:01
base /other_db | 2.7 MB 00:00
extras | 3.4 kB 00:00
extras /filelists_db | 10 kB 00:00
extras /prestodelta | 905 B 00:00
extras /primary_db | 18 kB 00:00
extras /other_db | 5.7 kB 00:00
updates | 3.4 kB 00:00
updates /filelists_db | 2.9 MB 00:00
updates /prestodelta | 617 kB 00:02
updates /primary_db | 3.2 MB 00:00
updates /other_db | 419 kB 00:00
Metadata Cache Created
[root@web yum.repos.d] #


安装编译工具@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
[root@web yum.repos.d] #yum groupinstall "Development Tools" "Development Libraries" �y
[root@web yum.repos.d] # yum grouplist
Loaded plugins: fastestmirror
@H_301_65@ Setting up Group Process
Loading mirror speeds from cached hostfile
Installed Groups:
Development tools
E-mail server
Fonts
General Purpose Desktop
Graphical Administration Tools
Input Methods
Legacy X Window System compatibility
MysqL Database client
Perl Support

关闭SElinux@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
[root@web ~] # vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
@H_301_65@ # enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@web ~] # reboot

关闭防火墙@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
[root@web ~] # service iptables stop
[root@web ~] # service ip6tables stop
[root@web ~] # chkconfig iptables off
@H_301_65@ [root@web ~] # chkconfig ip6tables off
[root@web ~] # chkconfig iptables --list
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@web ~] # chkconfig ip6tables --list
ip6tables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

修改主机名@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
[root@web ~] # vim /etc/sysconfig/network
NETWORKING= yes
HOSTNAME=web. test .com
@H_301_65@ ~
[root@web ~] # vim /etc/hosts
127.0.0.1 web web. test .com localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


2. 解决依赖关系@H_404_2@

httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。@H_404_2@

(1). 编译安装apr@H_404_2@

@H_404_2@

1
2
3
@H_301_65@ 4
5
6
[root@web src] # tar xf apr-1.4.6.tar.bz2
[root@web src] # cd apr-1.4.6
[root@web src] # ./configure --help | less (可以查看帮助文件
@H_301_65@ [root@web src] # ./configure --prefix=/usr/local/apr (指定安装路径)
[root@web src] # make
[root@web src] # make install

@H_404_2@

(2). 编译安装apr-util@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
[root@web src] # tar xf apr-util-1.5.2.tar.bz2
[root@web src] # cd apr-util-1.5.2
[root@web src] # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
@H_301_65@ (--prefix指定安装路径;--with-apr指定apr的安装路径,apr-util依赖于apr)
[root@web src] # make && make install
附:apache官方对APR的介绍:
The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behavIoUr regardless of the platform on which their software is built,relieving them of the need to code special- case conditions to work around or take advantage of platform-specific deficiencies or features.

(3). httpd-2.4.4编译过程也要依赖于pcre-devel软件包,需要事先安装。@H_404_2@

1
[root@web ~] # yum install pcre-devel -y

3. 编译安装httpd-2.4.4@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
[root@web src] # tar xf httpd-2.4.4.tar.gz
[root@web src] # cd httpd-2.4.4
[root@web httpd-2.4.4] # ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=event
@H_301_65@ --sysconfdir= /etc/httpd :指定配置文件安装位置
-- enable -so :支持动态共享模块如果没有这个模块PHP将无法与apache结合工作
-- enable -ssl :启用支持ssl
-- enable -cgi :支持cgi
-- enable -rewrite :支持URL重写
--with-zlib :压缩库,在互联网上传播时可节约带宽
--with-apr= /usr/local/apr :指定apr路径
--with-apr-util= /usr/local/apr-util :指定apr-util路径
-- enable -mpms-shared=all :支持多道处理模块
--with-mpm=event :设定默认的模块

错误:@H_404_2@

1
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

解决方法:@H_404_2@

1
[root@web httpd-2.4.4] # yum install -y openssl-devel

补充说明:@H_404_2@

(1)构建MPM为静态模块
在 全部平台中,MPM都可以构建为静态模块。在构建时选择一种MPM,链接到服务器中。如果要改变MPM,必须重新构建。为了使用指定的MPM,请在执行 configure脚本 时,使用参数 --with-mpm=NAME。NAME是指定的MPM名称。编译完成后,可以使用 httpd -l 来确定选择的MPM。 此命令会列出编译到服务器程序中的所有模块,包括 MPM。 @H_404_2@

(2)构建 MPM 为动态模块
在 Unix或类似平台中,MPM可以构建为动态模块,与其它动态模块一样在运行时加载。 构建 MPM 为动态模块允许通过修改LoadModule指令内容来改变MPM,而不用重新构建服务器程序。在执行configure脚本时,使用--enable- mpms-shared选项即可启用此特性。当给出的参数为all时,所有此平台支持的MPM模块都会被安装。还可以在参数中给出模块列表。默认MPM, 可以自动选择或者在执行configure脚本时通过--with-mpm选项来指定,然后出现在生成的服务器配置文件中。编辑LoadModule指令 内容可以选择不同的MPM。@H_404_2@

4. 修改httpd的主配置文件,设置其Pid文件的路径@H_404_2@

说明:手动编译安装后,httpd.pid文件是存放在/usr/local/apache/logs/目录下的,这个位置未免有些不方便。@H_404_2@

更改配置文件@H_404_2@

1
2
3
@H_301_65@ 4
5
6
[root@web httpd-2.4.4] # cd
[root@web ~] # cd /etc/httpd/
[root@web httpd] # ls
@H_301_65@ conf conf.d extra httpd.conf logs magic mime.types modules original run
[root@web httpd] # cp httpd.conf httpd.conf.bak
[root@web httpd] # vim httpd.conf

#在配置文件中找一个位置定义一下Pid文件路径就可以了@H_404_2@

1
Pidfile "/var/run/httpd.pid"

5. 提供SysV服务脚本/etc/rc.d/init.d/httpd@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@H_802_1404@ 78
79
80
81
82
83
84
85
[root@web httpd] # vim /etc/init.d/httpd
#!/bin/bash
#
@H_301_65@ # chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
. /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 # -----指定apachectl程序位置
httpd=${HTTPD- /usr/local/apache/bin/httpd } #-------httpd程序位置
prog=httpd
pidfile=${PIDFILE- /var/run/httpd .pid} #----如果文件存在就使用存在文件路径,如果不存在就使用/var/rum/httpd.pid
lockfile=${LOCKFILE- /var/lock/subsys/httpd } # --------创建的锁文件
RETVAL=0
start() {
echo -n $ "Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS #----以$pidfile文件执行httpd 并且使用选项start
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)
@H_802_1404@ $apachectl $@
RETVAL=$?
;;
*)
echo $ "Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL

[root@web httpd]# chmod +x /etc/init.d/httpd #添加执行权限 @H_404_2@

#设置开机自启动@H_404_2@

1
2
3
@H_301_65@ 4
5
[root@web httpd] # chkconfig httpd --add
[root@web httpd] # chkconfig httpd on
[root@web httpd] # chkconfig httpd --list
@H_301_65@ httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web httpd] #

6. 启动apache并测试@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
[root@web httpd] # service httpd start
Starting httpd: AH00558: httpd: Could not reliably determine the server 's fully qualified domain name,using web.test.com. Set the ' ServerName' directive globally to suppress this message
[ OK ]
@H_301_65@ [root@web httpd] #
[root@web httpd] # netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID /Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 990 /sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1066 /master
tcp 0 0 :::80 :::* LISTEN 36920 /httpd
tcp 0 0 :::22 :::* LISTEN 990 /sshd
tcp 0 0 ::1:25 :::* LISTEN 1066 /master
udp 0 0 0.0.0.0:68 0.0.0.0:* 890 /dhclient
[root@web httpd] #

启动成功了,但似乎有警告,我们看一下!@H_404_2@

1
Starting httpd: AH00558: httpd: Could not reliably determine the server 's fully qualified domain name,using web.test.com. Set the ' ServerName' directive globally to suppress this message

解决方案:@H_404_2@

编辑httpd.conf文件搜索"/ServerName",添加ServerName localhost:80@H_404_2@

1
2
3
@H_301_65@ 4
5
6
[root@web httpd] # vim /etc/httpd/httpd.conf
再重新启动apache 即可。
[root@web httpd] # service httpd restart
@H_301_65@ Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@web httpd] #

好了问题解决,下面我们用Windows 7访问一下!效果如下:@H_404_2@

效果图1

好了测试成功,下面我们继续!@H_404_2@

7. 为httpd服务的相关命令添加环境变量@H_404_2@

1
2
3
[root@web httpd] # httpd
- bash : httpd: command not found
[root@web httpd] #

大 家看到了,虽然我们可以使用 service httpd restart 来重新启动Apache,是我们无法使用httpd命令,下面我们就来解决一下!直接在/etc/profile.d目录下创建的httpd.sh环境变 量文件,因为在默认的情况下这个目录下定义的环境变量都是profile文件的组成部分。@H_404_2@

1
2
3
@H_301_65@ 4
5
6
[root@web httpd] # vim /etc/profile.d/httpd.sh
export PATH=$PATH: /usr/local/apache/bin
[root@web httpd] # source /etc/profile #重新读取一下环境变量
@H_301_65@ [root@web httpd] # httpd �t #测试一下
Syntax OK
[root@web httpd] #

现在httpd服务的相关命令就可以直接使用了,嘿嘿!@H_404_2@

二、安装MysqL数据库@H_404_2@

1. 准备数据存放的文件系统@H_404_2@

说明:新建一个逻辑卷,并将其挂载至特定目录即可。这里假设其逻辑卷的挂载目录为/mydata,而后需要创建/mydata/data目录做为MysqL数据的存放目录。@H_404_2@

(1). 先确认下系统里是否有LVM工具,默认没有安装 @H_404_2@

1
2
[root@web httpd] # rpm -qa | grep lvm
[root@web httpd] # yum install -y lvm2

(2). 查看一下磁盘@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
[root@web httpd] # fdisk -l
Disk /dev/sda : 21.5 GB,21474836480 bytes
255 heads,63 sectors /track ,2610 cylinders
@H_301_65@ Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x0000a0a2
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1938 5120000 83 Linux
/dev/sda4 1938 2611 5405696 5 Extended
/dev/sda5 1939 2066 1024000 82 Linux swap / Solaris
[root@web httpd] #

(3). 创建逻辑分区 @H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[root@web ~] # fdisk /dev/sda
/dev/sda7 2066 2327 2099724 8e Linux LVM #我这里是测试环境就创建了一个2G分区
[root@web ~] # partx -a /dev/sda #告诉内核有关存在和磁盘上的分区的编号
@H_301_65@ [root@web ~] # pvcreate /dev/sda7 #创建物理卷
Physical volume "/dev/sda7" successfully created
[root@web ~] # vgcreate myvg /dev/sda7 #创建卷组
Volume group "myvg" successfully created
[root@web ~] #
[root@web ~] # lvcreate -n mydata -L 1G myvg #创建一个1G的逻辑卷
Logical volume "mydata" created
[root@web ~] # lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
mydata myvg -wi-a---- 1.00g
[root@web ~] #
[root@web ~] # mkfs.ext4 /dev/myvg/mydata #格式化
[root@web ~] # mkdir /mydata #创建挂载目录
[root@web ~] # mount /dev/myvg/mydata /mydata/ #挂载
[root@web ~] # vim /etc/fstab
/dev/myvg/mydata /mydata ext4 defaults 0 0 #增加这一行
[root@web ~] # mount �a #测试挂载是否成功
[root@web ~] # mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /data type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/myvg-mydata on /mydata type ext4 (rw)
[root@web ~] #

(4). 为了便于管理在/mydata目录下再创建个子目录data用于存放数据@H_404_2@

1
2
3
@H_301_65@ 4
[root@web ~] # mkdir /mydata/data
[root@web ~] # ls /mydata/
data lost+found
@H_301_65@ [root@web ~] #

2. 新建用户以安全方式运行进程@H_404_2@

1
2
3
[root@web ~] # groupadd -r MysqL
[root@web ~] # useradd -g MysqL -r -s /sbin/nologin -M -d /mydata/data MysqL
[root@web ~] # chown -R MysqL:MysqL /mydata/data

3. 安装并初始化MysqL5.6.12@H_404_2@

(1). 说明:MysqL 安装包有三种式,rpm,源码包,二进制包(已编译好,解压后简单配置一下就可以用),我这里用的就是二进制包@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@web src] # tar -xf MysqL-5.6.12-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ #-C指定解压目录
[root@web local ] # ln -sv MysqL-5.6.12-linux-glibc2.5-x86_64/ MysqL #创建软链接
`MysqL ' -> `MysqL-5.6.12-linux-glibc2.5-x86_64/'
@H_301_65@ [root@web local ] # cd MysqL
[root@web MysqL] # ls
bin data include lib MysqL- test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@web MysqL] #
[root@web MysqL] # chown -R MysqL:MysqL . #更改属主属组
[root@web MysqL] # ll
total 76
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 bin
-rw-r--r-- 1 MysqL MysqL 17987 May 21 23:18 COPYING
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 MysqL MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 MysqL MysqL 4096 Jun 29 21:12 man
drwxr-xr-x 10 MysqL MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 MysqL MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 MysqL MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 MysqL MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 support-files

(2). 执行MysqL 初始化的data存放位置的准备@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@web MysqL] # scripts/MysqL_install_db --user=MysqL --datadir=/mydata/data #执行MysqL 初始化的data存放位置的准备
Installing MysqL system tables.... /bin/MysqLd : error while loading shared libraries: libaio.so.1: cannot open shared object file : No such file or directory
#初始化时报错说缺少libaio.so我们安装一下
@H_301_65@ [root@web MysqL] # yum install libaio
[root@web MysqL] # scripts/MysqL_install_db --user=MysqL --datadir=/mydata/data #再次执行MysqL 初始化的data存放位置的准备
To start MysqLd at boot time you have to copy
support-files /MysqL .server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MysqL root USER !
To do so,start the server, then issue the following commands:
. /bin/MysqLadmin -u root password 'new-password'
. /bin/MysqLadmin -u root -h web. test .com password 'new-password'
Alternatively you can run:
. /bin/MysqL_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MysqL daemon with:
cd . ; . /bin/MysqLd_safe &
You can test the MysqL daemon with MysqL- test -run.pl
cd MysqL- test ; perl MysqL- test -run.pl
Please report any problems with the . /bin/MysqLbug script!
The latest information about MysqL is available on the web at
http: //www .MysqL.com
Support MysqL by buying support /licenses at http: //shop .MysqL.com
WARNING: Found existing config file . /my .cnf on the system.
Because this file might be in use,it was not replaced,
but was used in bootstrap (unless you used --defaults- file )
and when you later start the server.
The new default config file was created as . /my-new .cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my .cnf exists on the system
This file will be read by default by the MysqL server
If you do not want to use this,either remove it,or use the
--defaults- file argument to MysqLd_safe when starting the server
[root@web MysqL] #
[root@web MysqL] # ls /mydata/data/ #查看 data 目录有文件说明初始化成功
ibdata1 ib_logfile0 ib_logfile1 MysqL performance_schema test

(3). 初始化完成后MysqL中目录文件的属主应改回成root,以免被别人攻破MysqL用户密码而带来数据破坏等@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@web MysqL] # cd /usr/local/MysqL/
[root@web MysqL] # chown root /usr/local/MysqL/* -R
[root@web MysqL] # ll
@H_301_65@ total 84
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 bin
-rw-r--r-- 1 root MysqL 17987 May 21 23:18 COPYING
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 root MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 root MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 support-files
[root@web MysqL] #

4. 为MysqL提供主配置文件@H_404_2@

初始化后会自动在当前目录下创建一个my.cnf配置文件,直接修改就可以(在MysqL 5.6 以后配置文件自动生成,不需要我们再进行复制)@H_404_2@

(1). 查看配置文件@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[root@web MysqL] # ll
total 84
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 bin
@H_301_65@ -rw-r--r-- 1 root MysqL 17987 May 21 23:18 COPYING
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 root MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 root MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 support-files
[root@web MysqL] #
[root@web MysqL] # cat my.cnf
# For advice on how to change settings please see
# http://dev.MysqL.com/doc/refman/5.6/en/server-configuration-defaults.html
[MysqLd]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MysqL. Start at 70% of total RAM for dedicated server,else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set,remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed,experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@web MysqL] #

大家可以看到生成配置文件很简单,我们得添加一些内容!@H_404_2@

(2). 修改配置文件@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@web MysqL] # vim my.cnf
添加内容是:
binlog- format =ROW
@H_301_65@ log-bin=master-bin.log
log-slave-updates= true
gtid-mode=on
enforce-gtid-consistency= true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync -master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server- id =1
report-port=3306
port=3306
datadir= /mydata/data
socket= /tmp/MysqL .sock
report-host=master. test .com

5. 为MysqL提供sysv服务脚本并启动服务@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@web MysqL] # cp support-files/MysqL.server /etc/init.d/MysqLd #复制sysv脚本
[root@web MysqL] # chkconfig --add MysqLd
[root@web MysqL] # chkconfig MysqLd on #开机自启动
@H_301_65@ [root@web MysqL] # chkconfig MysqLd --list
MysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web MysqL] # service MysqLd start
Starting MysqL.... SUCCESS!
[root@web MysqL] # netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID /Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 990 /sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1066 /master
tcp 0 0 :::80 :::* LISTEN 37120 /httpd
tcp 0 0 :::22 :::* LISTEN 990 /sshd
tcp 0 0 ::1:25 :::* LISTEN 1066 /master
tcp 0 0 :::3306 :::* LISTEN 37924 /MysqLd #MysqL启动成功
udp 0 0 0.0.0.0:68 0.0.0.0:* 890 /dhclient

6. 输出MysqL的man手册至man命令的查找路径@H_404_2@

1
2
[root@web MysqL] # vim /etc/man.config
MANPATH /usr/local/MysqL/man #增加这一行

7. 输出MysqL的头文件至系统头文件路径/usr/include@H_404_2@

1
2
3
[root@web MysqL] # ln -sv /usr/local/MysqL/include/ /usr/include/MysqL #输出MysqL的头文件至系统头文件
` /usr/include/MysqL ' -> `/usr/local/MysqL/include/'
[root@web MysqL] # cd /usr/include/MysqL/

8. 输出MysqL的库文件给系统库查找路径@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
[root@web MysqL] # vim /etc/ld.so.conf.d/MysqL.conf
/usr/local/MysqL/lib #直接新建编辑/etc/ld.so.conf.d/MysqL.conf文件,把MysqL的库文件路径添加进去就可以了
~
@H_301_65@ [root@web MysqL] # ldconfig �v# 让系统重新读取库文件
/usr/local/MysqL/lib :
libtcmalloc_minimal.so.0 -> libtcmalloc_minimal.so (changed)
libMysqLclient.so.18 -> libMysqLclient_r.so.18.0.0
/usr/lib64/MysqL :
libMysqLclient.so.16 -> libMysqLclient.so.16.0.0
libMysqLclient_r.so.16 -> libMysqLclient_r.so.16.0

9. 修改PATH环境变量,让系统可以直接使用MysqL的相关命令@H_404_2@

1
2
3
[root@web MysqL] # vim /etc/profile.d/MysqL.sh #添加环境变量(与添加httpd是一样的)
export PATH=$PATH: /usr/local/MysqL/bin
[root@web MysqL] # source /etc/profile #重新读取一下环境变量

10. 测试并连接MysqL@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@web MysqL] # MysqL
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
@H_301_65@ Server version: 5.6.12-log MysqL Community Server (GPL)
Copyright (c) 2000,2013,Oracle and /or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and /or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MysqL> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.02 sec)

三、编译安装PHP@H_404_2@

1. 编译安装PHP-5.4.16@H_404_2@

说明:
(1). 这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。
(2). 如果使用PHP5.3以上版本,为了链接MysqL数据库,可以指定MysqLnd,这样在本机就不需要先安装MysqLMysqL开发包了。 MysqLnd从PHP 5.3开始可用,可以编译时绑定到它(而不用和具体的MysqL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。
@H_404_2@

1
2
3
@H_301_65@ 4
# ./configure --with-MysqL=MysqLnd --with-pdo-MysqL=MysqLnd --with-MysqLi=MysqLnd
# make
# make test
@H_301_65@ # make intall

@H_404_2@

(1). 安装图片资源软件 @H_404_2@

1
[root@web PHP-5.4.16] # yum -y install gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel

(2). 安装libxml(扩展标记语言)库@H_404_2@

1
[root@web PHP-5.4.16] # yum -y install libxml2 libxml2-devel

(3). 安装bzip2压缩库@H_404_2@

1
[root@web PHP-5.4.16] # yum install -y bzip2 bzip2-devel

(4). 安装mcrypt加密库@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
[root@web src] # rpm -ivh libmcrypt-2.5.8-4.3.x86_64.rpm
warning: libmcrypt-2.5.8-4.3.x86_64.rpm: Header V3 DSA /SHA1 Signature,key ID 04b8b50a: NOKEY
Preparing... ########################################### [100%]
@H_301_65@ 1:libmcrypt ########################################### [100%]
[root@web src] # rpm -ivh libmcrypt-devel-2.5.8-4.3.x86_64.rpm
warning: libmcrypt-devel-2.5.8-4.3.x86_64.rpm: Header V3 DSA /SHA1 Signature,key ID 04b8b50a: NOKEY
Preparing... ########################################### [100%]
1:libmcrypt-devel ########################################### [100%]
[root@web src] #

(5). 编译PHP 5.4.16@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[root@web PHP-5.4.16] # tar -xf PHP-5.4.16.tar.gz
[root@web PHP-5.4.16] # cd PHP-5.4.16
[root@web PHP-5.4.16] # ./configure --prefix=/usr/local/PHP --with-MysqL=/usr/local/MysqL --with-openssl --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --enable-mbstring --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/PHP.d --with-bz2 --enable-maintainer-zts
@H_301_65@ --with-MysqL= /usr/local/MysqL MysqL相关
--with-openssl :让其能够支持openssl功能
--with-MysqLi= /usr/local/MysqL/bin/MysqL_config :MysqL的另外一个接口,让MysqLPHP交互的接口;接口程序是MysqL_config,是个二进制程序
-- enable -mbstring :多字节string,支持中文或者是非一个字节能够表示的语言
--with-gd : 支持gd库
--with-freetpye- dir 支持freetype功能,freetype:自由的可移植的字体库,可以实现去引用特定字体的
--with-jpeg- dir 支持jpeg图片
--with-png- dir 支持png图片
--with-zlib:互联网上常用的,通用格式的压缩库,让数据文件先压缩再传送给客户端
--with-libxml- dir :xml(扩展标记语言),现在的很多系统在实现数据交互的时候,都要基于xml来实现,所以要PHP支持xml,并且让其知道其库文件所在位置
-- enable -sockets:让PHP支持基于套接字的通信
--with-apxs2:基于apxs实现让PHP编译成apace模块
--with-mcrypt:支持加密功能的,额外的加密库
--with-config- file -path :PHP配置文件的路径放在了什么地方 主配置文件PHP.ini
--with-config- file -scan :主配置文件的片段,也是配置文件,这个路径下以.ini结尾的都是配置文件片段
--with-bz2 :压缩库
-- enable -maintainer-zts :这一项的使用取决于apache是什么类型的,apache使用的是prefork就不需要;如果使用的是event或者是worker就要添加这一项;apache以线程工作就必须编译这一项
Generating files
configure: creating . /config .status
creating main /internal_functions .c
creating main /internal_functions_cli .c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License,available in this |
| distribution in the file LICENSE. By continuing this installation |
| process,you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license,you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating PHP5.spec
config.status: creating main /build-defs .h
config.status: creating scripts /PHPize
config.status: creating scripts /man1/PHPize .1
config.status: creating scripts /PHP-config
config.status: creating scripts /man1/PHP-config .1
config.status: creating sapi /cli/PHP .1
config.status: creating main /PHP_config .h
config.status: executing default commands
#编译完成
[root@web PHP-5.4.16] # make && make install
Installing PHP SAPI module: apache2handler
/usr/local/apache/build/instdso .sh SH_LIBTOOL= '/usr/local/apr/build-1/libtool' libPHP5.la /usr/local/apache/modules
/usr/local/apr/build-1/libtool --mode= install install libPHP5.la /usr/local/apache/modules/
libtool: install : install .libs /libPHP5 .so /usr/local/apache/modules/libPHP5 .so
libtool: install : install .libs /libPHP5 .lai /usr/local/apache/modules/libPHP5 .la
libtool: install : warning: remember to run `libtool --finish /root/src/PHP-5 .4.16 /libs '
chmod 755 /usr/local/apache/modules/libPHP5 .so
[activating module `PHP5' in /etc/httpd/httpd .conf]
Installing PHP CLI binary: /usr/local/PHP/bin/
Installing PHP CLI man page: /usr/local/PHP/PHP/man/man1/
Installing PHP CGI binary: /usr/local/PHP/bin/
Installing build environment: /usr/local/PHP/lib/PHP/build/
Installing header files: /usr/local/PHP/include/PHP/
Installing helper programs: /usr/local/PHP/bin/
program: PHPize
program: PHP-config
Installing man pages: /usr/local/PHP/PHP/man/man1/
page: PHPize.1
page: PHP-config.1
Installing PEAR environment: /usr/local/PHP/lib/PHP/
[PEAR] Archive_Tar - installed: 1.3.11
[PEAR] Console_Getopt - installed: 1.3.1
warning: pear /PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)
warning: pear /PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
[PEAR] PEAR - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/PHP/etc/pear .conf
You may want to add: /usr/local/PHP/lib/PHP to your PHP.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.1
/root/src/PHP-5 .4.16 /build/shtool install -c ext /phar/phar .phar /usr/local/PHP/bin
ln -s -f /usr/local/PHP/bin/phar .phar /usr/local/PHP/bin/phar
Installing PDO headers: /usr/local/PHP/include/PHP/ext/pdo/
[root@web PHP-5.4.16] #

#安装完成@H_404_2@

(6). 为PHP提供配置文件@H_404_2@

查看配置文件@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
[root@web PHP-5.4.16] # ls | grep PHP.ini
PHP.ini-development
PHP.ini-production
@H_301_65@ [root@web PHP-5.4.16] #
PHP.ini-development :用于开发环境
PHP.ini-production :用于生产环境:把这项复制到 /etc/ 目录下重命名PHP.ini即可;不需要启动服务,因为已经编译成apache模块了;是否启动服务要看工作模型,当做成fastcgi要启动服务
[root@web PHP-5.4.16] # cd PHP-5.4.16
[root@web PHP-5.4.16] # cp PHP.ini-production /etc/PHP.ini

(在编译的时候已经指定了配置文件的路径,所以PHP自动到/etc/目录下去找其配置文件)@H_404_2@

四、整合Apache与PHP@H_404_2@

1. 编辑apache配置文件httpd.conf,以apache支持PHP@H_404_2@

(1). 首先要在apache配置文件中定义,使apache能够处理PHP结尾的文件,全文查找AddType字段,添加一下内容@H_404_2@

1
2
3
@H_301_65@ 4
[root@web PHP-5.4.16] # vim /etc/httpd/httpd.conf
AddType application /x-httpd-PHP .PHP
AddType application /x-httpd-PHP-source .PHPs
@H_301_65@ PHPIniDir "/usr/local/PHP"

(2). 定位至DirectoryIndex index.html修改为:
@H_404_2@

1
DirectoryIndex index.PHP index.html

@H_404_2@

2. 重启apache并测试@H_404_2@

1
2
3
@H_301_65@ 4
[root@web PHP-5.4.16] # service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
@H_301_65@ [root@web PHP-5.4.16] #

3. 增加测试文件 @H_404_2@

1
2
3
@H_301_65@ 4
[root@web PHP-5.4.16]# vim /usr/local/apache/htdocs/test.PHP
<?
PHPinfo();
@H_301_65@ ?>

@H_404_2@

4. 测试效果@H_404_2@

效果2

5. 问题@H_404_2@

在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个错!@H_404_2@

执行PHPinfo();时提示:@H_404_2@

1
Warning: PHPinfo(): It is not safe to rely on the system 's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning,you most likely misspelled the timezone identifier. We selected the timezone ' UTC' for now,but please set date .timezone to select your timezone. in /usr/local/apache/htdocs/test .PHP on line 2

解决办法有三种:@H_404_2@

(1). 在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');@H_404_2@

1
2
3
@H_301_65@ 4
5
[root@web PHP-5.4.16] # vim /usr/local/apache/htdocs/test.PHP
<?
date_default_timezone_set( "PRC" );
@H_301_65@ PHPinfo();
?>

@H_404_2@

(2). 在页头使用 ini_set('date.timezone','Asia/Shanghai');@H_404_2@

(3). 修改PHP.ini。打开PHP.ini查找date.timezone 去掉前面的分号修改成为:date.timezone ="PRC" PRC注意加上双引号,要不还会出错!@H_404_2@

1
2
[root@web PHP-5.4.16] # vim /etc/PHP.ini
date .timezone = "PRC"

五、安装Xcache加速器@H_404_2@

1. 为PHP添加xcache功能@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
[root@web src] # tar -xf xcache-3.0.3.tar.gz
[root@web src] # cd xcache-3.0.3
[root@web xcache-3.0.3] # /usr/local/PHP/bin/PHPize
@H_301_65@ Configuring for :
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
[root@web xcache-3.0.3] #

2. 编译安装Xcache 3.0.3@H_404_2@

1
2
3
@H_301_65@ 4
5
[root@web xcache-3.0.3] # ./configure --enable-xcache --with-PHP-config=/usr/local/PHP/bin/PHP-config
[root@web xcache-3.0.3] # make && make install
编译完成,让PHP支持xcache功能前提要把xcache的配置信息添加PHP配置文件
@H_301_65@ Installing shared extensions: /usr/local/PHP/lib/PHP/extensions/no-debug-zts-20100525/
[root@web xcache-3.0.3] #

3. 编辑PHP.ini,整合PHP和xcache@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
9
10
11
[root@web xcache-3.0.3] # mkdir /etc/PHP.d
[root@web xcache-3.0.3] # cp xcache.ini /etc/PHP.d/ #也可以直接把xcache.ini配置信息直接追加到PHP.ini配置文件
[root@web xcache-3.0.3] # ls /etc/PHP.d/
@H_301_65@ xcache.ini
[root@web xcache-3.0.3] # vim /etc/PHP.d/xcache.ini #
接下来编辑 /etc/PHP .d /xcache .ini,找到zend_extension开头的行,修改为如下行:
[xcache-common]
;; non-Windows example:
extension = /usr/local/PHP/lib/PHP/extensions/no-debug-zts-20100525/xcache .so #修改这一行
;; Windows example:
; extension = PHP_xcache.dll

4. 重启apache并测试@H_404_2@

1
2
3
@H_301_65@ 4
[root@web xcache-3.0.3] # service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
@H_301_65@ [root@web xcache-3.0.3] #

效果3

说明:测试可以使用windows主机访问linux主机IP,查看PHP.info中是否有xcache模块相关信息 @H_404_2@

六、启用服务器状态@H_404_2@

说明:@H_404_2@

mod_status模块可以让管理员查看服务器的执行状态,它通过一个HTML页面展示了当前服务器的统计数据。这些数据通常包括但不限于:
(1) 处于工作状态的worker进程数;
(2) 空闲状态的worker进程数;
(3) 每个worker的状态,包括此worker已经响应的请求数,及由此worker发送的内容的字节数;
(4) 当前服务器总共发送的字节数;
(5) 服务器自上次启动或重启以来至当前的时长;
(6) 平均每秒钟响应的请求数、平均每秒钟发送的字节数、平均每个请求所请求内容的字节数;@H_404_2@

启用状态页面方法很简单,只需要在主配置文件添加如下内容即可:@H_404_2@

1
2
3
@H_301_65@ 4
5
[root@web xcache-3.0.3] # vim /etc/httpd/httpd.conf
<Location /server-status >
SetHandler server-status
@H_301_65@ Require all granted
< /Location >

需要提醒的是,这里的状态信息不应该被所有人随意访问,因此,应该限制仅允许某些特定地址的客户端查看。比如使用Require ip 172.16.0.0/16来限制仅允许指定网段的主机查看此页面 。@H_404_2@

效果图:@H_404_2@

效果4

七、PHP连接MysqL测试@H_404_2@

(1). 编辑apache的默认页面/usr/local/apache/htdocs/test.PHP@H_404_2@

1
2
3
@H_301_65@ 4
5
6
7
8
[root@web xcache-3.0.3] # vim /usr/local/apache/htdocs/test.PHP
<?
$conn=MysqL_connect( 'localhost' , 'root' , '' );
@H_301_65@ if ($conn)
echo "Success" ;
else
echo "Failure" ;
?>

(2). 测试@H_404_2@

效果5

连接成功!@H_404_2@

八、安装Discuz论坛(Discuz_X3.0_SC_GBK最新版)@H_404_2@

(1). 授权主机对MysqL的访问@H_404_2@

1
2
3
@H_301_65@ 4
MysqL> GRANT ALL PRIVILEGES ON *.* TO 'root' @ '192.168.%.%' IDENTIFIED BY '123456' ;
Query OK,0 rows affected (0.03 sec)
MysqL> FLUSH PRIVILEGES;
@H_301_65@ Query OK,0 rows affected (0.02 sec)

(2). 准备Discuz 3.0@H_404_2@

1
2
[root@web src] # unzip Discuz_X3.0_SC_GBK.zip
[root@web src] # mv upload/* /usr/local/apache/htdocs/

(3). 安装@H_404_2@

1


(4). 修改权限 @H_404_2@

2

1
2
[root@web htdocs] # chmod 777 ./data ./config/ ./data/cache/ ./data/avatar/ ./data/plugindata/ ./data/download/ ./data/addonmd5/ ./data/template/ ./ data/threadcache/ ./data/attachment/ ./data/attachment/album/ ./data/attachment/forum/ ./data/attachment/group/ ./data/log/ ./uc_client/data/cache/ ./uc_server/data ./uc_server/data/avatar/ ./uc_server/data/backup/ ./uc_server/data/logs/ ./uc_server/data/tmp/ ./uc_server/data/view/ ./uc_server/data/cache/
[root@web htdocs] #

修改效果如下:@H_404_2@

image

(5). 选择全新安装 @H_404_2@

4


(6). 配置数据库文件@H_404_2@

5

(7). 安装完成@H_404_2@

6

(8). 最终效果@H_404_2@

7


所有演示全部完成 !@H_404_2@

猜你在找的CentOS相关文章