转载自:

Centos7安装配置Apache+PHP+Mysql+phpmyadmin

一、安装Apache

yum install httpd

安装成功后,Apache操作命令:

systemctl start httpd      //启动apache
systemctl stop httpd //停止apache
systemctl restart httpd //重启apache
systemctl enable httpd //设置apache开机启动

异常处理
我再阿里云上配置并出现启动Apache后无法访问的问题,但是一般服务器访问Apache可能需要如下操作:
(1)在防火墙中开放80端口
现在需要将 http 服务加入防火墙以允许外部访问,

firewall-cmd --add-service=http --permanent

–permanent 参数表示这是一条永久防火墙规则,如果不加则重启系统后就没有这条规则了。

而对于自定义的端口(如81),也需要添加防火墙规则,

firewall-cmd --zone=public --add-port=81/tcp --permanent

重启 Firewalld 使该规则生效,

systemctl restart firewalld

(2)关闭SELINUX

vi /etc/selinux/config

注释掉如下两句,添加最后一项

\#SELINUX=enforcing #注释掉
\#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加

:wq! 保存退出

输入如下命令

setenforce 0 #使配置立即生效

二、 安装MariaDB (MySQL的一个开源分支)

yum install mariadb mariadb-server

MariaDB安装成功后,需要配置MySQL的root密码,此外,备注一下启动关闭MariaDB的常用命令

systemctl start mariadb     //启动MariaDB
systemctl stop mariadb //停止MariaDB
systemctl restart mariadb //重启MariaDB
systemctl enable mariadb //设置开机启动

设置root账户密码

mysql_secure_installation

Enter current password for root (enter for none):
Set root password? [Y/n]

点击回车然后提示是否设置root账号密码,输入y

New password:
Re-enter new password:
Password updated successfully!

提示输入新密码和重复输入新密码,重复输入两次后,出现更新密码成功提示。

然后一路输入y就可以。

Remove anonymous users? [Y/n] y
... Success!

Disallow root login remotely? [Y/n] y
... Success!

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reload privilege tables now? [Y/n] y
... Success!

Thanks for using MariaDB!

设置root密码后,重启MariaDB生效

systemctl restart mariadb.service

测试访问数据库:

mysql -uroot -p

然后输入密码,登录成功后显示如下:

Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

输入如下命令,查看数据库服务器的数据库

show databases;

退出命令:

exit;

三、安装PHP以及PHP拓展

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

安装完成后,重启Apache服务器

systemctl restart httpd.service

测试PHP安装结果

vi /var/www/html/index.php

输入如下内容

<?php
phpinfo();
?>

输入:wq! 保存退出
在浏览器中输入服务器地址,查看是否可以看到:

页面效果

四、安装phpmyadmin

使用yum安装phpmyadmin

yum install phpmyadmin php-mcrypt

phpMyAdmin 的默认安装目录是 /usr/share/phpMyAdmin,同时会在 Apache 的配置文件目录中自动创建虚拟主机配置文件 /etc/httpd/conf.d/phpMyAdmin.conf(区分大小写)。默认情况下,CentOS 7上的phpMyAdmin只允许从回环地址(127.0.0.1)访问。为了能远程连接,你需要改动它的配置。

vi /etc/httpd/conf.d/phpMyAdmin.conf

修改配置文件,如下:

<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8 <IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
# Require ip 127.0.0.1 #注释掉
# Require ip ::1 #注释掉
Require all granted #新添加
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory> <Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#Require ip 127.0.0.1 #注释掉
#Require ip ::1 #注释掉
Require all granted #新添加
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>

然后重启Apache服务器

systemctl restart httpd

然后就可以通过浏览器访问http://服务器ip地址/phpmyadmin访问

访问phpmyadmin页面

