centos下搭建lamp环境

2011年9月14日 发表评论 阅读评论

1:安装apache

yum install httpd httpd-devel
2:安装mysql

yum install mysql mysql-server mysql-devel

设置密码
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
登陆
mysql -u root -p
Enter Password: <your new password>
创建一个用户管理数据库
mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';

 

3:安装php

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

4:启动apache

   测试php

   建立以下文件/var/www/html/test.php
   编辑其内容

// test.php
<?php
phpinfo();
?>

5:测试
   在浏览器中输入:http://IP/test.php
   看是否显示PHP的信息

6:安装phpmyadmin

yum install phpmyadmin

/etc/httpd/conf.d/phpmyadmin.conf

<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
# Deny from all
Allow from 127.0.0.1
</Directory>

/usr/share/phpmyadmin/conf.inc.php  设置密码

7: 防火墙配置
a.添加.允许访问端口{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
b.关闭防火墙{不推荐}.
service iptables stop
c.重置加载防火墙
service iptables restart
3.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。

8: 简单配置文件:
apache的配置文件是/etc/httpd/conf下
modules放在/usr/lib/httpd下
php的配置文件在/etc/php.d/下 和/etc/php.ini
php的modules放在/usr/lib/php/modules下




本站的发展离不开您的资助,金额随意,欢迎来赏!

You can donate through PayPal.
My paypal id: itybku@139.com
Paypal page: https://www.paypal.me/361way

分类: Linux/unix/mac 标签:
  1. 本文目前尚无任何评论.