• WordPress 问题/Question

    Hosting Google Fonts locally on your WordPress site is an excellent way to boost your site’s performance, improve privacy compliance (like GDPR), and give you more control over your assets. Here are the most effective ways to do it, ranging from easiest to most hands-on.

    ⚡ Method 1: Use a Dedicated Plugin (Easiest & Most Common)

    This is the best method for most users, as it’s automated and requires no coding. Several excellent free plugins in the WordPress directory can scan your site, download the fonts, and rewrite the URLs for you.

    Here are a few top recommendations based on the search results:

    Plugin NameKey FeaturesBest ForHands-on Setup Required
    LocalFontsZero configuration, catches hardcoded links and @import rules, auto-downloads fonts via WP-Cron, removes connection hints to Google.Users who want a “set it and forget it” solution that works automatically after activation.No
    EasyFontsLightweight (30kb), handles Google Fonts and Bunny Fonts, supports @font-face in inline styles, compatible with page builders.Users who need a lightweight solution that also supports the privacy-friendly Bunny Fonts.Minimal (configure in settings)
    Local Google FontsSettings page to choose which fonts to load, option for automatic loading, helps with GDPR compliance.Users who want more control over which specific fonts are loaded locally.Moderate (choose fonts in settings)
    Fonts ManagerAutomatically scans pages, retrieves Google Fonts URLs, downloads and replaces links.Users who want a simple, automatic scanning and hosting process.Minimal

    General Installation Steps:

    1. In your WordPress admin panel, go to Plugins > Add New.
    2. Search for the plugin name (e.g., “LocalFonts” or “EasyFonts”).
    3. Click Install Now and then Activate.
    4. Depending on the plugin, you may need to visit its settings page (usually under Settings) to configure options or click a “Reload Fonts” button . For most, activation is all you need.

    To verify it’s working, use your browser’s developer tools (F12), go to the Network tab, filter by “Fonts”, and reload your page. You should no longer see requests to fonts.googleapis.com or fonts.gstatic.com .

    🚀 Method 2: Use a Performance Plugin (Best if You Already Use One)

    If you already use a comprehensive caching and performance plugin, it likely has this feature built-in, saving you from installing an extra plugin.

    • WP Rocket: This premium plugin has a “Self-host Google Fonts locally” option. You can find it by going to Settings > WP Rocket > Media tab and checking the box . The plugin will then detect, download, and rewrite the font URLs for you. It also provides filters to exclude specific fonts if needed .
    • Autoptimize & Perfmatters: These popular optimization plugins also offer options to disable or remove Google Fonts, which forces your site to use system fonts . While this doesn’t “host” the Google Fonts locally, it’s a valid alternative if you want to eliminate external requests for privacy or performance reasons.

    🛠️ Method 3: Do It Manually (For Full Control)

    For developers or those who prefer a code-based approach, manual self-hosting is a viable option. It’s more work but gives you complete control over the files .

    The Process:

    1. Download Fonts: Go to Google Fonts, select the fonts you need, and click “Download all” to get the .ttf (TrueType) files.
    2. Convert Formats: Web fonts should be in .woff2 format for best performance and browser support. Use a free online converter (like CloudConvert) to convert the .ttf files to .woff2.
    3. Upload to Server: Using an FTP client (like FileZilla) or your hosting control panel’s file manager, upload the .woff2 files to a new folder inside your (child) theme’s directory, for example, /wp-content/themes/your-child-theme/fonts/.
    4. Declare with @font-face: Add the CSS code to declare your new font family. This should be added to your child theme’s style.css file or via the WordPress Customizer’s “Additional CSS” section.
      css @font-face { font-family: 'My Local Font'; src: url('/wp-content/themes/your-child-theme/fonts/my-font.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
    5. Apply the Font: Use the font-family rule to apply your locally hosted font to specific elements like headings or body text.
      css body { font-family: 'My Local Font', Arial, sans-serif; }

    🤔 Which Method is Right for You?

    • For most users: Method 1 (Dedicated Plugin) is the best choice. It’s simple, automated, and highly effective. LocalFonts is a great starting point due to its zero-configuration approach .
    • For performance enthusiasts: If you already own WP Rocket, use its built-in feature to keep your toolkit lean .
    • For developers: Method 3 (Manual) provides the most control and eliminates the need for any additional plugins, but it requires more technical effort.

    Hope this helps you get your fonts hosted locally. What WordPress theme or page builder are you currently using? Knowing that might help narrow down the plugin choice, as some work better with specific builders like Divi or Elementor .


    日期:April 24, 2026

    Setting up a WordPress website on Oracle Cloud’s free tier is a great way to build a site with no upfront costs. The process involves setting up your cloud environment, creating a virtual machine, and then installing the web server, database, and WordPress itself.

    Here is a step-by-step guide to walk you through the entire process using an Ubuntu Linux instance.

    Prerequisites

    Before you begin, ensure you have:

    • An Oracle Cloud Infrastructure Free Tier account. If you don’t have one, you can sign up on their website.
    • A computer (MacOS, Linux, or Windows) with an SSH client (like Terminal on Mac/Linux or PowerShell on Windows) to connect to your cloud server .

    Step 1: Set Up a Compartment (Optional but Recommended)

    A compartment is a logical container for your cloud resources, helping you organize and manage them.

    1. Sign in to the Oracle Cloud Infrastructure Console.
    2. Open the navigation menu and go to Identity & Security -> Identity -> Compartments.
    3. Click Create Compartment.
    4. Enter a name (e.g., “WordPress-Compartment”) and a description, then click Create Compartment .

    Step 2: Create Your Free Virtual Machine (VM) Instance

    This is where your WordPress site will live.

    1. From the main console landing page, scroll down to “Launch Resources” and select the Create a VM instance workflow .
    2. Name your instance: Give it a descriptive name, like “WordPress-Server”.
    3. Choose your compartment: Select the compartment you created in Step 1 .
    4. Edit the Image: Click the Edit button next to “Image and shape”.
      • Click Change image.
      • Select the Ubuntu image. Choose a version like Canonical Ubuntu 24.04 or 22.04 (this guide is compatible with both).
    5. Confirm the Shape: Ensure the shape selected is the Always Free-eligible one, such as VM.Standard.E2.1.Micro (AMD) or an Arm-based one. This confirms you won’t be charged .
    6. Configure Networking: In the “Networking” section, ensure Assign a public IPv4 address is selected. Let the system create a new Virtual Cloud Network (VCN) for you .
    7. Add SSH Keys: This is crucial for secure access.
      • Select Generate a key pair for me.
      • Immediately click Save Private Key and Save Public Key to download both files to a safe folder on your computer. You will not be able to retrieve them later .
    8. Click Create. It will take a few minutes for your instance to provision.

    Step 3: Configure Firewall to Allow Web Traffic

    To make your website accessible from the internet, you need to open port 80 (for HTTP) and optionally port 443 (for HTTPS) in both the cloud firewall and the instance’s internal firewall.

    Part A: Configure the Cloud Firewall (Ingress Rules)

    1. Go to the navigation menu and select Networking -> Virtual Cloud Networks.
    2. Click on the VCN that was created with your instance (it will have a similar name).
    3. Click on the public subnet link.
    4. Under “Resources”, click on the Default Security List.
    5. Click Add Ingress Rules and add the following rule :
      • Source Type: CIDR
      • Source CIDR: 0.0.0.0/0 (This allows traffic from anywhere on the internet)
      • IP Protocol: TCP
      • Destination Port Range: 80,443 (This opens both HTTP and HTTPS ports)
      • Description: “Allow web traffic”
      • Click Add Ingress Rules.

    Step 4: Connect to Your Instance via SSH

    Now, you’ll connect to your virtual server from your local computer.

    1. On the OCI console, go to Compute -> Instances and click on your instance. Copy its Public IP address.
    2. Open your terminal (or PowerShell) and navigate to the directory where you saved your private SSH key.
    3. Run the following command to connect. Remember to replace <private-key-file> with your key’s filename and <public-ip> with the IP address you copied.
      bash ssh -i <private-key-file> ubuntu@<public-ip>
      Since you’re connecting for the first time, you might be asked to confirm the connection. Type yes and press Enter .

    Step 5: Install the LAMP Stack (Linux, Apache, MySQL, PHP)

    Once connected to your server via SSH, you’ll install all the necessary software.

    1. Update your system’s package list: sudo apt update
    2. Install Apache, MySQL, and PHP:
      This command installs the web server (Apache), the database (MySQL), the core programming language (PHP), and all the extra PHP modules WordPress needs to run. sudo apt install -y apache2 mysql-server php libapache2-mod-php php-mysql php-curl php-gd php-xml php-mbstring php-zip php-json
    3. Open the instance’s internal firewall for web traffic:
      Even though you opened the cloud firewall, Ubuntu also has its own internal firewall (iptables). These commands make the rules persistent after a reboot .
      bash sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 443 -j ACCEPT sudo netfilter-persistent save

    Step 6: Secure Your MySQL Database

    It’s essential to set a password and remove insecure defaults from your new database installation.

    1. Run the MySQL secure installation script: sudo mysql_secure_installation You will be guided through a series of prompts:
      • Set up the VALIDATE PASSWORD COMPONENT? (Optional, but recommended for security).
      • Enter a new strong password for the MySQL root user.
      • Type Y to remove anonymous users.
      • Type Y to disallow root login remotely.
      • Type Y to remove the test database.
      • Type Y to reload privileges tables.
    2. Create a database and user for WordPress:
      Log in to the MySQL console with your new root password.
      bash sudo mysql -u root -p
      Once logged in, run the following SQL commands (replace 'your-database-password' with a strong, unique password) :
      sql CREATE DATABASE wordpress; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your-database-password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; EXIT;

    Step 7: Download and Configure WordPress

    Now, you’ll download WordPress and set the correct file permissions.

    1. Download the latest WordPress package: cd /tmp curl -O https://wordpress.org/latest.tar.gz
    2. Extract the files to your web server’s root directory: sudo tar zxf latest.tar.gz -C /var/www/html/ --strip 1
    3. Set correct file ownership and permissions:
      The web server (Apache) needs to own the files to be able to read and write them.
      bash sudo chown -R www-data:www-data /var/www/html/ sudo chmod -R 755 /var/www/html/
      Create an uploads directory and set its ownership as well .
      bash sudo mkdir -p /var/www/html/wp-content/uploads sudo chown -R www-data:www-data /var/www/html/wp-content/uploads

    Step 8: Complete the Installation Through Your Web Browser

    The final steps are done through a simple web-based wizard.

    1. Open a web browser and go to your instance’s public IP address: http://<your-public-ip-address>
    2. You will see the WordPress setup welcome page. Select your language and click Continue.
    3. WordPress will notify you that it needs your database details. Click Let’s go! .
    4. Enter the database information you created in Step 6 :
      • Database Name: wordpress
      • Username: wpuser
      • Password: <your-database-password>
      • Database Host: localhost (since the database is on the same server)
      • Table Prefix: Leave as wp_ (or change if you wish).
      • Click Submit.
    5. If the connection is successful, click Run the installation.
    6. Fill in the information for your new site:
      • Site Title: The name of your website.
      • Username: The admin username for your WordPress site (choose something secure, not “admin”).
      • Password: A strong password for your admin account.
      • Your Email: Your email address.
      • Search Engine Visibility: Choose if you want search engines to index your site.
    7. Click Install WordPress.
    8. After a successful installation, click Log In and use the admin username and password you just created.

    Congratulations! You now have a fully functional WordPress website running on Oracle Cloud’s free tier.

    Next Steps & Considerations

    • Register a Domain Name: Instead of using the IP address, you can buy a domain name (like yourwebsite.com) and point it to your server’s IP.
    • Enable HTTPS: It’s highly recommended to secure your site with an SSL certificate. You can use Let’s Encrypt, which is a free, automated service for this purpose .
    • Keep Your Site Updated: Regularly run sudo apt update && sudo apt upgrade on your server and keep your WordPress themes and plugins updated to ensure security.
    • Account Idle Policy: Be aware that Oracle may reclaim idle Always Free compute instances. To avoid this, ensure your instance is not idle by having a reasonable amount of CPU and network activity .

    日期:April 22, 2026

    Of course! Setting up a WordPress website on your local computer is an excellent way to learn, test themes/plugins, or build a site before it goes live. This local environment is often called a “local server” or “development environment.”

    Here’s a comprehensive guide on how to do it.


    Overview: The Two Main Methods

    There are two primary ways to set up WordPress locally. I highly recommend Method 1 for beginners.

    1. Using a Local Server Tool (Easiest & Recommended): Software like Local, XAMPP, or MAMP automates the entire process. They create a mini-server environment on your PC with all the necessary components (Apache, PHP, MySQL).
    2. Manual Installation (Advanced): Installing and configuring the web server (like Apache), PHP, and database (like MySQL) individually. This offers more control but is complex.

    Method 1: Using Local by Flywheel (The Easiest Way)

    Local is a free, modern, and very user-friendly tool designed specifically for WordPress. It works on Windows, Mac, and Linux.

    Step-by-Step Guide with Local

    Step 1: Download and Install Local

    • Go to the Local website.
    • Download the free version for your operating system.
    • Run the installer and follow the simple on-screen instructions.

    Step 2: Create a New Site

    • Open Local and click “Create a new site.”
    • You’ll be guided through a simple setup wizard:
      • Site Name: Enter a name for your development site (e.g., my-test-site). This will also be your local domain (e.g., my-test-site.local).
      • Environment: Choose “Preferred” for the best balance of performance and ease of use.
      • Setup: For your first site, choose “Create a new WordPress site.”
      • WordPress Username/Password: Set your admin username and password. Write these down! You’ll need them to log into your WordPress dashboard.

    Step 3: Start Your Site

    • After you click “Add Site,” Local will automatically download the necessary files, set up the database, and configure everything.
    • Once the process is complete, your site will appear in the Local dashboard. Click “Start Site” to run your local server.

    Step 4: Access Your Site and Dashboard

    • Your local WordPress site will now be running. You can access it in two ways:
      • The Front End (Your Website): Click the “Open Site” button in Local. It will open in your browser (e.g., http://my-test-site.local).
      • The Back End (WP Admin): Click the “Admin” button in Local. It will take you directly to your WordPress login page (http://my-test-site.local/wp-admin). Log in with the username and password you created in Step 2.

    Congratulations! You now have a fully functional WordPress website running on your computer.


    Method 2: Using XAMPP (A Traditional Alternative)

    XAMPP is a free, all-in-one package containing Apache (web server), MySQL (database), and PHP. It’s very powerful but requires a few more manual steps.

    Step-by-Step Guide with XAMPP

    Step 1: Download and Install XAMPP

    • Go to the Apache Friends XAMPP page.
    • Download the version for your operating system.
    • Run the installer. It’s best to install it to a simple folder like C:\xampp (Windows) or Applications/XAMPP (Mac).

    Step 2: Start the Servers

    • Open the XAMPP Control Panel.
    • Start the Apache and MySQL modules by clicking the “Start” button next to them. A green indicator will show they are running.

    Step 3: Download WordPress

    • Go to wordpress.org/download and download the latest version of WordPress.
    • Unzip the downloaded file. You will get a folder named wordpress.
    • Move this wordpress folder into your XAMPP’s htdocs directory (e.g., C:\xampp\htdocs\).
    • You can rename the wordpress folder to whatever you want your site’s folder to be called (e.g., mysite).

    Step 4: Create a Database

    • In your web browser, go to http://localhost/phpmyadmin.
    • Click on the “Databases” tab.
    • Enter a name for your new database (e.g., mysite_db) and click “Create.” Remember this name.

    Step 5: Run the WordPress Installation

    • In your browser, go to http://localhost/mysite (replace mysite with the name of the folder you created in Step 3).
    • You will see the famous WordPress installation screen.
    • Select your language and click “Continue.”
    • WordPress will now show you the information it needs. Click “Let’s go!”
    • Fill in the database details:
      • Database Name: The name you created (e.g., mysite_db).
      • Username: root
      • Password: (Leave this field blank)
      • Database Host: localhost
      • Table Prefix: wp_ (you can leave this as default).
    • Click “Submit.” If the connection is successful, click “Run the installation.”
    • Finally, enter your Site Title, Username, Password, and Email for the WordPress admin account. Click “Install WordPress.”

    Step 6: Log In

    • After installation, you can log in at http://localhost/mysite/wp-admin with the username and password you just created.

    Why Set Up a Local WordPress Site?

    • Safe Testing: Test new themes, plugins, and WordPress updates without breaking your live website.
    • Development: Build websites for clients offline.
    • Learning: Experiment with code (HTML, CSS, PHP) without any risk.
    • Speed: Everything runs on your machine, so it’s incredibly fast.

    What To Do When You’re Ready to Go Live?

    When your local site is ready for the world, you will need to “migrate” it to a live web hosting server. This process involves:

    1. Buying web hosting and a domain name.
    2. Exporting your local database.
    3. Uploading your WordPress files to the host.
    4. Importing the database on the host.
    5. Updating configuration files.

    Many plugins (like Duplicator or All-in-One WP Migration) and the Local software itself have tools to make this migration process much easier.

    For almost all users, starting with “Local by Flywheel” is the fastest, simplest, and most reliable method.


    日期:April 22, 2026

    Making your locally-built WordPress site accessible to the public is a common next step for sharing your work or getting client feedback. There are two main paths you can take: a temporary solution using a tunnel for quick previews, or a permanent solution by migrating to a live hosting provider.

    Here is a comparison of both methods to help you decide.

    Aspect🚀 Method 1: Temporary Access (via “Tunneling”)🌐 Method 2: Permanent Access (via Migration)
    What It IsExposing your local computer to the internet using a tool (e.g., ngrok) to get a temporary public URL .Moving your site’s files and database to a paid hosting provider (e.g., Bluehost, Kinsta) to go live permanently .
    Best ForQuick client previews, testing plugins that need a public URL (like Jetpack), or gathering feedback on a work-in-progress .Launching the final website, making it available 24/7 to the public, and getting your own domain name (e.g., www.yoursite.com) .
    ProsFree/Low Cost: Many tools offer a free tier .
    Immediate: No need to buy hosting or a domain upfront.
    Convenient: You continue working in your familiar local environment.
    Professional: Provides a custom domain, better speed, and uptime .
    Always Online: Your computer doesn’t need to stay on .
    Secure: Hosting providers offer robust security and backups.
    ConsComputer Must Be On: Your PC must be running and awake for anyone to access the site .
    Temporary & Slow: The URL is often a random string of letters and can be slow .
    Security Risk: You are opening your local computer to the internet.
    Costs Money: You’ll need to pay for a hosting plan and a domain name .
    More Complex: Requires a few technical steps to migrate the site, though many hosts offer one-click migrations .

    🛠️ Option 1: The Temporary Tunnel (For Previewing)

    This is the best way to show a work-in-progress without buying anything. Tools like ngrok or Localtunnel create a secure tunnel to your computer .

    How to do it (using ngrok as an example):

    1. Start your local WordPress site (ensure XAMPP/MAMP/Local is running).
    2. Download and run ngrok from their website.
    3. Run the command in your terminal: ngrok http 80 (use port 8080 if that’s what your local site uses) .
    4. Share the URL ngrok gives you (e.g., https://abc123.ngrok.io). Anyone with this link can see your site.

    ⚠️ A Critical Step for WordPress: Because your site’s internal links and images are hardcoded to http://localhost, clicking on them will break for remote users . To fix this, you must update your site’s URL. Add these two lines to your wp-config.php file (replace the URL with the one from ngrok):

    define( 'WP_HOME', 'https://your-ngrok-url.ngrok.io' );
    define( 'WP_SITEURL', 'https://your-ngrok-url.ngrok.io' );

    After you are done previewing, remember to remove these lines to work locally again .

    📦 Option 2: The Permanent Migration (For Going Live)

    When you are ready to launch the final site, you should move it to a live server. This is the standard professional process.

    How to do it (The 30,000-foot view):

    1. Buy a domain and hosting (e.g., from a provider like DreamHost, Kinsta, or any popular WordPress host) .
    2. Export your local database using phpMyAdmin (this creates a .sql file) .
    3. Upload your WordPress files to the live server using an FTP client like FileZilla .
    4. Create a new database on your live server (via your hosting control panel) and import your .sql file into it .
    5. Update your wp-config.php file with the live server’s database name, username, and password .
    6. Update your site’s URLs from http://localhost to http://yourdomain.com. You can do this in phpMyAdmin by changing the siteurl and home fields in the wp_options table .

    Pro Tip: For a simpler migration, look for a host that offers a free migration plugin (like Jetpack’s migration tool or a host-specific plugin) to handle the heavy lifting for you .

    💡 Final Verdict

    • For a quick, free preview that your client can look at for a day or two? Use ngrok (Option 1). It’s fast and easy.
    • To launch a real website that people can visit anytime? Migrate to a host (Option 2). It’s the only professional way to do it .

    If you decide to go with the permanent migration and need help picking a hosting provider or a plugin to simplify the process, feel free to ask


    日期:April 21, 2026

    This is the end of content for WordPress question.

    No more pages for WordPress question.