/ 中存储网

在CentOS系统上编译安装Apache+PHP+MySQL服务器环境

2013-12-22 12:59:01 来源:IT技术网

源码目录:/usr/local/src/

应用目录:/usr/local/app/

一、MYSQL安装。

1.下载MSYQL源码:

http://www.mysql.com/downloads/mysql/

最近版本是 mysql-5.1.47.tar.gz

2.上传到服务器目录/usr/local/src/

cd /usr/local/src/

tar zxvf mysql-5.1.47.tar.gz

cd mysql-5.1.47

./configure --prefix=/usr/local/app/mysql --with-extra-charsets=all --with-unix-socket-path=/tmp/mysql.sock

make

make install

安装完毕。

3. 初始化MYSQL

cp /usr/local/app/mysql/share/mysql/my-medium.cnf /etc/my.cnf

/usr/local/app/mysql/bin/mysql_install_db

cp /usr/local/app/mysql/share/mysql/mysql.server /etc/init.d/mysqld

4.创建MYSQL用户

groupadd mysql

useradd mysql -d /usr/local/app/mysql/var -g mysql

5.启动mysql

/etc/init.d/mysqld start

二.安装APACHE

1.下载HTTPD

http://labs.renren.com/apache-mirror/httpd/

下载最新的 httpd-2.2.15.tar.gz 

2.上传到服务器 /usr/lcoal/src/

cd /usr/lcoal/src/

tar zxvf httpd-2.2.15.tar.gz

cd /usr/lcoal/src/httpd-2.2.15

./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=most

make

make install

三、安装PHP

1.下载PHP

http://www.php.net/downloads.php

下载最新版本 php-5.2.13.tar.gz

2.上传到服务器 /usr/lcoal/src/

tar zvfx php-5.2.13.tar.gz

cd php-5.2.13

./configure --with-apxs2=/usr/local/app/apache/bin/apxs --with-zlib-dir --with-libxml-dir --with-jpeg-dir --with-png-dir --with-gd --with-mysql=/usr/local/app/mysql --with-pdo-mysql=/usr/local/app/mysql --with-mysqli=/usr/local/app/mysql/bin/mysql_config --enable-mbstring

make

make install

cp /usr/local/src/php-5.2.13/php.ini-recommended /usr/local/lib/php.ini

3.配置APACHE支持PHP5

修改httpd.conf

vi /usr/lcoal/app/apache/conf/httpd.conf

httpd.conf 中添加

LoadModule php5_module modules/libphp5.so

httpd.conf 中添加

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

重启apache

/usr/local/app/apache/bin/apachectrl start