Cen OS6 系统下安装LAMP

2017-07-07  本文已影响0人  冰泪

一、个别电脑可能有防火墙限制导致不能安装

查看防火墙关闭状态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密码

   1>知道初始密码  通过登录mysql系统,

# mysql -u root -p  password:

【输入原来的密码】

# use mysql;

# update user set password=password("test") where user='root';

#  flush privileges;

#  exit;

   2>忘记原来的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配置系统在引导时启动

# chkconfig--levels 235 httpd on

3、启动Apache

#  /etc/init.d/httpdstart

然后浏览器输入 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-xmlphp-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 -yinstall httpd httpd-devel php55w php55w-devel php55w-mysql mysqld55w-servermysql55w mysql55w-server

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

解决方法:

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

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

解决方法:

#  yuminstall php55w-mbstringphp -m 可以查看当前php 支持的扩展

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

解决方法:

1、将 phpMyAdmin/libraries/config.default.php中的$cfg['blowfish_secret'] =''; 改成 $cfg['blowfish_secret'] ='aaaaa'; (注:其中的'aaa′为随意的32位字符 否则会警告太短)

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

$cfg['blowfish_secret'] = ''; 改成 $cfg['blowfish_secret'] = 'aaaaa'; (注:其中的'aaaaa′为随意的字符)这个密码用于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

给服务器设置个名字即可

6、由于端口受限 不能访问的 参考以下帖子 开启端口的方法

http://www.jianshu.com/writer#/notebooks/11663044/notes/14293774

上一篇下一篇

猜你喜欢

热点阅读