惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
Y
Y Combinator Blog
The Cloudflare Blog
V
V2EX
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
T
Tailwind CSS Blog
P
Privacy International News Feed
S
Securelist
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tor Project blog
P
Proofpoint News Feed
Project Zero
Project Zero
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
美团技术团队
The GitHub Blog
The GitHub Blog
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Latest
Security Latest
NISL@THU
NISL@THU
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Secure Thoughts
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
IT之家
IT之家
Last Week in AI
Last Week in AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CERT Recently Published Vulnerability Notes
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy & Cybersecurity Law Blog
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
S
Schneier on Security
L
Lohrmann on Cybersecurity
S
Security Affairs
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG

博客园 - 子墨老师

基于Hutool的poi导出excel表格【升级更新】 如何设置wps单元格下拉选项设置 Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException: Encryption raised an exception ZoomIt的使用与快捷键 springboot项目中使用Java 8的日期时间API 基于springboot系统,如何跟踪会话过期,浏览器会话标识是否收到正常响应,存储,并在后续请求保持携带 SpringBoot+MyBatis实现数据库字段加密 Vue2中能否实现输入中文自动转化为拼音, 且不带音调 Excel导出问题:accessExternalStylesheet 解构赋值+扩展运算符在数组和对象上的应用例子 收藏一下JDK下载地址 介绍几个axios接口请求顺序的问题 vue cli的介绍 Failed to start nginx.service: Unit nginx.service not found. 如何实现文件批量重命名后再进行批量打包下载 如何能成功在centos7下安装nodejs18+以上版本 centos7下卸载nodejs源码包 基于ConcurrentMap锁机制的NFS文件合并方案 基于ConcurrentMap锁机制的NFS分片上传方案 如何将已经存在的本地项目源码关联到远程git仓库中 gitee如何使用
centos7安装php+wordpress
子墨老师 · 2025-06-10 · via 博客园 - 子墨老师

今天记录一篇自己在centos7上安装php+wordpress的过程

1.先准备好mysql57数据库,这个步骤省略。如果不知道如何安装mysql57,请参考我的博客:centos7下安装mysql - 子墨老师 - 博客园

2.我们需要安装一个 PHP 模块以确保其正常工作。没有这个模块,WordPress 将无法调整图像大小来创建缩略图

#这个的安装展示不用,因为安装php版本太低
sudo yum install php-gd

3.安装apache,即httpd

yum install -y httpd

4.赶快坚持httpd是否能正常启动

[root@LiuXin ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)

如果出现上面错误,请检查默认的端口80是否被占用

[root@LiuXin ~]# sudo netstat -tulnp | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1020/nginx: master
tcp6       0      0 :::80                   :::*                    LISTEN      1020/nginx: master

通过检查端口号命令,发现80端口被nginx占用,则我们就把apache端口改为8899

sudo vi /etc/httpd/conf/httpd.conf

搜索 Listen 指令

Listen 80

将监听端口修改为8899,然后再检查当前的apache的状态。如果你发现有下面的错误,就需要修改selinux,让其授权8899端口号

5.解决SELinux端口授权限制

# 添加 SELinux 策略允许 8899 端口
sudo semanage port -a -t http_port_t -p tcp 8899

# 若提示命令不存在,先安装工具包
sudo yum install policycoreutils-python -y

一般通过上面的命令提示,我们apache状态就恢复正常

6.安装PHP+WordPress

注意:最新的WordPress版本至少要求PHP7+以上的版本。推荐:PHP7.4.33

# 安装 EPEL 仓库
sudo yum install -y epel-release

# 添加 Remi 仓库(PHP 7.4 官方源)
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
#启用PHP7仓库
sudo yum-config-manager --enable remi-php74
#安装 PHP 7.4.33 及核心扩展
sudo yum install -y php php-cli php-fpm php-mysqlnd php-gd php-mbstring php-curl php-xml

安装完成PHP环境,我们再按照下面的步骤进行wordpress下载和安装

cd ~
wget http://wordpress.org/latest.tar.gz

提取归档文件

tar xzvf latest.tar.gz

通过rsync将wordpress文件传输到/var/www/html中

sudo rsync -avP ~/wordpress/ /var/www/html/

添加一个上传存储文件的目录

mkdir /var/www/html/wp-content/uploads

对文件进行正确的授权

sudo chown -R apache:apache /var/www/html/*

修改wordpress的配置文件

cd /var/www/html
cp wp-config-sample.php wp-config.php

编辑wp-config.php文件,将连接数据库部分的信息进行修改

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

我们还需配置访问index.php的主页,将默认加载index.html修改为index.php

#设置 WordPress 入口文件优先级
DirectoryIndex index.php index.html index.htm

如果重新启动httpd还有问题,比如页面出现500错误等等,请查看日志进行具体分析

sudo tail -f /var/log/httpd/error_log

访问成功的主页如下