您的位置:首页 > 数据库 > MySQL

Cen OS6 系统下安装LAMP

2017-07-06 00:00 92 查看
一、个别电脑可能有防火墙限制导致不能安装

查看防火墙关闭状态
service iptables status
1 关闭防火墙-----service iptables stop
2 启动防火墙-----service iptables start
3 重启防火墙-----service iptables restart
4 查看防火墙状态--service iptables status
5 永久关闭防火墙--chkconfig iptables off
6 永久关闭后启用--chkconfig iptables on

二、 开始安装MySQL

1、安装

yum install mysql mysql-server

2 、设置mysql 开机自启动

chkconfig --levels 235 mysqld on  /etc/init.d/mysqld start

3、设置mysql密码

知道初始密码  通过登录mysql系统,
# mysql -u root -p
Enter password: 【输入原来的密码】
mysql>use mysql;
mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;
mysql> exit;

忘记原来的myql的root的密码;

查看下mysql状态
# /etc/init.d/mysqld status
如果正在运行状态下 那么请首先关闭掉
# /etc/init.d/mysqld stop

然后 跳过验证
# mysqld_safe --skip-grant-tables
这时已经跳过验证直接 进入mysql
# mysql
进入mysql系统数据库:
# use mysql

修改root账户密码:
# update user set password=password("12345") where user="root";
刷新权限:
# flush privileges;

退出
# exit

启动mysql:

# /etc/init.d/mysqld start

进入mysql
mysql -u root -p 12345

三、安装Apache2

1、安装
yum install httpd

2、配置系统在引导时启动Apache

chkconfig --levels 235 httpd on

3、启动Apache

/etc/init.d/httpd start


然后浏览器输入 http://127.0.0.1或者 服务器的域名 你应该看到Apache2的测试页:

Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,

配置文件是/etc/httpd/conf/httpd.conf

四、安装PHP

1 我们可以用下面的命令来安装PHP   php55w 表示安装php5.5 版本 根据自己需求更改

yum install php55w

安装完需要重启

/etc/init.d/httpd restart

测试
在根目录中创建
vi /var/www/html/info.php

然后浏览器访问例如
http://127.0.0.1/info.php  或者 http://域名/index.php显示index.php 内容就表示完成了


设置php mysql支持 安装的php-mysql软件

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

重新启动Apache2的:

/etc/init.d/httpd restart

五、安装phpMyAdmin(注意下载的phpMyAdmin 支持的php 版本 和mysql版本)

下载phpMyAdmin 文件 然后将文件包放在 /var/www/html文件夹下
如果php环境没问题的话应该能通过http://127.0.0.1/phpMyAdmin/访问了 内部具体的权限设置可以自行查阅资料


六、错误解决方法

1、出现缺少包的错误解决方法

查看以下的包是不是全部安装完成

httpd httpd-devel php55w php55w-devel php55w-mysql mysqld-server mysql mysql-server

如果缺少那个重新安装那个

一键安装所需的所有包(php55w 是php5.5 版本具体根据自己使用版本而定)

使用前先移除服务器上的各种包
yum -y remove httpd httpd-devel php55w php55w-devel php55w-mysql mysqld55w-server mysql55w mysql55w-server

安装
yum -y install httpd httpd-devel php55w php55w-devel php55w-mysql mysqld55w-server mysql55w mysql55w-server

2、出现 yum安装出现 Error: xz compression not available

解决方法:

参考这个帖子https://my.oschina.net/iceTear/blog/1162681

3、phpMyAdmin里边出现 没有找到 PHP 扩展 mbstring,而您现在正在使用多字节字符集。

解决方法:

yum install php55w-mbstring

php -m 可以查看当前php 支持的扩展

4、phpMyAdmin 配置文件现在需要一个短语密码。

解决方法:

1、将 phpMyAdmin/libraries/config.default.php中的

$cfg['blowfish_secret'] = ''; 改成 $cfg['blowfish_secret'] = 'aaaaa'; (注:其中的'ithov.com′为随意的字符)

2、在phpMyAdmin目录中,打开config.sample.inc.php,18行

$cfg['blowfish_secret'] = ''; 改成 $cfg['blowfish_secret'] = 'aaaaa'; (注:其中的'ithov.com′为随意的字符)

这个密码用于Cookies的加密,以免多个PhpMyAdmin或者和其他程序共用Cookies时搞混。


5、重启apach服务器出现下面警告
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

解决方法:

echo "ServerName admin" >> /etc/httpd/conf/httpd.conf

给服务器设置个名字即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息