环境准备:
我的环境:Red Hat Enterprise Linux Server release 5.4
所需软件包:
apr-1.4.6.tar.gz
httpd-2.4.2.tar.bz2
php-5.4.4.tar.gz
apr-util-1.4.1.tar.gz
libmcrypt-2.5.7.tar.gz
cmake-2.8.6.tar.gz
mysql-5.5.25.tar.gz
辅助包:
ncurses-devel.i386
pcre-devel
libxml2
安装配置过程:
安装cmake编译工具
[root@orcl10g LAMP]# tar zxvf cmake-2.8.6.tar.gz
[root@orcl10g LAMP]# cd cmake-2.8.6
[root@orcl10g cmake-2.8.6]# ./configure
[root@orcl10g cmake-2.8.6]# make
[root@orcl10g cmake-2.8.6]# make install
查看cmake是否安装成功
[root@orcl10g cmake-2.8.6]# which cmake
/usr/local/bin/cmake
安装libmcrypt-2.5.7
[root@orcl10g LAMP]# tar zxvf libmcrypt-2.5.7
[root@orcl10g LAMP]# cd libmcrypt-2.5.7
[root@orcl10g libmcrypt-2.5.7]# ./configure
编译:
[root@orcl10g libmcrypt-2.5.7]# make
安装:
[root@orcl10g libmcrypt-2.5.7]# make install
安装mysql
添加mysql用户组
[root@orcl10g LAMP]# groupadd mysql
创建mysql用户,不允许其直接登入系统
[root@orcl10g LAMP]# useradd -g mysql -s /sbin/nologin mysql
创建mysql的数据存放路径并设置目录权限
[root@orcl10g mysql-5.5.25]# mkdir -p /mysql/data
[root@orcl10g mysql-5.5.25]# chown -R mysql:mysql /mysql/data
解压安装包:
[root@orcl10g LAMP]# tar zxvf mysql-5.5.25.tar.gz
[root@orcl10g LAMP]# cd mysql-5.5.25
cmake配置使安装路径为/usr/local/mysql5字符集设置为all
[root@orcl10g mysql-5.5.25]# cmake -DECMAKE_INSTALL_PREFIX=/usr/local/mysql5 -DEXTRA_CHARSETS=all
执行会出如下错误:
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:127 (FIND_CURSES)
cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:257 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
提示的很明显,需要安装ncurses-devel包,在镜像里找到该包并安装,yum安装更方便:
[root@orcl10g ~]# yum install ncurses-devel -y
删除ncurses-devel再次执行cmake命令
[root@orcl10g LAMP]# cd mysql-5.5.25
[root@orcl10g mysql-5.5.25]# rm -rf CMakeCache.txt
[root@orcl10g mysql-5.5.25]# cmake -DECMAKE_INSTALL_PREFIX=/usr/local/mysql5 -DEXTRA_CHARSETS=all
[root@orcl10g mysql-5.5.25]# make
[root@orcl10g mysql-5.5.25]# make install
添加数据存放路径:
[root@orcl10g apache2]# vi /etc/my.cnf
[mysqld]
添加
datadir = /mysql/data
添加root密码
[root@orcl10g apache2]# /usr/local/mysql/bin/mysqladmin -u root password 123456
登入测试:
[root@orcl10g apache2]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql>
[root@orcl10g mysql]# cp ./support-files/my-medium.cnf /etc/my.cnf
生成测试数据库:
[root@orcl10g mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
启动数据库
[root@orcl10g mysql-5.5.25]# /usr/local/mysql/bin/mysqld --user=mysql
安装配置apache2
安装apr-1.4.6
[root@orcl10g LAMP]# tar zxvf apr-1.4.6.tar.gz
[root@orcl10g LAMP]# cd apr-1.4.6
[root@orcl10g apr-1.4.6]# ./configure --prefix=/usr/local/apr-httpd/
[root@orcl10g apr-1.4.6]# make
[root@orcl10g apr-1.4.6]# make install
安装apr-util-1.4.1
[root@orcl10g apr-1.4.6]# cd ..
[root@orcl10g LAMP]# tar zxvf apr-util-1.4.1.tar.gz
[root@orcl10g LAMP]# cd apr-util-1.4.1
[root@orcl10g apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util-httpd/
--with-apr=/usr/local/apr-httpd/
[root@orcl10g apr-util-1.4.1]# make & make install
解压安装apache
[root@orcl10g LAMP]# tar ixvf httpd-2.4.2.tar.bz2
[root@orcl10g LAMP]# cd httpd-2.4.2
指定安装路径,并允许读写,指派刚安过的apr和apr-util路径
[root@orcl10g httpd-2.4.2]# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/
执行会报错:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
需要安装依赖包pcre-devel.i386:
镜像中找到pcre-devel或者使用yum安装
[root@orcl10g httpd-2.4.2]# yum install pcre* -y
Installed:
pcre-devel.i386 0:6.6-2.el5_1.7
Complete!
重新执行./configure命令
[root@orcl10g httpd-2.4.2]# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/
编译
[root@orcl10g httpd-2.4.2]# make
安装
[root@orcl10g httpd-2.4.2]# make install
启动apache2
[root@orcl10g httpd-2.4.2]# /usr/local/apache2/bin/apachectl start
如果报以下错误,需修改一下配置文件:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@orcl10g httpd-2.4.2]# vi /usr/local/apache2/conf/httpd.conf
加入ServerName
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName localhost:80
再次启动apache
[root@orcl10g httpd-2.4.2]# /usr/local/apache2/bin/apachectl start
[root@orcl10g httpd-2.4.2]# /usr/local/apache2/bin/apachectl
httpd (pid 15249) already running
安装php
解压php包
[root@orcl10g LAMP]# tar zxvf php-5.4.4.tar.gz
[root@orcl10g LAMP]# cd php-5.4.4
配置:
[root@orcl10gphp-5.4.4]# ./configure --prefix=/usr/local/php5/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --enable-mbstring
提示报错:
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
缺少 libxml2包
[root@orcl10g php-5.4.4]# yum install libxm*
再次执行配置:
[root@orcl10g php-5.4.4]# ./configure --prefix=/usr/local/php5/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --enable-mbstring
编译
[root@orcl10g php-5.4.4]#make
安装
[root@orcl10g php-5.4.4]#make install
测试:
[root@orcl10g ~]# cd /usr/local/apache2/htdocs/
[root@orcl10g htdocs]# vi index.php
写入内容如下:
phpinfo();
?>
php信息:
apache信息
mysql信息