设为首页 收藏本站
查看: 1839|回复: 1

编译安装LAMP环境 (httpd2.4.4、mysql5.5、php5.4)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-2-22 09:11:22 | 显示全部楼层 |阅读模式
MySQL服务器维护了两类变量:
    服务器变量:
       定义MySQL服务器运行特性
       SHOW GLOBAL VARIABLES [LIKE 'STRING'];
    状态变量:
       保存了MySQL服务器运行统计数据
       SHOW GLOBAL STATUS [LIKE 'STRING']

MySQL通配符:
    _: 匹配任意单个字符
    %:匹配任意长度的任意字符

Httpd 2.4新特性:
1、MPM可于运行时装载: --enable-mpms-shared=all --with-mpm=event  编译安装是指定MPM运行模块为event  
2、Event MPM 支持event新的多路处理模块
3、异步读写

4、在每模块及每目录上指定日志级别
5、每请求配置: <If>,<ElseIf>,<Else>;
6、增强的表达式分析器;
7、毫秒级的Keepalive Timeout;
8、基于域名的虚拟主机不再需要NameVirtualHost指令;
9、降低了内存占用;
10、支持在配置文件中使用自定义变量;
11、对于基于IP的访问控制不再支持order all,deny allow from all
而是支持Require user
Usage:
      Require user USERNAME
      Require group GRPNAME
  Require ip IPADDR   允许该IP地址访问
  Require not ip IPADDR 拒绝该IP地址访问
    IP
    NETWORK/NETMASK
    NETWORK/LENGTH
    NET
   172.16.0.0/255.255.0.0=172.16.0.0/16=172.16
Require host HOSTNAME
  HOSTNAME : www.linux.com
  DOMAIN  :  .linux.com
允许所有主机访问:
   Require all granted
拒绝所有主机访问:
   Require all deny

--enable-modules=most
新增的模块:
mod_proxy(之前版本也有)
mod_proxy_fcgi
mod_proxy_scgi
mod_proxy_express
mod_remoteip
mod_sesslon
mod_ratelimit
mod_request
等等

通过编译安装LAMP环境:
   安装顺序:httpd --> mysql --> php --> xcache(php缓存程序)
  Linux,Apache,Mysql,Php
  以下演示安装httpd:2.4.4   php:5.4.13  Mysql:5.5(通用二进制格式,解压后即可使用)

-----------------------------------------------------------------------------------

1、 安装httpd 2.4.4需安装高版本的apr1.4以上的版本 apr-util1.4版本以上
-----------------------------------------------------------------------------------


1.1. 需要下载更高版本的arp和apr-util,但是原来的安装程序不能卸载,因为他们被其他程序依赖
需通过编译安装在其他目录下即可。

[iyunv@lamp ~]# rpm -q apr
apr-1.2.7-11.el5_3.1
[iyunv@lamp ~]# rpm -q apr-util
apr-util-1.2.7-11.el5_3.2



1.2. 把apr和apr-util安装在/usr/local目录下,这个目录为第三方软件安装目录:
[iyunv@lamp ~]# ls

anaconda-ks.cfg   apr-util-1.4.1.tar.bz2  install.log   
apr-1.4.6.tar.gz httpd-2.4.4.tar.gz      install.log.syslog

安装顺序:apr-1.4.6 --> apr-util-1.4.1 --> httpd-2.4.4
   


1.3. 安装前需确认开发环境组是否安装:Development Tools(开发工具)和Development Libraries(开发库)
[iyunv@lamp ~]# yum groupinstall "Development Tools"
Install     54 Package (s)

Total download size: 57M
Is this OK [y/N]: y

[iyunv@lamp ~]# yum groupinstall "Development Libraries"
Install     56 Package (s)

Total download size:40M
Is this OK [y/N]: y

1.4. 编译安装apr  apr-util httpd

[iyunv@lamp ~]# tar -xf apr-1.4.6.tar.gz            
[iyunv@lamp ~]# tar -xf apr-util-1.4.1.tar.bz2
[iyunv@lamp ~]# tar -xf httpd-2.4.4.tar.gz
[iyunv@lamp ~]# ls
anaconda-ks.cfg   apr-util-1.4.1     install.log  apr-1.4.6        
apr-util-1.4.1.tar.bz2  apr-1.4.6.tar.gz  httpd-2.4.4.tar.gz    httpd-2.4.4   

[iyunv@lamp ~]# cd apr-1.4.6
[iyunv@lamp apr-1.4.6]# ./configure --prefix=/usr/local/apr  #编译安装前,
                               --prefix指定编译安装路径      
[iyunv@lamp apr-1.4.6]# make

