centos6.5 搭建lamp环境

时间:2022-03-25 12:58:22

1、卸载原来安装的PHP5.3
#yum -y remove php*
2、配置yum源追加CentOS 6.5的epel及remi源
# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
3、安装apache
yum install httpd
4、安装PHP5.6
# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-gd php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
5、PHP查看版本
# php -v
PHP 5.6.0 (cli) (built: Sep 3 2014 19:51:31)
6、安装mysql5.6
1.检测系统是否自带安装mysql
# yum list installed | grep mysql
2.如果发现有系统自带mysql,先卸载。
# yum -y remove mysql-libs.x86_64
3.下载mysql5.6
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# rpm -ivh mysql-community-release-el6-5.noarch.rpm
4.安装mysql 服务器命令:
# yum install -y mysql-community-server
5.安装成功后
# service mysqld start
6.查看mysql是否自启动,并且设置开启自启动命令
# chkconfig --list | grep mysqld
# chkconfig mysqld on
7.navicat连接mysql
首先配置CentOS下防火墙iptables规则:
# vim /etc/sysconfig/iptables
向其中加入下列规则:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
说明:防火墙开放http用的80端口和连接MySql的3306端口。
# service iptables restart
然后配置MySQL允许远程登陆:
先在CentOS中连接Mysql数据库
# mysql -uroot -proot
执行
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY'123456' WITH GRANT OPTION;
再执行下
> flush privileges;