下载mysql到/usr/local/src/
cd /usr/local/src/ wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
解压
[root@localhost src]# tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
把解压完的数据移动到/usr/local/mysql
[root@localhost src]# mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql
建立mysql用户
[root@localhost src]# useradd -s /sbin/nologin mysql
初始化数据库
[root@localhost src]# cd /usr/local/mysql [root@localhost mysql]# mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
拷贝配置文件
[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf
拷贝启动脚本文件并修改其属性
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chmod 755 /etc/init.d/mysqld
修改启动脚本
[root@localhost mysql]# vim /etc/init.d/mysqld
需要修改的地方有 “datadir=/data/mysql” (前面初始化数据库时定义的目录)
把启动脚本加入系统服务项,并设定开机启动,启动mysql
[root@localhost mysql]# chkconfig --add mysqld [root@localhost mysql]# chkconfig mysqld on [root@localhost mysql]# service mysqld start
安装必备的一些软件
[root@localhost mysql]# yum install -y zlib-devel
[root@localhost mysql]# yum install -y pcre pcre-devel apr apr-devel
[root@localhost mysql]# cd /usr/local/src/
[root@localhost src]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
解压:
[root@localhost src]# tar zxvf httpd-2.2.16.tar.gz
配置编译参数:
[root@localhost src]# cd httpd-2.2.16 [root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
编译:
[root@localhost httpd-2.2.16]# make
安装:
[root@localhost httpd-2.2.16]# make install
以上两个步骤都可以使用 echo $?
来检查是否正确执行,否则需要根据错误提示去解决问题。
安装必备的一些软件
[rot@localhost httpd-2.2.16]# yum install -y libxml2-devel
[rot@localhost httpd-2.2.16]# yum install -y openssl openssl-devel
[rot@localhost httpd-2.2.16]# yum install -y bzip2 bzip2-devel
[rot@localhost httpd-2.2.16]# yum install -y libpng libpng-devel
[rot@localhost httpd-2.2.16]# yum install -y freetype freetype-devel
[rot@localhost httpd-2.2.16]# rpm -ivh "http://download.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
[rot@localhost httpd-2.2.16]# yum install -y libmcrypt-devel
因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源。
[rot@localhost httpd-2.2.16]# cd /usr/local/src
[root@localhost src]# wget http://am1.php.net/distributions/php-5.3.27.tar.gz
解压:
[root@localhost src]# tar zxf php-5.3.27.tar.gz
配置编译参数:
[root@localhost src]# cd php-5.3.27 [root@localhost php-5.3.27]# ./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
编译:
[root@localhost php-5.3.27]# make
安装:
[root@localhost php-5.3.27]# make install
拷贝配置文件:
[root@localhost php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini
Apache主配置文件为:/usr/local/apache2/conf/httpd.conf
vim /usr/local/apache2/conf/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 www.example.com:80
修改为:
ServerName localhost:80
启动apache之前先检验配置文件是否正确:
/usr/local/apache2/bin/apachectl -t
如果有错误,请继续修改httpd.conf, 如果是正确的则显示为 “Syntax OK”, 启动apache的命令为:
/usr/local/apache2/bin/apachectl start
查看是否启动:
[root@localhost ~]# netstat -lnp |grep httpd tcp 0 0 :::80 :::* LISTEN 7667/httpd
如果有显示这行,则启动了。 也可以使用curl命令简单测试:
[root@localhost ~]# curl localhost <html><body><h1>It works!</h1></body></html>
只有显示这样才正确。
测试是否正确解析php:
vim /usr/local/apache2/htdocs/1.php
写入:
<?php echo "php解析正常"; ?>
保存后,继续测试:
curl localhost/1.php
看是否能看到如下信息:
[root@localhost ~]# curl localhost/1.php php解析正常[root@localhost ~]#
只有显示这样才正确。
!!!!