第一步:前期准备:准备虚拟机,最小化安装;彻底卸载mysql:关闭selinux;删除mysql用户:
[ ~]# rpm -qa|grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64mysql-server-5.1.71-1.el6.x86_64mysql-libs-5.1.71-1.el6.x86_64mysql-5.1.71-1.el6.x86_64[ ~]# yum remove -y qt-mysql-4.6.2-26.el6_4.x86_64 mysql-server-5.1.71-1.el6.x86_64 mysql-libs-5.1.71-1.el6.x86_64 mysql-5.1.71-1.el6.x86_64[ ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
[ local]# userdel mysql
第二步:安装mysql
[ tmp]# tar zxvf mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz
[ local]# useradd -s /sbin/nologin mysql
[ local]# useradd -s /sbin/nologin mysql
[ local]# cd /data/
[ data]# mkdir mysql[ /]# chown -R mysql:mysql /data/mysql/
[ mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
[ mysql]# echo $?
0[ mysql]# cd support-files/
[ support-files]# pwd/usr/local/mysql/support-files[ support-files]# lsbinary-configure magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server[ support-files]# vim mysql.serverdatadir=/data/mysql
[ support-files]# cp mysql.server /etc/init.d/mysqld
[ support-files]# chmod 755 /etc/init.d/mysqld [ support-files]# chkconfig --add mysqld[ support-files]# chkconfig mysqld on[ support-files]# service mysqld startStarting MySQL. SUCCESS! [ support-files]#[ mysql]# ln -fs /usr/local/mysql/bin/* /usr/bin/
第三步:安装apache
[ tmp]# tar zxvf httpd-2.2.16.tar.gz
[ httpd-2.2.16]# yum install -y gcc
[ httpd-2.2.16]# ./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so
[ httpd-2.2.16]# echo $?
0[ httpd-2.2.16]# make && make install
[ httpd-2.2.16]# echo $?
0第四步:安装php(libmcrypt-2.5.6源码包下载地址:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.6.tar.gz)
[ tmp]# tar zxvf php-5.3.28.tar.gz
[ tmp]# cd php-5.3.28
[ tmp]# yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
[ tmp]# tar zxvf libmcrypt-2.5.6.tar.gz
[ tmp]# cd libmcrypt-2.5.6
[ libmcrypt-2.5.6]# ./configure
[ libmcrypt-2.5.6]# make && make install
[ libmcrypt-2.5.6]# echo $?
0[ libmcrypt-2.5.6]# cd ..
[ tmp]#cd php-5.3.28
[ php-5.3.28]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
[ php-5.3.28]# echo $?
0[ php-5.3.28]# make && make install
[ php-5.3.28]# echo $?
0第五步:apache和php的结合
[ conf]# pwd
/usr/local/apache2/conf[ conf]# vim httpd.conf在AddType application/x-gzip .gz .tgz 下添加:
AddType application/x-httpd-php .php
把<IfModule dir_module>
DirectoryIndex index.html
</IfModule>修改为
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
在#ServerName 下添加:
ServerName localhost:80
完成以上配置后,测试apache文件可显示正常:
[ conf]# /usr/local/apache2/bin/httpd -t
Syntax OK第六步:测试解析php
[ conf]# cd ../htdocs/
[ htdocs]# lsindex.html[ htdocs]# vim 1.php<?
echo "php解析正常";
?>
如果在确认配置文件正常的情况下,提示404错误,重启系统即可。
第六步:apache测试
[ ~]# /usr/local/apache2/bin/httpd -t(查看配置文件是否正确)
httpd: apr_sockaddr_info_get() failed for lilonghttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerNameSyntax OK[ conf]# /usr/local/apache2/bin/httpd -l(静态加载的模块)
[ conf]# /usr/local/apache2/bin/httpd -M(加载的模块)[ conf]# apachectl graceful不杀死进程,重新加载
第七步:php测试
[ ~]# vim 1.php
<?
echo "lilong";
echo "\n";
?>
[ ~]# /usr/local/php/bin/php 1.php
lilong[ bin]# /usr/local/php/bin/php -m(php加载的模块)
[ bin]# /usr/local/php/bin/php -i(查看php参数)
[ php-5.3.28]# cp php.ini-development /usr/local/php/etc/php.ini
[ /]# /usr/local/php/bin/php -i |grep -i configuration(通过该命令查看上一条命令复制的配置文件已经加载)
Configuration File (php.ini) Path => /usr/local/php/etcLoaded Configuration File => /usr/local/php/etc/php.iniConfigurationPHP Warning: Unknown: 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in Unknown on line 0 [ htdocs]# vim 2.php<?
phpinfo();
?>
通过浏览器可查看本机php的详细信息
[ htdocs]# ldd /usr/local/apache2/modules/libphp5.so (查看某个动态模块在哪里)