| 
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册 
 
 
 
×
 
LAMP配置环境 
OS:Redhat AS4/5 
php5.2.5 
httpd2.2.6 
mysql5.0.51 
FTP 
[root@localhost ~]# /etc/init.d/vsftpd start ;启动FTP  
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf ;编辑FTP配置文件,FTP默认文件夹在/var/ftp下  
LAMP 采用Tarball方式安装 
Apache安装目录为:/web/www 
mysql安装目录为:/web/sql 
把原代码包cp到/web下  
[root@localhost ~]# mkdir /web ;创建/web目录  
[root@localhost ~]# cd /web ;进入/web目录  
[root@localhost web]# tar zxvf httpd-2.2.6.tar.gz ;解压Apache  
[root@localhost web]# tar zxvf mysql-5.0.51.tar.gz ;解压Mysql  
[root@localhost web]# tar zxvf php-5.2.5.tar.gz ;解压php  
;建议同时输入:tar zxvf httpd-2.2.6.tar.gz ;tar zxvf mysql-5.0.51.tar.gz ;tar zxvf php-5.2.5.tar.gz   
安装mysql 
[root@localhost web]# cd mysql-5.0.51 ;进入mysql目录  
[root@localhost mysql-5.0.51]# groupadd mysql ;增加sql用户组  
[root@localhost mysql-5.0.51]# useradd -g mysql mysql  
[root@localhost mysql-5.0.51]# ./configure --prefix=/web/sql ;开始编译   
[root@localhost mysql-5.0.51]# make  
[root@localhost mysql-5.0.51]# make install  
[root@localhost mysql-5.0.51]# cp support-files/mysql.server /etc/rc.d/init.d/mysql ;开机启动mysql 
[root@localhost mysql-5.0.51]# cp support-files/my-medium.cnf /etc/my.cnf 
[root@localhost mysql-5.0.51]# cd /web/sql  
[root@localhost sql]# chown -R mysql .  
[root@localhost sql]# chgrp -R mysql .  
[root@localhost sql]# bin/mysql_install_db --user=mysql  
[root@localhost sql]# chown -R root .  
[root@localhost sql]# chown -R mysql var  
[root@localhost sql]# bin/mysqld_safe --user=mysql& ;启动mysql  
[root@localhost sql]# bin/mysql ;进入mysql  
mysql> grant all privileges on *.* to '用户名'@'localhost' ;建立mysql用户  
mysql> identified by '密码' with grant option; //有待确认 
[root@localhost sql]# bin/mysql -u gdsspt_bbs -p ;登录用户名为gdsspt_bbs的数据库 
[root@localhost sql]# bin/mysqladmin -u gdsspt_bbs password '123' ;设置用户名为gdsspt_bbs的数据库的登录密码为123. 
安装 Apache /web/www 是安装目录 
[root@localhost httpd-2.2.6]# ./configure --enable-so --prefix=/web/www  
[root@localhost httpd-2.2.6]# make  
[root@localhost httpd-2.2.6]# make install  
[root@localhost www]# cp bin/apachectl /etc/init.d/httpd ;开机启动Apache 
[root@localhost www]# bin/apachectl -k start ;启动Apache  
[root@localhost www]# bin/apachectl -k stop ;停止Apache  
[root@localhost ~]# vi /etc/sysconfig/iptables ;编辑防火墙 
增加 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 
表示允许访问80端口 
 
