云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > centos7配置APache+PHP+mysql

centos7配置APache+PHP+mysql

  • 62 次阅读
  • 3 次下载
  • 2025/6/4 4:06:36

Centos7 配置apache+php+mysql 一.准备工作

1.先关闭firewall

Systemctl stop firewalld.service (7)之前是service firewalld stop 2.禁止firewall 开机启动

System disable firewalld.service 3.安装IPtables防火墙

yum install iptables-services 4.配置我们的IP防火墙 Vi /etc/sysconfig/iptables

# 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

5.重新防火墙配置生效

Systemctl restart iptables.service Systemctl enable iptables.service 6.关闭selinux

修改配置文件

Vi /etc/selinux /config

注释掉#SELINUX=enforcing #SELINUXTYPE=targeted 添加SELINUX=disabled Wq存盘退出

Setenforce 0 使配置立即生效

二.安装APache Yum install httpd

安装完成后Apache是以HTTPD服务的形式存在的,我们要想把Apache先停止后启动并且设置为开启启动

Systemctl start httpd.service 启动

Systemctl enable httpd.service 开机启动 查看HTTP服务状态的话 Systemctl status httpd.service

注意:下面的httpd.conf这个文件的内容修改的时候要注意 1.做注释的是后最好在上一行或者下行用#做注释

2.做注释的时候千万不要在一个函数里面做标识比如:

AllowOverride none 这边就是不能做注释 Require all denied

下面我们来编辑下我们的httpd.conf

首先先vi /etc/httpd/conf/httpd.conf 会看见下面的配置文件(有些地方我已经做过了修改)

配置好我们的文件后,要测试下我们的这个文本的语法有没有错误: Apachectl configtest

然后,重新启动我们的HTTPd服务 Systemctl restart httpd

注意:我们在检查文本有没有错误的时候发现

我们就要重新去修该下我们的httpd这个服务

只要找到我们的ServerName localhost:80 将其改为localhost:80就ok 了 然后再重新启动下

Systemctl restart httpd.service

三.安装PHP Yum install php

安装完成后我们就要配置下面php.conf 10-php.conf 先配置下我们的php.conf Vi /etc/httpd/conf.d/php.conf #

# Cause the PHP interpreter to handle files with a .php extension.

#文件名与正则表达式相匹配的文件,将适用这里设定的语句

SetHandler application/x-httpd-php

#SetHandler强制所有的匹配的文件使用指定的hander进行处理 # Allow php to handle Multiviews

#设置扩展名为.php的档案类型为text/html AddType text/html .php #

# Add index.php to the list of files that will be served as directory # indexes.

#默认网页文档名添加index.php DirectoryIndex index.php

#

# SetHandler application/x-httpd-php-source # #

# Apache specific PHP configuration options # those can be override in each configured vhost #

php_value session.save_handler \

php_value session.save_path \

搜索更多关于: centos7配置APache+PHP+mysql 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Centos7 配置apache+php+mysql 一.准备工作 1.先关闭firewall Systemctl stop firewalld.service (7)之前是service firewalld stop 2.禁止firewall 开机启动 System disable firewalld.service 3.安装IPtables防火墙 yum install iptables-services 4.配置我们的IP防火墙 Vi /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customizat

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com