1.编译安装httpd-2.4.10
(1)首先安装”DevelopmentTools”和“Server Platform Development”
~]# yum groupinstall -y “Development Tools” “ServerPlatform Development”
(2)安装增强版正则表达式分析器pcre-devel,以及openssl-devel,apr-devel,apr-util-devel,libevent-devel
~]# yum install -y pcre-devel openssl-devel apr-develapr-util-devel libevent-devel
(3)下载httpd-2.4.10源码包并展开。
~]# tar xvf httpd-2.4.10.tar.bz2
(4)制作makefile文件
./configure --prefix=/usr/local/apache24--sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite--enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre--with-zlib --with-apr=/usr --with-apr-util=/usr
(5)编译并安装httpd-2.4.10
~]# make && make install
~]# vim /etc/profile.d/http24.sh
exportPATH=/user/local/apache24/bin:$PATH
~]# source /etc/profile.d/http24.sh
(7)将库文件做软链接至/usr/incloud/httpd
~]# ln -sv /usr/local/apache24/incloud /use/incloud/httpd
(8)启动httpd服务
~]# apachectl start
2.安装mariadb-5.5.46
(1)将mariadb-5.5.46-tar.gz解压到/usr/local目录下
~]#tar xvf mariadb-5.5.46-tar.gz -C /usr/local
(2)为mariadb创建数据目录
~]#mkdir -pv /data/mydata
~]#chown -R MysqL:MysqL /data/mydata
(3)将解压后的目录链接至/usr/local/MysqL目录,便于以后滚动
~]#ln -sv /usr/local/mariadb-5.5.46 /usr/local/MysqL
(4)将/usr/local/MysqL目录下的所有文件属主改为root,属组改为MysqL
~]#cd /usr/local/MysqL
~]#chown -R root:MysqL ./*
(5)初始化mariadb
~]#cd /usr/local/MysqL
~]#scripts/MysqL_install_db --user=MysqL --datadir=/data/mydata
(6)编辑配置文件
~]#cp support-files/my-large.cnf/etc/my.cnf
~]#vim /etc/my.cnf
datadir=/data/mydata
innodb_file_per_table= ON
skip_name_resolve= ON
(7)启动脚本
~]#cp support-files/MysqL.server /etc/rc.d/init.d/MysqLd
~]#chmod +x /etc/rc.d/init.d/MysqLd
(8) 将mariadb相关可执行文件搜索路径导入到环境变量
~]#vim /etc/profile.d/MysqL.sh
exportPATH=/usr/local/MysqL/bin:$PATH
~]#source /etc/profile.d/MysqL.sh
(9)启动mariadb
~]#service MysqLd start
3.编译安装PHP-5.5.40
(1)安装PHP依赖的程序包,libxml2-devel,gd-devel,freetype-devel,libmcrypt-devel
~]#yum install -y libxml2-devel gd-devel freetype-devel libmcrypt-devel
(2)下载PHP-5.4.40并展开
~]#tar xvf PHP-5.4.40.tar.bz2
(3)利用configure脚本制作makefile文件
~]#cd PHP-5.4.40
~]#./configure --prefix=/usr/local/PHP54 --with-MysqL=/usr/local/MysqL--with-openssl --with-MysqLi=/usr/local/MysqL/bin/MysqL_config--enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd--with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt--with-apxs2=/usr/local/apache24/bin/apxs--with-config-file-path=/etc/PHP54.ini --with-config-file-scan-dir=/etc/PHP54.d
(4)编译并安装
~]#make && make install
(5)制作配置文件
~]#cp PHP.ini-production /etc/PHP.ini
(6)增加MIME类型
~]#vim /etc/httpd24/httpd.conf
AddTypeapplication/x-httpd-PHP .PHP
~]#vim /etc/httpd24/httpd.conf
DirectoryIndexindex.PHP index.html
4.制作测试页面进行测试
~]#mv/usr/local/apache24/htdocs/index.{html,PHP}
~]#vim/usr/local/apache24/htdocs/index.PHP
<?PHP
PHPinfo();
?>
5.测试数据库连接
(1)在MariaDB里面创建数据库testdb,创建用户testuser,并给该用户授权:
~]# MysqL
MariaDB[(none)]>CREATEDATABASE testdb;
MariaDB[(none)]>CREATEUSER ‘testuser’@’127.0.0.1’ IDENTIFIED BY ‘testpasswd’;
MariaDB[(none)]>GRANTALL ON testdb.* TO ‘testuser’@’127.0.0.1’;
MariaDB[(none)]>FLUSHPRIVILEGES;
(2)编辑默认主页文件/var/www/html/index.PHP,编写如下脚本进行测试:
<?PHP
$conn= MysqL_connect(‘127.0.0.1’,’testuesr’,’testpasswd’);
If($conn)
echo“OK”;
else
echo“Falure”;
?>
(3)在浏览器上测试
(1)在httpd主配置文件中注释掉#DocumentRoot "/usr/local/apache24/htdocs"
将Include /etc/httpd24/extra/httpd-vhosts.conf取消注释。
(2)创建两个虚拟主机www1.magedu.com和www2.mage.com
~]#mkdir -pv /vhost/www{1,2}
~]#vim /etc/httpd24/extra/httpd-vhosts.conf
(3)下载worepress并解压至/vhost/www1/目录下,修改配置文件:
~]#mv wp-config-sample.PHP wp-config.php
~]#vim wp-config.php
(4)测试www1.magedu.com域名
(5)下载PHPMyAdmin并解压至/vhost/www2目录下,并重命名改配置文件:
~]#mv config.sample.inc.PHP config.inc.PHP
(6)用openssl生成随机字符串,并填至配置文件相应位置,并修改MysqL服务器IP:
~]#openssl rand -base64 10
~]# vim config.inc.PHP
(7)在浏览器打开www2.magedu.com测试PHPMyAdmin:
原文链接:https://www.f2er.com/centos/381517.html