Select Page

windows server iis 下的 wordpress web.config 設定

在 windows server 的 iis 下,預設情況下安裝 php 架構的 wordpress 總是會遇到很多的困難,像是如果遭遇到想要訪問 wordpress 目錄下的目錄資料,例如:https://rain.tips/uploads/,會跟你說找不到資料,原因是wordpress所有的入口要先透由 index.php 去做路由,解決方案則是用 web.config 去指定路由要透過 index.php 即可

請在web.config檔案中添加 rewrite rules

    <rewrite>
      <rules>
			<rule name="WordPress: https://yoururl.com" patternSyntax="Wildcard">
				<match url="*"/>
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
				<action type="Rewrite" url="index.php"/>
			</rule></rules>
    </rewrite>

最後會長成這樣子

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
			<rule name="WordPress: https://yoururl.com" patternSyntax="Wildcard">
				<match url="*"/>
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
				<action type="Rewrite" url="index.php"/>
			</rule></rules>
    </rewrite>
  </system.webServer>
</configuration>

同場加映

Windows 主機的 IIS 讓 WordPress 可以透過檔案系統新增外掛

Windows 主機的 IIS 讓 WordPress 可以透過檔案系統新增外掛

這次解決了一個比較少人碰過的問題,當有人在 Windows Server 上並且使用 IIS Server 裝載 WordPress ,但剛剛裝好的時候,關於外掛或是外觀佈景主題,沒法安裝,會跳出要求你透過FTP安裝外掛。

原因是 web.config 設定的問題,以及權限設定的問題,解決方法如下:

增加 Web.config 設定

/* 直接用檔案下載的方法更新 */
define('FS_METHOD', 'direct');

修改權限讓 PHP 可以建立目錄和檔案

去到 wordpress\wp-content\plugins 和 wordpress\wp-content\theme 把目錄的權限加入 IUSR ,並且打開修改權限,這樣就可以直接在 wordpress 後台直接用檔案更新了

如何在 Hyper-V 中的 Ubuntu 20 的螢幕解析度調整為 1920×1080

如何在 Hyper-V 中的 Ubuntu 20 的螢幕解析度調整為 1920×1080

預設中,建立好的桌面板 Ubuntu 20 的系統,會是 1024×768 的解析度,但這種解析度下很難有正常的瀏覽行為,網頁的資訊都會擠在一起,所以建好 Hyper-V VM for Ubuntu 20 的時候,通常第一件事情,就是會去改變他的解析度大小,以下說明如何修改解析度

  1. 先打開 Terminal 並且編輯 gurb 檔案
sudo nano /etc/default/grub

2.找到 GRUB_CMDLINE_LINUX_DEFAULT ,預設應該是quiet splash,我們要在後面加入指令,讓他認得hyper-V,並且調整為 Full-HD的解析度

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

3.把 GRUB_CMDLINE_LINUX_DEFAULT 的參數從 quiet splash -> quiet splash video=hyperv_fb:1920×1080

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"

修改完畢後的 grub 檔案會是下圖

4.重新開機,並且重新關閉VM的視窗後重新連線VM

sudo reboot

5.等待重新開機完畢後,下指令更新 grub

sudo update-grub

6.更新完 grub 後,並且再次重開,重連VM即可看到視窗改變

sudo reboot

文章引用

How to make Ubuntu 20.04 LTS Desktop fullscreen on Hyper-V Manager

grub 是 Linux 中的開機管理程式,詳情可以看下文章

深入指揮作業系統啟動 詳解GRUB開機管理程式 | 網管人 (netadmin.com.tw)