httpd 2.4.9 + mysql-5.5.33 + php-5.4.26编译安装过程:
1、安装httpd
配置好yum源vim /etc/yum.repo/centos.repo,这里的baseurl是根据实际配置的yum仓库设定的
[DVD1]
name=centos-DVD1
baseurl=http://172.16.0.1/cobbler/ks_mirror/CentOS-6.6-x86_64/
enabled=1
gpgcheck=0
[DVD2]
name=centos-DVD2
baseurl=http://172.16.0.1/centos/6/extras/x86_64/
enabled=1
gpgcheck=0
[epel]
name=centos-epel
baseurl=http://172.16.0.1/fedora-epel/6/x86_64/
enabled=1
gpgcheck=0
[base]
name=centos-base
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0
下载安装包:(这里是我的下载路径)
lftp 172.16.0.1
cd pub/Sources/sources/httpd/
mget apr-1.5.0.tar.bz2apr-util-1.5.3.tar.bz2 httpd-2.4.9.tar.bz2
bye
编译安装httpd时,为了省事,我写了个脚本vim install-httpd.sh
#!/bin/bash
#mount cdrom
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
yum clean all
yum repolist
#install gcc
yum groupinstall "DevelopmentTools" "Server Platform Development" -y
#download installation package
lftp 172.16.0.1
cd pub/Sources/sources/httpd/
mget apr-1.5.0.tar.bz2apr-util-1.5.3.tar.bz2 httpd-2.4.9.tar.bz2
bye
#apr install
tar xf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install
cd
#apr-util install
tar xf apr-util-1.5.3.tar.bz2
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr
make && make install
cd
#httpd install
yum install pcre-devel -y
tar xf httpd-2.4.9.tar.bz2
cd httpd-2.4.9
./configure --prefix=/usr/local/apache--sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi--enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util--enable-modules=most --enable-mpms-shared=all --with-mpm=event
make && make install
运行此脚本bash install-httpd.sh
运行完,进入如下步骤:
添加环境变量vim /etc/profile.d/httpd.sh
加入export PATH=/usr/local/apache/bin:$PATH
重读配置文件. /etc/profile.d/httpd.sh
导出头文件 ln –sv /usr/local/apache/include/ /usr/include/httpd
导出man手册
vim /etc/man.config
加入MANPATH /usr/local/apache/man
编译vim /etc/httpd24/httpd.conf
添加PidFile "/var/run/httpd.pid"
设置启动脚本
cp /etc/init.d/httpd /etc/init.d/httpd24
vim /etc/init.d/httpd24
修改以下三项:
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/var/run/httpd.pid}
hash –r
而后为此脚本赋予执行权限:
chmod +x /etc/rc.d/init.d/httpd24
加入服务列表:
chkconfig --add httpd
尝试启动httpd服务
2、安装MYSQL
新建一个逻辑卷fdisk /dev/sda
执行2-3遍partx –a /dev/sda强制加载
创建LVM
格式化mke2fs /dev/myvg/mydata
创建mydata目录 mkdir mydata
挂载mydata到mydata目录下 vim /etc/fstab
添加最后一行
自动挂载mount –a; mount
下载mariadb-5.5.43-linux-x86_64.tar.gz
接下来在root目录下做了个脚本vim install-mysql.sh,执行就可以
#!/bin/bash
mkdir /mydata/data -pv
#useradd
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin -M -d/mydata/data mysql
chown -R mysql:mysql /mydata/data
#initialize
tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local
cd /usr/local/
ln -sv mariadb-5.5.43-linux-x86_64 mysql
cd mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql--datadir=/mydata/data
chown -R root .
cd /usr/local/mysql
cp support-files/my-large.cnf /etc/my.cnf
修改my.cnf中的配置vim /etc/my.cnf:
thread_concurrency = 8
添加:datadir = /mydata/data
Innodb_file_per_table = on
为mysql提供sysv服务脚本:
cd /usr/local/mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
添加至服务列表:
chkconfig --add mysqld
chkconfig mysqld on
测试启动:
为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要进行如下步骤:
输出mysql的man手册至man命令的查找路径:
vim /etc/man.config,添加如下行即可:
MANPATH /usr/local/mysql/man
输出mysql的头文件至系统头文件路径/usr/include:
ln -sv /usr/local/mysql/include /usr/include/mysql
输出mysql的库文件给系统库查找路径:
echo ‘/usr/local/mysql/lib‘ >/etc/ld.so.conf.d/mysql.conf
而后让系统重新载入系统库:
Ldconfig
修改环境变量
vim /etc/profile.d/mysql.sh
添加export PATH=/usr/local/mysql/bin:$PATH
3、安装PHP
下载php-5.4.26.tar.bz2
编辑脚本vim install-php.sh
#!/bin/bash
mount /dev/cdrom /media/cdrom
yum -y groupinstall"Desktop Platform Development"
yum -y install bzip2-devellibmcrypt-devel
tar xf php-5.4.26.tar.bz2
cd php-5.4.26
./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
make
make test
make install
cp php.ini-production/etc/php.ini
运行后
编辑apache配置文件httpd.conf,以apache支持php
vim /etc/httpd/httpd.conf
定位至AddTypt处添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
至此基本完成
测试php,vim /usr/local/apache/htdocs/index.php
<?php
$link = mysql_connect(‘127.0.0.1‘,‘root‘);
if ($link)
echo "Success...";
else
echo "Failure...";
mysql_close();
?>
在浏览器中输入地址访问,出现Success...则为成功。
安装过程中如缺少组件,按照提示进行下载安装即可,变则通。
以上过程一句老师所讲逐步完成,各个阶段均测试无问题,如有纰漏,望指正。
建议每安装好一个程序包时记得做快照,方便反复练习。