centos下搭建lamp环境
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:
创建一个用户管理数据库
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
5:测试
在浏览器中输入:http://IP/test.php
看是否显示PHP的信息
6:安装phpmyadmin
yum install phpmyadmin
/etc/httpd/conf.d/phpmyadmin.conf
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
/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下
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/lampdajian/277.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.