您的位置:首页 > 运维架构 > Linux

centos 7中搭建Lamp环境(php5.6+marisdb)

2017-02-17 14:36 393 查看
1、安装apache:

yum install -y httpd


启动服务:

systemctl start httpd.service


设置开启启动服务:

systemctl enable httpd.service


下面就是修改配置文件可以直接命令在控制台修改:

vi /etc/httpd/conf/httpd.conf


也可以直接进入/etc/httpd/conf/中用gedit打开修改;

修改好保存后重启apache:

systemctl restart httpd.service


因为centos将防火墙改为firewall,所以要先改为iptables防火墙:

1、关闭firewall,停止firewall服务:

systemctl stop firewalld.service


禁止firewall开机启动:

systemctl disable firewalld.service


2、安装iptables防火墙

yum install iptables-services


安装好后就需要修改编辑防火墙配置文件(这里不做介绍了直接使用控制台vi命令修改):

vi /etc/sysconfig/iptables




保存修改之后再打开config文件进行修改:

vi /etc/selinux/config


将SELINUX=enforcing和SELINUXTYPE=targeted注释掉,并添加SELINUX=disabled;保存退出后执行setenforce 0立即生效;

2、安装mariadb:

yum -y install mariadb-server mariadb


安装好开始启动:
systemctl start mariadb.service


设置开机启动:
systemctl enable mariadb.service


覆盖配置文件:
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf


数据库初始密码是没有的,若是想修改密码执行:

mysql_secure_installation


然后开始进入数据库,注意初始密码为空;后面的自己设好密码一路y就行;

3、安装php

首先追加配置yum源:

yum install epel-release

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm[/code] 
使用yum list命令查看可安装的包(Packege):

yum list --enablerepo=remi --enablerepo=remi-php56 | grep php


看到里面有php56的就可以进行php5.6版本的安装了:

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof


那装过后可以使用php –version来查看php版本,安装成功就可以看到对应版本了;

最后可以安装下php -fpm:

yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php apache centos lamp