[iyunv@lamp apr-1.4.6]# make install  #至此编译安装apr完成(删除编译安装的软件,只需要把安装目录删除即可)
[iyunv@lamp apr-1.4.6]# cd ../apr-util-1.4.1
[iyunv@lamp apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr  #编译安装apr-util需通过--prefix指定安装目录,以及--with-apr指定apr的安装路径。(必须2者都指定) 至此apr-util-1.4.1安装成功
[iyunv@lamp apr-util-1.4.1]# cd ../httpd-2.4.4

[iyunv@lamp httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  #编译安装httpd需指定安装目录--prefix,主配置文件目录--sysconfdir
还需开通很多功能,--enable-so等功能,且必须指定apr和apr-util编译安装的位置。

checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/  #这里报错提示pcre-config没有安装,需安装pcre-devel
[iyunv@lamp httpd-2.4.4]# yum install pcre-devel       #安装pcre-devel
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Server                                  | 3.7 kB     00:00
...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:7.8-3.1.el6 set to be updated
--> Finished Dependency Resolution
......
Running Transaction
  Installing     : pcre-devel-7.8-3.1.el6.x86_64                1/1
Installed:
  pcre-devel.x86_64 0:7.8-3.1.el6                              
Complete!
[iyunv@lamp httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util    #再重新执行一次编译
.......
checking for OpenSSL... checking for user-provided OpenSSL base directory... none
checking for OpenSSL version >= 0.9.7... FAILED  #提示openssl version 错误,解决方法
                            安装openssl-devel
configure: WARNING: OpenSSL version is too old  
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
[iyunv@lamp httpd-2.4.4]# yum install openssl-devel  #安装openssl-devel
[iyunv@lamp httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util    #再重新执行一次编译

.........
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands   #直到编译安装不再出现报错可以继续执行make
[iyunv@lamp httpd-2.4.4]# make  #./configure 编译报错都解决后,make和make一般都会成功
[iyunv@lamp httpd-2.4.4]# make install
......

Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/httpd-2.4.4'  #至此httpd编译安装完成

1.5. 启动httpd前需把selinux关闭,否则无法启动:
[iyunv@lamp httpd-2.4.4]# getenforce #查看selinux当前状态
Enforcing
[iyunv@lamp httpd-2.4.4]# setenforce 0  #临时关闭selinux,重启失效。      
[iyunv@lamp httpd-2.4.4]# vim /etc/selinux/config #编辑selinux配置文档,使设置永久有效
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive  #这项改成permissive或者disabled(建议改成permissive)
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[iyunv@lamp httpd-2.4.4]# getenforce
Permissive   #状态变为permissive

[iyunv@lamp httpd-2.4.4]# cd /usr/local/apache
[iyunv@lamp apache]# ls
bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

[iyunv@lamp apache]# /usr/local/apache/bin/apachectl start #测试启动apache服务
[iyunv@lamp apache]# netstat -tlnp #查看监听的端口号     

tcp    0     0 :::111         :::*         LISTEN      1325/rpcbind      
tcp    0    0 :::80           :::*        LISTEN      14655/httpd


1.6. 至此httpd服务就启动了,通过客户端访问ip即可
wKioL1ikETSQ4jYfAAFC8dnKxII098.jpg
1.7. 修改httpd.conf配置文档使得httpd.pid(httpd进程启动生成的文档,服务关闭后文档消失)文档生成路径修改为/var/run/httpd.pid,
[iyunv@lamp apache]# /usr/local/apache/bin/apachectl stop  #停止httpd服务
[iyunv@lamp apache]# vim /etc/httpd/httpd.conf #配置文件路径为编译安装httpd的时候设置的路径
..........
# least PidFile.
#
ServerRoot "/usr/local/apache"
PidFile "/var/run/httpd.pid" #新增此行内容(必须先停止httpd服务)
.........
验证:

[iyunv@localhost apache]# ls logs/
access_log  error_log
[iyunv@localhost apache]# ls /var/run/
acpid.socket      console    haldaemon.pid   NetworkManager  rpc.statd.pid   sshd.pid        xinetd.pid
atd.pid           crond.pid
httpd.pid       nscd            saslauthd       sudo
audispd_events    cups       klogd.pid       pcscd.comm      sdp             syslogd.pid
...



1.8. 为了使得httpd可以通过service httpd stop|start|restart管理方式,需在/etc/init.d/新建一个脚本httpd启动脚本如下:
[iyunv@lamp apache]# vim /etc/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 server
#        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
               kellproc -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



[iyunv@lamp apache]# chmod +x /etc/init.d/httpd   #赋予执行权限
[iyunv@lamp apache]# service httpd restart  #通过启用服务方式成功重新启动httpd服务
停止 httpd:                                           [确定]
正在启动 httpd:                                        [确定]
[iyunv@lamp apache]# chkconfig --add httpd #把httpd服务添加到开机启动列表中
[iyunv@lamp apache]# chkconfig --list  #查看开机启动列表
httpd       0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭  #默认开机不启动


指定chkconfig --level 35 httpd on设定服务在级别35开机启动

[iyunv@lamp apache]# chkconfig --level 35 httpd on

httpd       0:关闭1:关闭2:启用3:启用4:关闭5:启用6:关闭 #默认开机启动

[iyunv@lamp apache]# cd
[iyunv@lamp ~]# vim /etc/profile.d/httpd.sh  #把/usr/local/httpd/bin执行脚本命令路径放置在PATH变量中,使得该路径中的命令可以直接执行。
export PATH=$PATH:/usr/local/apache/bin #增加该行内容


然后重新登录下系统,/usr/local/apache/bin中的命令都可以直接执行,而不用加路径
[iyunv@lamp ~]# httpd -t   #检查httpd配置文件是否有语法错误
Syntax OK

[iyunv@lamp ~]# echo $PATH
/usr/lib64/qt3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/apache/bin:/root/bin   #已经把/usr/local/apache/bin目录加到了PATH变量中
[iyunv@lamp ~]# vim /etc/httpd/httpd.conf  #修改主配置文档中下面2行内容
#LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so



wKioL1ilD0uzju7nAAYcFsfxVjk533.jpg [iyunv@lamp ~]# httpd -t
Syntax OK
[iyunv@lamp ~]# service httpd restart
停止 httpd:                                           [确定]
正在启动 httpd:                                        [确定]
[iyunv@lamp ~]# httpd -M   #查看当前启用的模块
Loaded Modules:
.......
headers_module (shared)
setenvif_module (shared)
version_module (shared)
mpm_prefork_module (shared)  #默认模块已经修改为prefork模块了(以后需要切换其他模块只需                          要修改主配置文档中上一步骤的内容即可)
unixd_module (shared)
status_module (shared)
........




-----------------------------------------------------------------------------------

2、开始安装mysql5.5.54版本
-----------------------------------------------------------------------------------




[iyunv@lamp ~]# ls
httpd-2.4.4  mysql-5.5.54-linux2.6-x86_64.tar.gz
[iyunv@lamp ~]# tar xf mysql-5.5.54-linux2.6-x86_64.tar.gz -C /usr/local  #-C 指定解压目录
[iyunv@lamp ~]# cd /usr/local
[iyunv@lamp local]# ls
apache  apr-util  etc    include   lost+found  mysql-5.5.54-linux2.6-x86_64

[iyunv@lamp local]# ln -sv mysql-5.5.54-linux2.6-x86_64 mysql #创建软链接mysql
"mysql" -> "mysql-5.5.54-linux2.6-x86_64"
[iyunv@lamp local]# ls
apache  apr-util  etc    include  lib64   mysql-5.5.54-linux2.6-x86_64
apr     bin      games  lib     libexec   mysql
[iyunv@lamp local]# cd mysql
[iyunv@lamp mysql]# groupadd -r -g 306 mysql  #-r指创建系统组,-g指定组ID
[iyunv@lamp mysql]# useradd -r -g 306 -u 306 mysql #-r创建系统用户(不能登录系统的用户)
                                     -u指定UID
[iyunv@lamp mysql]# id mysql  #查看用户信息,UID GID
uid=306(mysql) gid=306(mysql) 组=306(mysql)
[iyunv@lamp mysql]# ls /home
donggen  

[iyunv@lamp mysql]# ll
总用量 72
drwxr-xr-x.  2 root root   4096  2月 17 09:33 bin
-rw-r--r--.  1 7161 31415 17987 11月 28 20:32 COPYING
...
[iyunv@lamp mysql]# chown -R mysql.mysql /usr/local/mysql/*  
#  -R递归把mysql目录下的所有文档或目录都修改为mysql用户和mysql组
[iyunv@lamp mysql]# ll
总用量 72
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 bin
-rw-r--r--.  1 mysql mysql 17987 11月 28 20:32 COPYING
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 data
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 docs
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 include
-rw-r--r--.  1 mysql mysql   301 11月 28 20:32 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 lib
drwxr-xr-x.  4 mysql mysql  4096  2月 17 09:33 man
drwxr-xr-x. 10 mysql mysql  4096  2月 17 09:34 mysql-test
-rw-r--r--.  1 mysql mysql  2496 11月 28 20:32 README
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 scripts
drwxr-xr-x. 27 mysql mysql  4096  2月 17 09:33 share
drwxr-xr-x.  4 mysql mysql  4096  2月 17 09:33 sql-bench
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 support-files
[iyunv@lamp mysql]#


** 由于mysql数据库随着时间的增长,数据会越来越大,所以应该把数据库数据放置在一个单独的可扩展的分区卷上,以便后期管理和备份,挂载在逻辑卷是比较好的方法如下:

[iyunv@lamp ~]# fdisk /dev/sdb  #新建分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xef7e9b34.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
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: 0xef7e9b34

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G

Command (m for help): T
Selected partition 1
Hex code (type L to list codes): 8e  
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
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: 0xef7e9b34

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1306    10490413+  8e Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[iyunv@lamp ~]# partprobe /dev/sdb  #通知内核重读sdb分区
[iyunv@lamp ~]# pvcreate /dev/sdb1   #先把/dev/sdb1分区建立一个pv物理卷
  Physical volume "/dev/sdb1" successfully created
[iyunv@lamp ~]# pvs  #查看物理卷
  PV         VG   Fmt  Attr PSize  PFree
  /dev/sdb1       lvm2 a-   10.00g 10.00g
[iyunv@lamp ~]# vgcreate myvg /dev/sdb1   #以/dev/sdb1分区创建myvg卷组
  Volume group "myvg" successfully created
[iyunv@lamp ~]# vgs  #查看卷组
  VG   #PV #LV #SN Attr   VSize  VFree
  myvg   1   0   0 wz--n- 10.00g 10.00g
[iyunv@lamp ~]# lvcreate -n mydata -L 5G myvg  #在卷组myvg中建立一个大小为5G,
                                 名称为mydata 的逻辑卷
  Logical volume "mydata" created

[iyunv@lamp ~]# lvs    #查看逻辑卷  
  LV     VG   Attr   LSize Origin Snap%  Move Log Copy%  Convert
  mydata myvg -wi-a- 5.00g     

[iyunv@lamp ~]# mke2fs -t ext4 /dev/myvg/mydata   #格式化mydata逻辑卷
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

正在写入inode表: 完成                           
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[iyunv@lamp ~]# mkdir /mydata   #建立一个目录作为挂载点
[iyunv@lamp ~]# vim /etc/fstab    #设定逻辑卷开机自动挂载

# /etc/fstab

# Created by anaconda on Tue Feb 14 01:11:01 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#

tmpfs          /dev/shm       tmpfs   defaults      0 0
devpts          /dev/pts       devpts  gid=5,mode=620  0 0
sysfs          /sys         sysfs   defaults       0 0
proc           /proc        proc    defaults       0 0
/dev/myvg/mydata   /mydata    ext4    defaults        0 0  #新增该行内容

[iyunv@lamp ~]# mount -a    #重读/etc/fstab硬盘挂载文件,使得新增的分区挂载成功
[iyunv@lamp ~]# mount  #查看已经挂载的分区
/dev/mapper/myvg-mydata on /mydata type ext4 (rw)  #逻辑卷mydata已经挂载到/mydata目录

[iyunv@lamp ~]# mkdir /mydata/data
[iyunv@lamp ~]# ll /mydata
总用量 20
drwxr-xr-x. 2 root root  4096  2月 17 17:30 data
drwx------. 2 root root 16384  2月 17 15:11 lost+found
[iyunv@lamp ~]# chown -R mysql.mysql /mydata/data/  #更改文件夹属主和属组-R递归
[iyunv@lamp ~]# ll /mydata
总用量 20
drwxr-xr-x. 2 mysql mysql  4096  2月 17 17:30 data
drwx------. 2 root  root  16384  2月 17 15:11 lost+found
[iyunv@lamp ~]# chmod o-rx /mydata/data/   #删除/data组其他人的读和执行权限
[iyunv@lamp ~]# ll /mydata
总用量 20
drwxr-x---. 2 mysql mysql  4096  2月 17 17:30 data
drwx------. 2 root  root  16384  2月 17 15:11 lost+found
[iyunv@lamp ~]# cd /usr/local/mysql
[iyunv@lamp mysql]# pwd
/usr/local/mysql

[iyunv@lamp mysql]#scripts/mysql_install_db --user=mysql --datadir=/mydata/data/  

#初始化mysql,以mysql用户,且数据目录需修改为/mydata/data目录
Installing MySQL system tables...
.........
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 lamp.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 at http://bugs.mysql.com/  #初始化完成
[iyunv@lamp mysql]# ll  #由于mysql目录内的文件和目录都为mysql属主,很容易被破解,
所以把mysql目录内的文件和目录属主修改为root
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 bin
-rw-r--r--.  1 mysql mysql 17987 11月 28 20:32 COPYING
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 data
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 docs
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 include
-rw-r--r--.  1 mysql mysql   301 11月 28 20:32 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096  2月 17 09:33 lib
drwxr-xr-x.  4 mysql mysql  4096  2月 17 09:33 man
drwxr-xr-x. 10 mysql mysql  4096  2月 17 09:34 mysql-test
-rw-r--r--.  1 mysql mysql  2496 11月 28 20:32 README
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 scripts
drwxr-xr-x. 27 mysql mysql  4096  2月 17 09:33 share
drwxr-xr-x.  4 mysql mysql  4096  2月 17 09:33 sql-bench
drwxr-xr-x.  2 mysql mysql  4096  2月 17 09:33 support-files

[iyunv@lamp mysql]# chown -R root ./*  #-R递归更改当前目录中所有文件和目录的属主为root
[iyunv@lamp mysql]# ll
drwxr-xr-x.  2 root mysql  4096  2月 17 09:33 bin
-rw-r--r--.  1 root mysql 17987 11月 28 20:32 COPYING
drwxr-xr-x.  3 root mysql  4096  2月 17 09:33 data  #由于data数据文件夹已经修改为/mydata/data目录,所以此处不需要把属主修改为mysql,否则如果没有修改data路径需修改为mysql
drwxr-xr-x.  2 root mysql  4096  2月 17 09:33 docs
drwxr-xr-x.  3 root mysql  4096  2月 17 09:33 include
-rw-r--r--.  1 root mysql   301 11月 28 20:32 INSTALL-BINARY
drwxr-xr-x.  3 root mysql  4096  2月 17 09:33 lib
drwxr-xr-x.  4 root mysql  4096  2月 17 09:33 man
drwxr-xr-x. 10 root mysql  4096  2月 17 09:34 mysql-test
-rw-r--r--.  1 root mysql  2496 11月 28 20:32 README
drwxr-xr-x.  2 root mysql  4096  2月 17 09:33 scripts
drwxr-xr-x. 27 root mysql  4096  2月 17 09:33 share
drwxr-xr-x.  4 root mysql  4096  2月 17 09:33 sql-bench
drwxr-xr-x.  2 root mysql  4096  2月 17 09:33 support-files

[iyunv@lamp mysql]# ls support-files/
binary-configure   magic      my-medium.cnf      mysql.server(mysql的服务启动脚本)
config.medium.ini  my-innodb-heavy-4G.cnf  mysqld_multi.server
[iyunv@lamp mysql]# cp support-files/mysql.server /etc/init.d/mysqld  #把启动脚本复制到                        linux系统默认服务启动的init.d目录中,并修改名称为mysqld
[iyunv@lamp mysql]# ll /etc/init.d/mysqld  #查看mysqld是否有执行的权限
-rwxr-xr-x. 1 root root 10875  2月 18 09:21 /etc/init.d/mysqld
[iyunv@lamp mysql]# chkconfig --add mysqld  #把mysqld进程添加到开机启动列表
[iyunv@lamp mysql]# chkconfig --list mysqld #查看开机启动列表中mysqld是否设置为开机启动
mysqld         0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭



至此mysql启动进程,数据文件夹等都设置完成,接下来配置mysql的配置文档相关内容:
MYsql配置文件路径:/etc/my.cnf

/etc/my.conf  -=> /etc/mysql/my.cnf -=> /$basedir/my.cnf -=> ~/.my.cnf (以最后一个为准)




[iyunv@lamp mysql]# ll support-files/
总用量 96
-rwxr-xr-x. 1 root mysql  1153 11月 29 00:10 binary-configure
-rw-r--r--. 1 root mysql  4691 11月 29 00:10 my-huge.cnf #配置文件
-rw-r--r--. 1 root mysql 19759 11月 29 00:10 my-innodb-heavy-4G.cnf #配置文件
-rw-r--r--. 1 root mysql  4665 11月 29 00:10 my-large.cnf #配置文件
-rw-r--r--. 1 root mysql  4676 11月 29 00:10 my-medium.cnf #配置文件
-rw-r--r--. 1 root mysql  2840 11月 29 00:10 my-small.cnf #配置文件
..........
以上5个都是配置文档模板,具体使用哪个作为自己mysql为配置文件,需根据自己的内存大小定义:
内存小于64M选择small.cnf 内存128M选择medium.cnf 内存为512M选择large.cnf 内存1-2G选择
huge.cnf作为配置文件。

[iyunv@lamp mysql]# free -m  #查看内存大小,内存大小为2G,所以选择
      total    used   free    shared    buffers   cached
Mem:    2007    239    1767     0        16      71
-/+ buffers/cache:        151       1855
Swap:  1499      0    1499

[iyunv@lamp mysql]# cp support-files/my-huge.cnf /etc/my.cnf
[iyunv@lamp mysql]# vim /etc/my.cnf  #修改配置文件,红色部分为修改过的
...........
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency

thread_concurrency = 4   #修改为4,数值为CPU的个数*2
datadir = /mydata/data   #新增该行,指定数据目录为/mydata/data
至此就可以启动mysql服务了

[iyunv@lamp mysql]# service mysqld start  #启动mysqld服务
Starting MySQL.. SUCCESS!
[iyunv@lamp mysql]# service mysqld restart  #重启mysqld服务
Shutting down MySQL. SUCCESS!
Starting MySQL.. SUCCESS!
[iyunv@lamp mysql]# netstat -tlnp |grep mysqld
tcp   0   0 0.0.0.0:3306      0.0.0.0:*         LISTEN    6954/mysqld #已启动

[iyunv@lamp mysql]# mysql  #启用mysql客户端,无法启动,提示命令没发现(默认PATH变量没mysql                                      所在路径)
-bash: mysql: command not found
[iyunv@lamp mysql]# vim /etc/profile.d/mysql.sh    #新建mysql.sh把mysql的启动命令路径加到                                      PATH变量中
export PATH=$PATH:/usr/local/mysql/bin  #新增该行内容



重新登录系统后再测试mysql命令,如下:

[iyunv@lamp ~]# msyql  #成功登录到mysql客户端
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.54-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>

至此mysql已经配置完成,为了使得可以通过man命令查看mysql需修改/etc/man.conf配置文档
[iyunv@lamp ~]# vim /etc/man.config

....

MANPATH /usr/X11R6/man
MANPATH /usr/local/mysql/man    #新增该行,使得帮助文档能通过man找到
[iyunv@lamp ~]# vim /etc/ld.so.conf.d/mysql.conf #新建mysql库路径文件,使得系统能够识别到

/usr/local/mysql/lib       #新增该行内容

[iyunv@lamp ~]# ldconfig -v   #通知系统重新读取库文件,-v显示重读过程
............


libxklavier.so.15 -> libxklavier.so.15.0.0
liblcms.so.1 -> liblcms.so.1.0.19
/lib64/tls: (hwcap: 0x8000000000000000)
/usr/lib64/sse2: (hwcap: 0x0000000004000000)
/usr/lib64/tls: (hwcap: 0x8000000000000000)
[iyunv@lamp ~]# ln -sv /usr/local/mysql/include /usr/include/mysql

#创建mysql的头文件目录链接,使得可以直接输出头文件
"/usr/include/mysql" -> "/usr/local/mysql/include"
[iyunv@lamp ~]# ls /usr/include/mysql/
decimal.h   my_attribute.h  my_global.h   mysqld_ername.h  my_sys.h            
my_alloc.h  my_getopt.h     mysql_com.h   mysql_version.h  sql_common.h
--------------MySQL已经安装配置完成。





-----------------------------------------------------------------------------------

3、编译安装PHP
-----------------------------------------------------------------------------------




lftp test@10.109.134.247:/> get php-5.4.23.tar.bz2
12251671 bytes transferred in 1 second (11.10M/s)        
lftp test@10.109.134.247:/> bye      #从ftp服务器上下载php或者从文章最后地址下载
[iyunv@lamp ~]# ls
anaconda-ks.cfg   apr-util-1.4.1.tar.bz2  install.log.syslog                  
apr-1.4.6.tar.gz  httpd-2.4.4.tar.gz    php-5.4.23.tar.bz2                  
[iyunv@lamp ~]# tar xf php-5.4.23.tar.bz2
[iyunv@lamp ~]# cd php-5.4.23
[iyunv@lamp php-5.4.23]# ls
........
buildconf.bat     makedist   README.MAILINGLIST_RULES         
CODING_STANDARDS  Makefile.frag    README.namespaces                 
header   php.ini-development  README.UNIX-BUILD-SYSTEM

.......

这里为了演示event模块,所以这里需修改httpd的配置文档把模块修改为event模块
[iyunv@lamp php-5.4.23]# vim /etc/httpd/httpd.conf
.......
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so  #注释掉该行
LoadModule mpm_event_module modules/mod_mpm_event.so   #增加该行内容使用event模块
........
[iyunv@lamp php-5.4.23]# httpd -M
#查看httpd目前启用的模块类型有哪些

...........
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
mpm_event_module (shared)  #已经修改为event模块类型了
...............



[iyunv@lamp php-5.4.23]# ./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 --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  #指定安装路径,mysql安装路径,支持各种功能和接口,为了支持apache的worker和event这两个MPM多处理模块,编译时使用--enable-maintainer-zts选项,如果apache使用的是prefork模块则不需要使用该选项。
...........
checking for strftime... (cached) yes
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.  #编译是提示错误,先查询是否安装过libxml2,如果安装看是否安装了libxml2-devel


[iyunv@lamp php-5.4.23]# rpm -qa|grep libxml2  #2个主程序已经安装
libxml2-2.7.6-1.el6.x86_64   
libxml2-python-2.7.6-1.el6.x86_64

[iyunv@lamp php-5.4.23]# yum list all | grep libxml*
This system is not registered with RHN.
RHN support will be disabled.
libxml2.x86_64   2.7.6-1.el6   @anaconda-RedHatEnterpriseLinux-201009221801.x86_64/6.0
libxml2-python.x86_64  2.7.6-1.el6  @anaconda-RedHatEnterpriseLinux-
libxml2.i686     2.7.6-1.el6                       Server
libxml2-devel.i686      2.7.6-1.el6                  Server
libxml2-devel.x86_64     2.7.6-1.el6                  Server #64位系统安装
perl-libxml-perl.noarch   0.08-10.el6                  Server


[iyunv@lamp php-5.4.23]# yum install libxml2-devel.x86_64
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.x86_64 0:2.7.6-1.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
Package                    Arch                Version                    Repository           Size
=====================================================================================================
Installing:
libxml2-devel              x86_64              2.7.6-1.el6                Server              1.1 M

Transaction Summary
=====================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.1 M
Installed size: 8.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libxml2-devel-2.7.6-1.el6.x86_64                                              1/1

Installed:
  libxml2-devel.x86_64 0:2.7.6-1.el6                                   
Complete!     #libxml2-devel安装完成


*再次执行PHP编译./configure
[iyunv@lamp php-5.4.23]# ./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 --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
.........
checking for gzgets in -lz... yes
checking whether to enable bc style precision math functions... no
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution  #提示BZip2报错
[iyunv@lamp php-5.4.23]# yum list all |grep bzip2* #查询是否缺少bzip2组建
This system is not registered with RHN.
RHN support will be disabled.
bzip2.x86_64    1.0.5-6.1.el6      @anaconda-RedHatEnterpriseLinux
bzip2-libs.x86_64   1.0.5-6.1.el6    @anaconda-RedHatEnterpriseLinux
bzip2-devel.i686     1.0.5-6.1.el6           Server
bzip2-devel.x86_64   1.0.5-6.1.el6           Server   #该组建未安装
[iyunv@lamp php-5.4.23]# yum install bzip2-devel.x86_64 #安装bzip-devel组建
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bzip2-devel.x86_64 0:1.0.5-6.1.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
Package                  Arch                Version                      Repository           Size
=====================================================================================================
Installing:
bzip2-devel              x86_64              1.0.5-6.1.el6                Server              250 k

Transaction Summary
=====================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 250 k
Installed size: 412 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : bzip2-devel-1.0.5-6.1.el6.x86_64                                              1/1

Installed:
  bzip2-devel.x86_64 0:1.0.5-6.1.el6                                    
Complete!        #安装bzip2-devel成功



*再次执行PHP编译./configure
[iyunv@lamp php-5.4.23]# ./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 --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
....................
checking for alloca... (cached) yes
checking for working memcmp... yes
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.#提示libmcrypt未安装,
需安装mhash-0.9.9.2.rpm mhash-devel-0.9.2.rpm libmcrypt-2.5.7.rpm  libmcrypt-devel-2.5.7.rpm
[iyunv@lamp ~]# ls
apr-1.4.6     libmcrypt-2.5.8-9.el6.x86_64.rpm    apr-1.4.6.tar.gz      
libmcrypt-devel-2.5.8-9.el6.x86_64.rpm    mhash-0.9.9-2.3.x86_64.rpm             
apr-util-1.4.1.tar.bz2    mhash-devel-0.9.9-2.3.x86_64.rpm      
[iyunv@lamp ~]# rpm -ivh *.rpm  #安装当前目录下,所有.rpm包
warning: libmcrypt-2.5.8-9.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
warning: mhash-0.9.9-2.3.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 04b8b50a: NOKEY
Preparing...                  ########################################### [100%]
   1:mhash                  ########################################### [ 25%]
   2:libmcrypt               ########################################### [ 50%]
   3:libmcrypt-devel           ########################################### [ 75%]
   4:mhash-devel              ########################################### [100%]



*再次执行PHP编译./configure
[iyunv@lamp php-5.4.23]# ./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 --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
#需注意几个地方 --with-apxs2=/usr/local/apache/bin/apxs 这个表示把php做成httpd的模块方式即不用启动脚本的,如果需要把php做成fcgi,则该项需修改为--enable-fpm,两项不能同时使用。
.................
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 sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: main/php_config.h is unchanged
config.status: executing default commands     #至此第一步./configure完成
[iyunv@lamp php-5.4.23]# make
[iyunv@lamp php-5.4.23]# make install
.............

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/php-5.4.23/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/
至此php编译安装完成,接下来对php相关配置进行设置

[iyunv@lamp php-5.4.23]# pwd  #确认当前路径,需把编译安装路径下的配置文档复制到对应路径
/root/php-5.4.23
[iyunv@lamp php-5.4.23]# ls
acinclude.m4   INSTALL    NEWS    README.TESTING
aclocal.m4     install-sh   pear       README.TESTING2
build     libphp5.la      php5.spec      README.UNIX-BUILD-SYSTEM
buildconf     libs        php5.spec.in       README.WIN32-BUILD-SYSTEM
buildconf.bat     libtool     run-tests.php
CODING_STANDARDS  LICENSE       php.ini-development(开发环境下的php配置文件)   
php.ini-production(生产环境的php配置文件)      scripts              
[iyunv@lamp php-5.4.23]# cp php.ini-production /etc/php.ini   #复制生产环境的php配置文件到编译安装php时指定的路径--with-config-file-path=/etc中并改名

接下来就是编辑php配置文件,使得php能跟httpd结合起来工作:
[iyunv@lamp ~]# vim /etc/httpd/httpd.conf  #编辑httpd配置文档,红色部分为修改或者新增
.............
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php        #新增该行
AddType application/x-httpd-php-source .phps   #新增该行

<IfModule dir_module>
    DirectoryIndex index.php index.html    #增加支持index.php主页网页
</IfModule>
修改以上2个地方后,php就可以测试运行了。


[iyunv@lamp ~]# httpd -t  #检测httpd配置文件是否有语法错误
Syntax OK
[iyunv@lamp ~]# service httpd restart  #重启httpd服务
停止 httpd:                         [确定]
正在启动 httpd:                   [确定]
[iyunv@lamp ~]# cd /usr/local/apache/htdocs/  #进入httpd网页存放目录
[iyunv@lamp htdocs]# ls
index.html
[iyunv@lamp htdocs]# mv index.html index.php
[iyunv@lamp htdocs]# vim index.php   #编辑主页文件,内容如下,保存并退出。
<html><body><h1>It works!   test!!!</h1></body></html>
<?php
phpinfo();
?>
[iyunv@lamp htdocs]#

在客户端浏览器中测试是否php启动生效,测试结果如下,php和httpd服务关联运行了
wKiom1iqqwzSSSI5AAG8A0Up9Fk930.jpg

修改index.php文档内容,测试php是否与mysql关联运行:


[iyunv@lamp htdocs]# vim index.php   #内容如下
<html><body><h1>It works! My Apache!</h1></body></html>
<?php
$conn=mysql_connect('localhost','root','');  #('localhost'表示本地mysql主机,root为mysql                               用户名,''中间为空:表示目前用户没有设置密码)
  if ($conn)
     echo "Success....";
   else
     echo "Failure....";
?>
在客户端浏览器中测试php和mysql服务是否关联运行,测试结果如下:
mysqld服务启动时,测试结果如下:
wKioL1iqq_Kh8thRAAH1QOTYzpo927.jpg
先停止mysqld服务:
[iyunv@lamp htdocs]# service mysqld stop  #关闭mysqld服务
Shutting down MySQL.. SUCCESS!    #关闭成功
mysqld服务停止时,测试结果如下:


[iyunv@localhost xcache-2.0.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
[iyunv@localhost xcache-2.0.0]# make

[iyunv@localhost xcache-2.0.0]# make install

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/





1. apr-util-1.4.1.tar.gz下载地址:
http://download.chinaunix.net/download.php?id=36061&ResourceID=470  
2. apr-1.4.6.tar.gz下载地址:
http://download.chinaunix.net/download.php?id=37842&ResourceID=470
3. httpd-2.4.4.tar.gz下载地址:
http://download.csdn.net/download/www476907899/5208979

4. mysql-5.5.54通用二进制版本下载地址:
http://mirrors.sohu.com/mysql/MySQL-5.5/
5. php-5.4.23.tar.bz2下载地址:
http://mirrors.sohu.com/php/
6. libmcrypt-2.5.8.rpm下载地址:
http://rpm.pbone.net/index.php3/stat/4/idpl/15286582/dir/redhat_el_6/com/libmcrypt-2.5.8-9.el6.x86_64.rpm.html
7. libmcrypt-devel-2.5.8.rpm下载地址:
http://rpmfind.net/linux/rpm2html/search.php?query=libmcrypt-devel(x86-64)
8. mhash-devel-0.9.9-2.3.x86_64.rpm下载地址:
http://rpm.pbone.net/index.php3/stat/4/idpl/21892847/dir/centos_6/com/mhash-devel-0.9.9-2.3.x86_64.rpm.html
9. mhash-0.9.9-2.3.x86_64.rpm下载地址:
32b: http://rpmfind.net/linux/rpm2htm ... p;system=&arch=
64b: http://rpm.pbone.net/index.php3/ ... 2.3.x86_64.rpm.html

10. xcache-2.0.0.tar.bz2载地址:
http://xcache.lighttpd.net/pub/Releases/2.0.0/


其它下载链接 **************************************************************
1、Linux MySQL5.5源码安装http://www.cnblogs.com/ghsea/p/4264696.html
2、Linux环境下安装zend optimizerhttp://blog.sina.com.cn/s/blog_6797650b0100vzs5.html


3、ZendOptimizer-3.3.3 下载:

http://www.neatstudio.com/show-1038-1.shtml
ZendOptimizer-3.3.9 下载:
http://downloads.zend.com/optimi ... glibc23-i386.tar.gz  (32位)
http://downloads.zend.com/optimi ... ibc23-x86_64.tar.gz  (64位)
4、Zend Optimizer不支持php5.3的解决方案http://284772894.iteye.com/blog/1920685


wKiom1iqrN7TB4z-AAHDr9lHinA412.jpg

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-345483-1-1.html 上篇帖子: Linux下源码安装LAMP(CentOS 6.8 + Apache2.4 + MySQL5.5 + PHP7)环境 下篇帖子: LAMP 搭建zabbix监控Oracle 数据库 for Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表