一、检查系统环境确保没有其他相冲突的软件
二、安装Apache
1、yum安装
[root@localhost ~]# yum -y install httpd
2、开启服务,设置开机自启
[root@localhost ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
[root@localhost ~]# chkconfig httpd
3、查看是否开启
[root@localhost ~]# netstat -lnupt | grep httpd
tcp 0 0 :::80 :::* LISTEN 1445/httpd
注:
### 安装apache 一些扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
配置文件
/etc/httpd/conf/httpd.conf
三、安装mysql
1、安装mysql
mysql 客户端程序
mysql-server服务端程序
mysql-devel开发设计的库
[root@localhost ~]# yum -y install mysql mysql-devel mysql-server
2、启动mysql服务,设置开机自启
[root@localhost ~]# service mysqld restart
[root@localhost ~]# chkconfig mysqld
3、查看是否启动
[root@localhost ~]# netstat -lunpt | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1663/mysqld
4、修改mysql数据库密码
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('123456')
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
#测试密码是否生效,已成功
[root@localhost ~]# mysql -uroot -p'123456'
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
四、安装PHP服务
1、安装PHP,及PHP的mysql支持软件
[root@localhost ~]# yum -y install php php-mysql
2、PHP常用扩展包
# 安装php常用扩展
yum search php #查看PHP的扩展包
yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
3、安装完PHP必须重启httpd服务
[root@localhost ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
五、测试安装是否成功
1、准备测试页面
[root@localhost ~]# vim /var/www/html/mysql.php
<?php
$link=mysqli_connect('localhost','root','123456'); #连接数据库
if($link) echo "<h1>lian jie shu ju ku cheng gong</h1>"; #连接成功显示
mysqli_close(); #关闭连接
?>
[root@localhost ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>
2、关闭防火墙,安全机制
#这里都是临时关闭
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]# setenforce 0
3、测试PHP是否安装成功
显示这个页面表示是PHP,Apache安装成功
连接数据库成功
六、安装PHP数据库可视化工具
phpmyadmin 软件下载地址:http://www.phpmyadmin.net/downloads
下载完成之后安装
[root@localhost ~]# cd /var/www/html/ #切换到网页源目录
[root@localhost html]# rz #上传软件包
. waiting to receive.**B0100000023be50
[root@localhost html]# unzip phpMyAdmin-3.5.8.2-all-languages_\(1\).zip #解压
[root@localhost html]# mv phpMyAdmin-3.5.8.2-all-languages phpMyAdmin #改名
[root@localhost html]# vim phpMyAdmin/libraries/config.default.php #修改这个配置文件
$cfg['SQLValidator']['username'] = 'root'; #数据库用户名
$cfg['SQLValidator']['password'] = '123456'; #密码
#如果访问不显示页面,安装php-mbstring
yum -y install php-mbstring
######
#安装时注意phpmyadmin与php版本的兼容,小编用的是PHP-5.3.3 与 phpmyadmin3.8.2
访问
用户名:数据库用户名
密码:数据库密码
安装lamp的详细步骤这个博客写的很详细https://www.cnblogs.com/wangchunniu1314/p/6340007.html