当前位置首页 > Apache知识

CentOS7.0安装配置LAMP服务器方法(Apache+PHP+MariaDB)

阅读次数:260 次  来源:admin  发布时间:

一、配置防火墙,开启80端口、3306端口

CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。

1、关闭firewall:

#停止firewall服务

ystemctl stop firewalld.service

#禁止firewall开机启动

ystemctl disable firewalld.service

2、安装iptables防火墙

#安装

yum install iptables-service

#编辑防火墙配置文件

vi /etc/sysconfig/iptable

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-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

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

:wq! #保存退出

#最后重启防火墙使配置生效

ystemctl restart iptables.service

#设置防火墙开机启动

ystemctl enable iptables.service

二、关闭SELINUX

#修改配置文件

vi /etc/selinux/config

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq! #保存退出

#使配置立即生效

etenforce 0

三.安装apache

yum install httpd

可能会用到的:

ystemctl start httpd.service #启动apache

ystemctl stop httpd.service #停止apache

ystemctl restart httpd.service #重启apache

ystemctl enable httpd.service #设置apache开机启动

restart一下,然后:

输入localhost

出现之后代表已经安装上去了。

四.安装mysql

方法参考

http://blog.itpub.net/29773961/viewspace-1248176/

方法大致相同

在centos7中可以用:

rpm -ivh mysql-community-release-el6-5.noarch.rpm

关于这一步骤,在目前能够找到的centos7配置教程上,大多都是安装mariadb,因为centos7默认将mariadb视作mysql。

.s.因为mysql被oracle收购后,原作者担心mysql闭源,所以又写了一个mariadb,这个数据库可以理解为mysql的分支。

我在此处还是安装mysql

如果需要安装mariadb,只需通过yum就可。

五.安装ph

yum install ph

安装PHP组件,使PHP支持mysql

yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

重启对应服务

ystemctl restart mysqld.service systemctl restart httpd.service

上一篇:【转载】Linux中功能强大的截图工具:Flameshot
下一篇:Linux根目录详解-转自鸟哥的私房菜-linuxSu