<p>一、  安装apache</p><p>先安装gcc编译器</p><p>yum install gcc gcc-c++ gcc-g77</p><p>如果系统中没有make工具就执行下面这条命令安装,后面要用到它</p><p>Yum install make</p><p> </p><p>安装apache需要用到这些文件</p><p>apr-1.4.6.tar.gz-----------apache可移植库</p><p>apr-util-1.5.1.tar.gz -----apache可移植库</p><p>pcre-8.32.zip--------------正则表达式库</p><p>httpd-2.2.23.tar.gz--------Apache源码包</p><div style="page-break-after: always;"><span style="display: none;"><!--more-->& nbsp ;</span></div><p> </p><p>安装apr-1.4.6.tar.gz</p><p>#tar –zxvf apr-1.4.6.tar.gz</p><p>#cd apr-1.4.6</p><p>#./configure --prefix=/usr/local/apr</p><p>#make</p><p>#make install</p><p> </p><p>安装apr-util-1.5.1.tar.gz</p><p>#tar –zxvf apr-util-1.5.1.tar.gz</p><p>#cd apr-util-1.5.1</p><p>#./configure --prefix=/usr/local/aprutil --with-apr=/usr/local/apr</p><p>#make</p><p>#make install</p><p> </p><p>安装pcre-8.32.zip</p><p>#unzip pcre-8.32.zip</p><p>#cd pcre-8.32</p><p>#./configure –prefix=/usr/local/prce</p><p>#make</p><p>#make install</p><p> </p><p>安装apache</p><p># tar -zxvf httpd-2.2.23.tar.gz</p><p># cd httpd-2.2.23</p><p>#./configure --prefix=/usr/local/apache2.4.2 -with-apr=/usr/local/apr -with-apr-util=/usr/local/aprutil</p><p>#make</p><p>#make install</p><p>进去apache目录</p><p>#cd /usr/local/apache/bin</p><p>启动apache</p><p>#./apachectl start</p><p>查看端口</p><p>#netstat –an | grep 80</p><p>此时应该显示80端口正在监听中….</p><p>输入http://192.168.111.133看到It Work表明apache安装成功,如果不能看到,则执行iptables –F</p><p> </p><p>二、  安装mysql</p><p>安装mysql需要用到的文件</p><p>cmake-2.8.4.tar.gz</p><p>mysql-5.5.29.tar.gz</p><p> </p><p>安装cmake-2.8.4.tar.gz</p><p>#tar -zxvf cmake-2.8.4.tar.gz</p><p>#cd cmake-2.8.4</p><p>#./configure –prefix=/usr/local/cmake</p><p>#make</p><p>#make install</p><p> </p><p>安装mysql</p><p># tar -zxvf mysql-5.5.29.tar.gz</p><p># cd mysql-5.5.29</p><p>添加mysql运行的用户组和用户</p><p>#groupadd mysql</p><p>#useradd mysql</p><p>创建mysql安装目录</p><p>#mkdir /usr/local/mysql</p><p>#mkdir /usr/local/mysql/data</p><p>#cmake . <br />-DCMAKE_INSTALL_PREFIX=/usr/local/mysql <br />-DINSTALL_DATADIR=/usr/local/mysql/data <br />-DDEFAULT_CHARSET=utf8 <br />-DDEFAULT_COLLATION=utf8_general_ci <br />-DEXTRA_CHARSETS=all <br />-DENABLED_LOCAL_INFILE=1</p><p>如果上面的配置信息出错则安装</p><p># install ncurses-devel</p><p>#make</p><p>#make install</p><p>设置mysql目录用户组和用户</p><p># chown -R root:mysql . 用户组为root 用户root</p><p># chown -R mysql:mysql data</p><p>拷贝配置文件到etc目录下</p><p>#cp support-files/my-medium.cnf /etc/my.cnf</p><p>创建并初始化系统数据库的系统表</p><p># scripts/mysql_install_db --user=mysql</p><p>启动mysql</p><p># ./bin/mysqld_safe –user=mysql &</p><p>修改root密码</p><p>./bin/mysql –uroot –p</p><p>>use mysql</p><p>添加root用户的远程连接能力</p><p>Mysql>GRANT ALL PRIVILEGES ON . TO root@"%" IDENTIFIED BY "root";</p><p>Mysql>update user set Password = password(‘19930526’) where User='root';(19930526为需要设置的密码)</p><p>Mysql>flush privileges;</p><p> </p><p>三、  安装PHP</p><p>安装PHP需要用到的文件</p><p>libxml2-2.6.32.tar.gz</p><p>php-5.3.21.tar.gz</p><p> </p><p>安装libxml2-2.6.32.tar.gz</p><p>#tar –zxvf libxml2-2.6.32.tar.gz</p><p># ./configure --prefix=/usr/local/libxml2</p><p>#make</p><p>#make install</p><p>安装php</p><p>tar –zxvf php-5.3.21.tar.gz</p><p>配置信息</p><p>./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql</p><p>>  --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2</p><p>#make</p><p>#make install</p><p>拷贝配置文件到/usr/local/php/lib目录下</p><p># cp php.ini-development /usr/local/php/lib/php.ini</p><p>配置Apache PHP 工作</p><p>配置 httpd.conf 让apache支持PHP</p><p># vi /usr/local/apache/conf/httpd.conf</p><p>找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容</p><p>AddType application/x-httpd-php .php      (.前面有空格)</p><p>AddType application/x-httpd-php-source .phps        (.前面有空格)</p><p>重启apache</p><p>新建文件demo.php</p><p><?php</p><p>   echo phpinfo();</p><p>?></p><p>将文件放到/usr/local/apache/htdocs下</p><p>看到打印信息页面则LAMP环境配置成功 …</p>