zhendeaini123 发表于 2018-5-12 10:34:39

Redhat5.4 LAMP配置

  1.       安装系统时选择www服务器
2.       用rpm -qi查看httpd mysql php php-mysql 是否安装.
3.       一般php-mysql系统默认不会安装。诺其他的安装包没有安装也是按下面的方法安装。
4.       安装php-mysql包
挂载redhat5.4光盘 #mount –o loop /dev/cdrom /mnt
查找光盘中是否有php-mysql包 #ls –a /mnt/Server |grep php-mysql
#rpm –ivh php-mysql.rpm
5.       关闭selinux 和iptables 如不关闭无法打开网站。
6.       启动httpd 和mysqld服务
#Service httpd start
#Service mysql start
7.       开启3级别下自动运行服务
#chkconfig –level 3 httpd on
#chkconfig –level 3 mysql on
8.       修改 httpd.conf配置文件
#vi /etc/httpd/conf/httpd.conf
SweverName 124.232.151.37 (诺有域名填写域名)网站访问域名
DocumentRoot “/var/www/html”网站文档目录
增加以下两行php文件传递给php解析
AddType application/x-httpd-php .php
AddType Application/x-httpd-php-source .phps
   增加index.php
   DirectoryIndex index.html index.html.var index.php
9.       测试apache 在浏览器中输入IP地址或域名访问。
10.   测试PHP
在/var/www/html下创建index.php文件
#vi /var/www/html/index.php
<?php
phpinfo();
?>
写入上面三行代码后,重启服务,再访问会在网页上出php相关信息
11.   测试mysql
设置mysql的root密码
#mysqladmin –u root password test0129
测试一下密码是否设置成功
#mysql -u root -p

enter password:
创建mysqltest.php测试文件
#vi /var/www/html/mysqltest.php
<?php
$link = mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;test0129&quot;);

if (!$link)

{

die('Could not connect: ' . mysql_error());

}

else echo &quot;Mysql runing&quot;;

mysql_close($link);
   ?>
退出重启服务,再访问网站测试是否出现:mysql running
如果正常,说明LAMP配置正常。
本文下载地址:http://down.51cto.com/data/346045
页: [1]
查看完整版本: Redhat5.4 LAMP配置