要想要配置生效可以重启电脑,或者允许下面两个命令: 
# service iptables stop 
# service iptables start 
紧接着安装 PHP 
[root@localhost php-5.2.5]# ./configure --with-apxs2=/web/www/bin/apxs --with-mysql=/web/sql  
[root@localhost php-5.2.5]# make  
[root@localhost php-5.2.5]# make install  
[root@localhost php-5.2.5]# cp php.ini-dist /usr/local/lib/php.ini  
[root@localhost php-5.2.5]# vi /web/www/conf/httpd.conf 重新配置 apache2 让他支持 php  
在 LoadModule php5_module modules/libphp5.so 后 
添加 AddType application/x-httpd-php .php .phtml  
OK, 基本的安装已经完成 .  
# /web/www/bin/apachectl start 重新起动 APACHE: 
如果重新起动 APACHE 出现 :  
Syntax error on line 232 of /web/www/conf/httpd.conf: Cannot load /web/www/modules/libphp5.so into server:  
/web/www/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied  
那就要按照下面的方法解决 :  
1.chcon -t texrel_shlib_t /web/www/modules/*.so //有待确认 
2. 编辑 /etc/selinux/config ,找到这段:  
# This file controls the state of SELinux on the system.  
# SELINUX= can take one of these three values:  
# enforcing - SELinux security policy is enforced.  
# permissive - SELinux prints warnings instead of enforcing.  
# disabled - SELinux is fully disabled.  
SELINUX=enforcing  
把 SELINUX=enforcing 注释掉: #SELINUX=enforcing ,然后新加一行为:  
SELINUX=disabled  
保存,关闭。  
编辑 /etc/sysconfig/selinux ,找到 :  
# This file controls the state of SELinux on the system.  
# SELINUX= can take one of these three values:  
# enforcing - SELinux security policy is enforced.  
# permissive - SELinux prints warnings instead of enforcing.  
# disabled - SELinux is fully disabled.  
SELINUX=enforcing  
如果 SELINUX 已经是 SELINUX=disabled ,那么就不用改了,否则就把 SELINUX=enforcing 注释掉,新加一行:  
SELINUX=disabled  
保存,退出。  
 
安装ZendOptimizer  
回到 ZendOptimizer 源码所在目录.  
2. 执行 tar -zxvf ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz  
3. 执行 cd ZendOptimizer-3.2.6-linux-glibc21-i386  
4. 执行 ./install  
5. 进入如下的ZendOptimizer安装界面.点击回车  
6. 点击回车  
7. 在 Yes 上点击回车  
8. 这里填写ZendOptimizer安装路径.我们将它安装在 /web/Zend  
下.填写 /web/Zend  后点击 Tab 键.在 ok 上面点击回车  
9. 这里选择php.ini所在位置.我们在之前的安装中已经将php.ini复制到了/usr/local/lib  
下.所以这里不用修改.在 OK 上点击回车  
10. 我们用的正是apache.在Yes上点击回车  
11. 这里填写apachectl的位置.我们的是在/web/www/bin/apachectl  
输入 /web/www/bin/apachectl  后,点击 Tab 键移动光标到 OK 上.然后点击回车  
12. 点击回车  
13. 点击回车  
14. 点击回车 重启apache  
15. 点击回车 完成ZendOptimizer的安装  
环境测试  
安装完成后.我们来测试一下之前配置的环境是否正确  
1. 再次重启apache.执行 /web/www/bin/apachectl -k restart  
尽管安装ZendOptimizer时已经重启了apache,但我们还是要执行如下命令重启apache  
以确保apache修改的配置已经从新加载入来.请大家务必不要漏了这一步.  
2. 执行 vi /web/www/htdocs/phpinfo.php  
在网站根目录下建立一个phpinfo.php的文件.  
3. 点击 i 键进入 插入编辑方式.  
4. 输入  
<?php  
phpinfo();  
?>  
5. 点击 Esc 键回到vi 命令行方式.输入 :wq 回车  
系统将保存phpinfo.php文件,并退出vi编辑器  
6. 在浏览器打开 http://192.168.6.33/phpinfo.php  
如果出现如下界面则说明php已经安装好了.  
7. 测试 php 是否和 mysql 关联.  
执行 vi /web/www/htdocs/test.php   
8. 点击 i 键进入 插入编辑方式.并输入  
<?php  
//phpfans http://www.phpfans.net  
$conn = mysql_connect("localhost","root","");  
if($conn) echo "<h1>succeed</h1>";  
else echo "<h1>fail</h1>":  
?>  
9. 点击 Esc 键回到vi 命令行方式.并输入 :wq 然后点击回车  
10. 在浏览器中打开 http://localhost/phpmyadmin可能语句错误先不管它。。  
出现如下界面则说明php已经成功关联mysql了 |   
 
 
 
 |