1.获取软件包
apache: http://www.apache.org/dist/httpd/httpd-2.4.2.tar.gz
mysql: http://mirror.provenscaling.com/mysql/enterprise/source/5.0/mysql-5.0.70.tar.gz
php: http://museum.php.net/php5/php-5.2.2.tar.gz
把下载的软件包全部放入/usr/local/src
2.安装mysql
cd mysql-5.0.0
./configure --prefix=/usr/local/mysql-----指定目录安装
make时出现错误
make: *** No targets specified and no makefile found. stop.
在网上查找资料发现./configure出了问题,看到最后几行出错。信息如下:
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found
原因:缺少ncurses包
解决方法:yum list | grep ncurses
yum -y install ncurses-devel
yum install ncuises-devel
安装完成。重新./configure 顺利进行!
进行下一步安装
make
又出现如下报错
问题:安装gcc-c++和它的依赖libstdc++-devel
yum -y install gcc-c++
yum -y install libstdc++-devel
重新./configure安装并make
看样子是安装成功了,嘘气一声~
make install ---------安装成功
useradd mysql----------添加mysql用户
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -R mysql .-------设置权限,注意后面有个点
chgrp -R mysql .
chown -R mysql var
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld---开机启动
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
配置完成,应该可以启动mysql了
service mysqld start
启动MYSQL服务时,总提示“MYSQL manager or server PID file could not be found![失败 ]
OH,MY GOD.又报错,继续查原因
vim /etc/init.d/mysqld
指定安装目录和存放目录
可算启动成功了。长叹啊~这一路曲折多多,linux的问题要有100天不拉屎的精神(坚持不懈啊~)
3.安装apache
tar -zxvf httpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite --enable-shared=max
看来没有安装pcre组件啊,赶紧下载安装
咦!怎么newly created file is older than distributed files!
修改系统时间,时间校准,重新安装
有点疯掉了。真是步步为营步步营啊。卸载重新安装吧!
yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
查找解决办法http://www.itokit.com/2012/0430/73710.html执行
安装完成后,检查组件是否完全开始执行
./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
OK, 总算结束这个apache曲折过程
4.安装PHP
tar -zxvf php-5.2.2.tar.gz
cd php-5.2.2
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
yum -y install flex-*
重新./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
yum -y install libxml2-*
再重新./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
找到存放的位置cd /usr/lib64/mysql/
cp -rp libmysqlclient_r.so.15.0.0 /usr/local/mysql/lib/mysql/
重新执行./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
.解决方法:
如果是自己选择GZ包安装的MYSQL。这里要加路径。
加的方法为--with-mysql-dir=/user/local/mysql
切记不可写为:--with-mysql=/user/local/mysql
./configure --prefix=/usr/local/php --with-mysql-dir=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
总是报这番错误,查找资料,更新版本,经过多番尝试,不知道是哪里出现问题。询问有经验的人士,最后怀疑是apache2.4.2和php5.2.2版本兼容问题。重新下载安装apache2.2.22.按照以上操作的步奏重新尝试…………OH,MY GOD.看来又要大费周章了,坚持吧!
最后启动成功。看来真的是兼容问题。
apache设置成开机自启动:在/etc/rc.d/rc.local文件中加入一行并保存: /usr/local/apache/bin/apachectl start
(apache+php配置完毕)
6.查看并确认L.A.M.P环境信息
vi /usr/local/apache/htdocs/phpinfo.php新增加下面一行,并保存。
<?
php phpinfo();
?>
chmod 755 /usr/local/apache/htdocs/phpinfo.php
用浏览器打开 http://192.168.1.210/phpinfo.php检查 phpinfo中的各项信息是否正确。如果可以访问则环境搭建成功
6)安装phpMyAdmin
tar -zxvf phpMyAdmin-3.2.4-all-languages.tar.gz
mkdir -p /var/www/
mv phpMyAdmin-3.2.4-all-languages /var/www/phpMyAdmin/
cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
vim /var/www/phpMyAdmin/config.inc.php 指定下面选项即可
$cfg['Servers'][$i]['host'] = '127.0.0.1'; 把localhost修改为127.0.0.1
$cfg['Servers'][$i]['user'] = 'root'; 指定mysql服务器的用户名,可以是其他用户,但必须要给该用户授权
$cfg['Servers'][$i]['password'] = 'mysql'; 指定mysql数据库密码
创建phpMyAdmin.conf配置文件
vim /usr/local/httpd/conf/extra/phpMyAdmin.conf
Alias /phpMyAdmin /var/www/phpMyAdmin
<Location /phpMyAdmin>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1.113 指定客户端连接的IP地址
</Location>
编辑apache的主配置文件添加下面内容
vim /usr/local/apache/conf/httpd.conf
Include conf/extra/phpMyAdmin.conf
重启apache服务就大功告成啦
/usr/local/httpd/bin/apachectl restart