设为首页 收藏本站
查看: 1252|回复: 0

Centos7安装WordPress(一)安装Apache, PHP And MySQL(LAMP)

[复制链接]
累计签到:4 天
连续签到:1 天
发表于 2015-11-15 16:01:09 | 显示全部楼层 |阅读模式
Centos7安装WordPress(一)安装Apache, PHP And MySQL(LAMP)
  ==================================================
  在前两篇博客中介绍了CentOS6安装WordPress的方法,由于更换了个人博客的VPS,所以想试一下CentOS7下安装WordPress,折腾了半天总算成功了。安装的过程与CentOS6的差不多,不过有许多细节需要注意。

CentOS6下的安装与配置请参考

Centos6安装WordPress(一)Apache,Mysql, PHP环境搭建

Centos6安装WordPress(二)WordPress安装
1.安装Apache
  利用yum命令安装Apache

yum -y install httpd
  启动httpd并且设置为开机启动


systemctl start httpd.service
systemctl enable httpd.service
  安装成功后,可以看到熟悉的测试界面

DSC0000.jpg
  另外,还需要配置一下防火墙,打开80和443端口

首先安装firewall


yum -y install firewalld firewall-config
systemctl start firewalld.service
systemctl enable firewalld.service
  配置防火墙

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

  另外,如果对新的firewall配置不熟悉,或者想要使用原来的iptables也是可以的,利用一下命令便可以继续使用iptables service

systemctl stop firewalld
systemctl disable firewalld
iptables-service
touch /etc/sysconfig/iptables
systemctl start iptables
systemctl enable iptables
touch /etc/sysconfig/ip6tables
systemctl start ip6tables
systemctl enable ip6table


2.安装Mariadb
  同样还是利用yum命令进行安装,并且配置开机启动

yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service
  下面配置root密码


mysql_secure_installation
  安装过程中会有几个选项,大家根据自己的需要进行配置就好了

Enter current password for root (enter for none):(输入原始root密码,若无enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] (是否设置root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] (是否移除匿名用户)
... Success!
Disallow root login remotely? [Y/n] (是否禁止远程root登陆)
... skipping.
Remove test database and access to it? [Y/n] (是否删除测试数据库)
Reload privilege tables now? [Y/n] (重新载入)
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!


3.安装PHP
  首先安装PHP及常用组件

yum -y install php

  查看所有组件

yum search php

DSC0001.jpg
  选择所需组件进行安装

yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
  完成后我们可以新建一个PHP页面查看安装的组件


vi /var/www/html/info.php
  编辑为以下内容

<?php
phpinfo();
?>

  重启httpd服务

systemctl restart httpd.service

  打开网址 http://x.x.x.x/info.php 进行查看(x.x.x.x为vps的ip地址)
4.安装PHPMyAdmin(可选)
  phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。借由此Web接口可以成为一个简易方式输入繁杂SQL语法的较佳途径,尤其要处理大量资料的汇入及汇出更为方便。其中一个更大的优势在于由于phpMyAdmin跟其他PHP程式一样在网页服务器上执行,但是您可以在任何地方使用这些程式产生的HTML页面,也就是于远端管理MySQL数据库,方便的建立、修改、删除数据库及资料表。也可借由phpMyAdmin建立常用的php语法,方便编写网页时所需要的sql语法正确性。
  首先要安装EPEL的源(注意要选择CentOS7的)

rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm  
  安装并配置phpMyAdmin

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

  注释掉原来的部分配置文件,修改为以下格式:

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#<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
#     </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/>
Options none
AllowOverride Limit
Require all granted
</Directory>

  修改认证方式(将 cookie 修改为 http)


vi /etc/phpMyAdmin/config.inc.php
[...]
$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)?
[...]

  重启http服务

systemctl restart  httpd.service

  然后可以在浏览器中输入http://x.x.x.x/phpMyAdmin 利用前面设置的用户(root)和密码进行登录,登陆后下图:

DSC0002.jpg
  至此,我们就完成了环境配置。

版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139605-1-1.html 上篇帖子: Linux学习笔记:LAMP 1 环境配置 下篇帖子: AWS: 安装 LAMP Web 服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表