作者:TyiMan
链接:http://www.jianshu.com/p/bc14ff0ab1c7
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Centos7安装配置Apache+PHP+Mysql+phpmyadmin的更多相关文章

  1. 虚拟机下安装Centos7并配置Apache+PHP+Mysql+phpmyadmin+wordpress

    一.安装Apache yum install httpd 安装成功后,Apache操作命令: systemctl start httpd //启动apache systemctl stop httpd ...

  2. Centos7 安装配置Apache+Mysql5.7+PHP7.0+phpmyadmin

    Centos7 下安装配置Apache+Mysql5.7+PHP7.0+phpmyadmin 搭建LAMP =========================================Apach ...

  3. Ubuntu 15.04 安装配置Apache和mysql的方法

    前 言 上篇海面特效的博文结尾提到了SideFX开发的HQueue分布式集群,配置HQueue首先需要安装mysql,所以今天先分享一下如何在Ubuntu系统中安装mysql和Apache: Ubun ...

  4. Ubuntu 麒麟版下安装:Apache+php5+mysql+phpmyadmin.

    摘要 LAMP是Linux web服务器组合套装的缩写,分别是Apache+MySQL+PHP.此文记录在Ubuntu上安装Apache2服务器,包括PHP5(mod_php)+MySQL+phpmy ...

  5. Windows下安装配置Apache+PHP+Mysql环境

    1.下载相关安装包 Apache下载: http://archive.apache.org/dist/httpd/binaries/win32/ ,选择httpd-2.2.25-win32-x86-n ...

  6. CentOS7安装配置Apache、PHP和MySQL

    一.安装Apache sudo yum install httpd 安装成功后,Apache操作命令: systemctl start httpd //启动apache systemctl stop ...

  7. CentOS7安装配置Apache HTTP Server

    RPM安装httpd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 # yum -yinstall http ...

  8. Centos6.5 下安装配置Apache+PHP+Mysql环境

    1.准备工作 # yum -y update && yum -y install vim make cmake gcc gcc-c++ bison bison-devel ncurse ...

  9. centos7 安装配置rsyslog + LogAnalyzer + mysql

    https://www.cnblogs.com/mchina/p/linux-centos-rsyslog-loganalyzer-mysql-log-server.html 安装LNMP 一键安装包 ...

随机推荐

  1. C++ for循环与迭代器

    1.基本的for循环 std::vector<int> arr; ... for(std::vector<int>::iterator it=arr.begin();it!=a ...

  2. slideDown留言板

    <!doctype html> <html lang="en"> <head> <meta http-equiv="Conten ...

  3. 从实践出发:微服务布道师告诉你Spring Cloud与Spring Boot他如何选择

    背景 随着公司业务量的飞速发展,平台面临的挑战已经远远大于业务,需求量不断增加,技术人员数量增加,面临的复杂度也大大增加.在这个背景下,平台的技术架构也完成了从传统的单体应用到微服务化的演进. 系统架 ...

  4. 安装使用zookeeper

    1,加压 2,复制zoo_sample.cfg命名为zoo.cfg 3,在conf同级目录下新建一文件夹 data 4,修改数据存放目录 5,启动zookeeper

  5. ManyToManyField 增加记录

    class BOMView(View): def get(self,request): obj=BOMForm() return render(request,'bom.html',{'obj':ob ...

  6. 简单了解一下php的迭代生成器yield

    yield是从PHP5.5开始有的,关于yidle的说明鸟哥的博客做了详细说明,我觉得是有点复杂,在看了几篇其他的帖子还有案例,我大概知道yield的作用就是在做大量数据循环处理的时候,能节省很大一部 ...

  7. 关于typeid和typeof

    typeid和typeof是c++/gcc编译器的两个关键字,也就是操作符,所以他们根本就不会声明在头文件中. 只不过typeid返回的是type_info,它定义在<typeinfo>头 ...

  8. unknown variable 'log_bin_basename'

    今天在处理一问题时,在my.cnf中设置了log_bin_basename=/DATA/log-bin,在启动时报unknown variable 'log_bin_basename' 经查mysql ...

  9. 问题:oracle 12c rac数据库服务器的home目录丢失问题解决2018-06-25 18:30

    问题原因:是由于运维粗心,在缩容/home(此目录下挂载了逻辑卷lv_home)时没有先缩小文件系统(resize2fs)也没有备份,导致home数据损坏,重启时系统无法正常启动 解决方案:跳过此ho ...

  10. javaScript中ajax、axios总结

    一.原生js实现ajax请求: 步骤: get请求: // 1.创建一个XMLHttpRequest的对象. var xml=null; //初始值设为空 if(XMLHttpRequest){ xm ...