一、配置防火墙,开启80端口、3306端口
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、安装iptables防火墙
yum install iptables-services #安装
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
:wq! #保存退出
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
二、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
安装篇:
一、安装Apache

系统运维 www.111cn.net 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链
yum install httpd #根据提示,输入Y安装即可成功安装
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
在客户端浏览器中打开服务器IP地址,会出现下面的界面,说明apache安装成功

系统运维 www.111cn.net 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链
二、安装MariaDB
CentOS 7.0中,已经使用MariaDB替代了MySQL数据库
1、安装MariaDB

yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
2、为root账户设置密码

mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:
systemctl restart mariadb.service #重启MariaDB
三、安装PHP
1、安装PHP

yum install php #根据提示输入Y直到安装完成
2、安装PHP组件,使PHP支持 MariaDB
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#这里选择以上安装包进行安装,根据提示输入Y回车
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
配置篇
一、Apache配置
vi /etc/httpd/conf/httpd.conf #编辑文件
ServerSignature On #添加,在错误页中显示Apache的版本,Off为不显示
Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None #修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
#Options Indexes FollowSymLinks #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htmindex.php(设置默认首页文件,增加index.php)
MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数)
:wq! #保存退出
systemctl restart httpd.service #重启apache
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页
二、php配置
vi /etc/php.ini #编辑
date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #禁止显示php版本的信息
short_open_tag = ON #支持php短标签
open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.111cn.net/:/tmp/
:wq! #保存退出
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
测试篇
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!

注意:apache默认的程序目录是/var/www/html
权限设置:chown apache.apache -R /var/www/html
相关推荐
在CentOS 7上使用yum安装LAMP(Linux, Apache, MariaDB/MySQL, PHP)环境是一种常用的方式来搭建动态网站或应用。LAMP环境能够支持多种动态网站和应用的运行,包括流行的WordPress, Drupal等。CentOS(Community ...
【从零开始部署CentOS7+Apache+PHP+MariaDB+HTTPS】 这篇文章将引导你逐步完成在CentOS7系统上搭建一个基于Apache服务器、PHP处理脚本语言、MariaDB数据库服务以及启用HTTPS安全协议的过程。以下是详细的步骤: 1....
在CentOS 7上安装MySQL(或MariaDB)的过程同样非常直接,使用yum install mysql即可。安装完成后,需要运行mysql_secure_installation脚本来设置root密码,以及进行其他安全设置。 PhpMyAdmin是一个用于管理MySQL...
需要注意的是,在CentOS 7中MySQL已被MariaDB替代,但在CentOS 6中仍可使用原版MySQL。 ##### 步骤1:检查是否已安装MySQL ```bash yum list installed mysql* rpm -qa | grep mysql* ``` 以上两条命令分别用于...
本文将详细介绍如何在 Centos7 系统上搭建一个完整的 PHP 开发环境,包括 Apache HTTP Server、MySQL 数据库以及 PHP 解释器的安装和配置过程。 #### 二、准备工作 - **硬件需求**:一台 Centos7 服务器。 - **...
在Linux操作系统环境下搭建LAMP(Linux, Apache, MariaDB/MySQL, PHP)环境是许多网络应用开发与部署的基本步骤,尤其是在使用CentOS 7系统时。LAMP环境的搭建主要分为三个部分,分别是安装和配置Apache Web服务器、...
在本教程中,我们将详细讲解如何在64位的CentOS 7系统上安装Apache、MariaDB(替代MySQL)和PHP 5.6。这个过程对于开发者和系统管理员来说非常实用,因为它提供了一种标准的方式来配置一个LAMP(Linux、Apache、...
其次,安装 MySQL,因为 Centos 7 中的 MySQL 需要付费,因此我们安装 MariaDB,可以使用命令 `yum install -y mariadb mariadb-server`。然后,需要设置 MariaDB 服务开机自启动,可以使用命令 `systemctl enable ...
CentOS 7 使用 OwnCloud 安装个人云服务 在本文中,我们将介绍如何在 CentOS 7 上使用 OwnCloud 安装个人云服务。OwnCloud 是一个开源的云存储解决方案,允许用户在自己的服务器上存储和管理文件。 安装必要的 PHP...
首先,本篇文章详细介绍了在CentOS 6.2系统上使用YUM包管理器安装LAMP(Linux、Apache、MySQL/MariaDB、PHP)环境以及phpMyAdmin的全过程。LAMP环境是网站开发中常用的服务器端软件组合,phpMyAdmin是一款用于管理...
3. **安装MySQL或MariaDB**:Bugzilla需要数据库存储数据,可以使用MySQL或MariaDB。如果是首次安装,执行: ``` sudo yum install -y mysql-server sudo systemctl start mysqld sudo mysql_secure_...
通常在安装一个WEB运行环境时太过于麻烦,要整理脚本安装...同时更新了由于CENTOS停止维护后不能安装的问题,内部做了YUM源的重新配置,具体内容请看博客https://blog.csdn.net/wanghaisheng/article/details/114884965
在 CentOS 7 中,我们使用默认的 MariaDB 数据库: 1. 安装 MariaDB 服务器并启动: ``` yum install mariadb-server -y systemctl enable --now mariadb ``` 2. 配置 MariaDB 安全选项并设置 root 密码: ``` mysql...
### CentOS 7.2 SVN+Mysql+Apache+PHP 版本管理工具安装配置知识点 #### 一、准备工作 在开始安装配置之前,确保以下条件得到满足: 1. **服务器可以连接到Yum源**:这一步至关重要,因为后续安装过程中会依赖Yum...
- 使用MariaDB作为MySQL的替代品,CentOS官方使用yum安装mariadb-server和mariadb-client。 - 配置MariaDB官方yum源,安装mariadb10.3.5版本。 - 启动并设置开机启动mariadb服务。 5. Web服务器(Apache)和PHP的...
CentOS 7 安装 Zabbix 3.0 超详细步骤解析 安装前准备 在安装 Zabbix 3.0 之前,需要安装依赖包,包括 `wget`、`net-snmp-devel`、`OpenIPMI-devel`、`httpd`、`openssl-devel`、`java`、`lrzsz`、`fping-devel`、...
4. **安装MySQL(MariaDB)**:由于CentOS 7中MySQL被MariaDB替代,所以运行`yum -y install mariadb*`进行安装。启动MariaDB服务`systemctl start mariadb.service`,设置开机启动`systemctl enable mariadb....
CentOS 7 中 Hive 的安装和使用 Hive 是一个基于 Hadoop 的数据仓库工具,主要用于存储、查询和分析大规模数据。下面将详细介绍 CentOS 7 中 Hive 的安装和使用。 1. 安装 MySQL 在安装 Hive 之前,需要先安装 ...