如何在Fedora 38上安装WordPress

Linux命令 Edge插件网 1年前 (2023-10-15) 364次浏览 已收录 0个评论

WordPress是一个功能强大且流行的内容管理系统(CMS),可让您轻松创建和管理网站。将其与Fedora 38,Nginx,PHP 8和MariaDB相结合,为您的WordPress网站提供了一个强大而安全的环境。

如何在Fedora 38上安装WordPress

在Fedora 38上安装WordPress

第 1 步。在我们可以在Fedora 38上安装WordPress之前,重要的是要确保我们的系统是最新的软件包。这将确保我们可以访问最新功能和错误修复,并且我们可以毫无问题地安装 WordPress:

<span class="pln">sudo dnf update</span>

第 2 步。安装Nginx。

Nginx是一个高性能的Web服务器,以其可靠性和速度而闻名。让我们安装它:

<span class="pln">sudo dnf install nginx
sudo systemctl start nginx
sudo systemctl enable nginx</span>

第 3 步。安装 PHP。

PHP 8 是最新的 PHP 版本,提供性能改进和增强的安全性。安装 PHP 8 和必要的扩展:

<span class="pln">sudo dnf install php php</span><span class="pun">-</span><span class="pln">fpm php</span><span class="pun">-</span><span class="pln">mysqlnd php</span><span class="pun">-</span><span class="pln">opcache php</span><span class="pun">-</span><span class="pln">gd php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">json
sudo systemctl start php</span><span class="pun">-</span><span class="pln">fpm
sudo systemctl enable php</span><span class="pun">-</span><span class="pln">fpm</span>

验证 PHP 安装:

<span class="pln">php </span><span class="pun">-</span><span class="pln">v</span>

第 4 步。安装 MariaDB。

MariaDB是MySQL的直接替代品,也是WordPress的绝佳选择。安装 MariaDB 并保护安装:

<span class="pln">sudo dnf install mariadb mariadb</span><span class="pun">-</span><span class="pln">server
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation</span>

这将安装 MariaDB 启动它,并保护安装。按照提示设置root密码并提高安全性。

接下来,为 WordPress 创建一个 MariaDB 数据库和用户:

<span class="pln">sudo mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>

输入您的 root 密码,然后执行以下 SQL 命令:

<span class="pln">CREATE DATABASE wordpress_db</span><span class="pun">;</span><span class="pln">
CREATE USER </span><span class="str">'wordpress_user'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span><span class="pln">
GRANT ALL PRIVILEGES ON wordpress_db</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'wordpress_user'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span><span class="pln">
FLUSH PRIVILEGES</span><span class="pun">;</span><span class="pln">
EXIT</span><span class="pun">;</span>

这将创建一个名为“”的数据库,即用户“”,并授予必要的权限。wordpress_dbwordpress_user

第5步。在Fedora 38上安装WordPress。

让我们获取最新的WordPress版本并设置其配置文件:

<span class="pln">cd </span><span class="pun">/</span><span class="pln">tmp
wget https</span><span class="pun">:</span><span class="com">//wordpress.org/latest.tar.gz</span><span class="pln">
tar </span><span class="pun">-</span><span class="pln">xvzf latest</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz
sudo mv wordpress </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span>

然后,创建一个配置文件并设置数据库:

<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wordpress
cp wp</span><span class="pun">-</span><span class="pln">config</span><span class="pun">-</span><span class="pln">sample</span><span class="pun">.</span><span class="pln">php wp</span><span class="pun">-</span><span class="pln">config</span><span class="pun">.</span><span class="pln">php
nano wp</span><span class="pun">-</span><span class="pln">config</span><span class="pun">.</span><span class="pln">php</span>

使用数据库详细信息编辑文件:

<span class="pln">define</span><span class="pun">(</span><span class="str">'DB_NAME'</span><span class="pun">,</span> <span class="str">'wordpress_db'</span><span class="pun">);</span><span class="pln">
define</span><span class="pun">(</span><span class="str">'DB_USER'</span><span class="pun">,</span> <span class="str">'wordpress_user'</span><span class="pun">);</span><span class="pln">
define</span><span class="pun">(</span><span class="str">'DB_PASSWORD'</span><span class="pun">,</span> <span class="str">'your_strong_password'</span><span class="pun">);</span>

第 6 步。为 WordPress 配置 Nginx。

要为 WordPress 配置 Nginx,请创建一个服务器块配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">wordpress</span><span class="pun">.</span><span class="pln">conf</span>

添加以下配置:

<span class="pln">server </span><span class="pun">{</span><span class="pln">
    listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln">
    server_name your_domain</span><span class="pun">.</span><span class="pln">com www</span><span class="pun">.</span><span class="pln">your_domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span><span class="pln">

    root </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wordpress</span><span class="pun">;</span><span class="pln">
    index index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span><span class="pln">

    location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln">
        try_files $uri $uri</span><span class="pun">/</span> <span class="pun">/</span><span class="pln">index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">?</span><span class="pln">$args</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span><span class="pln"> \.php$ </span><span class="pun">{</span><span class="pln">
        include fastcgi_params</span><span class="pun">;</span><span class="pln">
        fastcgi_pass unix</span><span class="pun">:</span><span class="str">/var/</span><span class="pln">run</span><span class="pun">/</span><span class="pln">php</span><span class="pun">-</span><span class="pln">fpm</span><span class="pun">/</span><span class="pln">php</span><span class="pun">-</span><span class="pln">fpm</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">;</span><span class="pln">
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name</span><span class="pun">;</span>
    <span class="pun">}</span>
<span class="pun">}</span>

将“your_domain.com”替换为您的实际域或服务器 IP。

WordPress对永久链接使用重写规则。要启用它们,请运行:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">wordpress</span><span class="pun">.</span><span class="pln">conf</span>

在服务器块中添加以下行:

<span class="pln">location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln">
try_files $uri $uri</span><span class="pun">/</span> <span class="pun">/</span><span class="pln">index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">?</span><span class="pln">$args</span><span class="pun">;</span>
<span class="pun">}</span>

保存文件并重新加载 Nginx 以使更改生效:

<span class="pln">sudo systemctl reload nginx</span>

步骤 7.使用Let’s Encrypt保护Nginx。

建议使用 SSL/TLS 加密来保护您的网站。若要安装“让我们加密”并获取 SSL 证书,请按照下列步骤操作:

<span class="pln">sudo dnf install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">nginx
sudo certbot </span><span class="pun">--</span><span class="pln">nginx</span>

按照提示配置 SSL 证书。

第8步。网页界面安装。

现在,在 Web 浏览器中访问服务器的 IP 地址或域。您将看到WordPress安装向导。按照屏幕上的说明创建管理员帐户并配置站点。

如何在Fedora 38上安装WordPress

感謝你使用這本教鬆在Fedora 38系統上安裝WordPress。有关其他帮助或有用信息,我们建议您查看WordPress官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在Fedora 38上安装WordPress
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址