You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS EC2实例中WordPress主题及登录页CSS/HTML加载失败求助

Troubleshooting CSS/HTML Loading Issues on AWS EC2 WordPress

Hey there, let's walk through targeted fixes for your WordPress CSS/HTML loading problem—since you've already checked wp-config.php and Apache MIME settings, let's focus on other common root causes:

  • Verify File Permissions
    Incorrect file permissions are a super common culprit for static resource failures. On most AWS EC2 setups (Amazon Linux/RHEL), run these commands to set proper ownership and permissions:

    # Set Apache as the owner of WordPress files
    sudo chown -R apache:apache /var/www/html
    # Set directory permissions to 755
    sudo find /var/www/html -type d -exec chmod 755 {} \;
    # Set file permissions to 644
    sudo find /var/www/html -type f -exec chmod 644 {} \;
    

    For Debian/Ubuntu systems, replace apache:apache with www-data:www-data.

  • Check mod_rewrite and .htaccess Configuration
    WordPress relies on mod_rewrite for clean URLs and proper resource routing:

    1. Enable the module (Debian/Ubuntu):
      sudo a2enmod rewrite
      sudo systemctl restart apache2
      
      For Amazon Linux/RHEL, it's usually enabled by default, but restart Apache to confirm:
      sudo systemctl restart httpd
      
    2. Ensure your Apache virtual host allows .htaccess overrides. Edit your site's config file (e.g., /etc/httpd/conf.d/your-site.conf) and add/update this directive inside the <Directory> block:
      AllowOverride All
      
    3. Replace your .htaccess file in the WordPress root with the default WordPress rules (backup the old one first):
      # BEGIN WordPress
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
      # END WordPress
      
  • Confirm Site URL Settings
    Mismatched site URLs can break resource paths. Add these lines to your wp-config.php (replace with your actual domain):

    define('WP_HOME', 'http://your-domain');
    define('WP_SITEURL', 'http://your-domain');
    

    This overrides the database settings and ensures WordPress uses the correct base URL for loading CSS/JS.

  • Inspect Browser Console Errors
    Open your browser's developer tools (F12) and check the Console tab for specific errors:

    • A 404 Not Found means the resource path is incorrect (likely URL/rewrite issue)
    • A 403 Forbidden points to permission problems
    • A 500 Internal Server Error indicates a server config or script issue
      Sharing these errors will help narrow down the problem faster.
  • Check Apache Error Logs
    Dig into Apache's error logs for server-side issues:

    • Amazon Linux/RHEL: /var/log/httpd/error_log
    • Debian/Ubuntu: /var/log/apache2/error.log
      Run this command to view recent logs:
    sudo tail -20 /var/log/httpd/error_log
    

If none of these steps resolve the issue, share the browser console errors and Apache log snippets, and we can dive deeper!

内容的提问来源于stack exchange,提问作者Alejandro Chiriboga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 16:44:06