apache-lamp-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApache & LAMP Config
Apache & LAMP 配置
When to use this skill
何时使用本技能
- Configuring local development environments (MAMP, XAMPP, Docker + Apache).
- Managing files.
.htaccess - Troubleshooting rewrite rules.
- 配置本地开发环境(MAMP、XAMPP、Docker + Apache)。
- 管理文件。
.htaccess - 排查重写规则问题。
1. Virtual Hosts
1. 虚拟主机
- Structure: One file per site in , symlinked to
sites-available.sites-enabled - DocumentRoot: Point to the directory, not the project root (security).
public/ - Directory: Allow overrides:
apache
<Directory "/var/www/site/public"> AllowOverride All Require all granted </Directory>
- 结构:每个站点对应目录下的一个文件,并创建符号链接到
sites-available目录。sites-enabled - DocumentRoot:指向目录而非项目根目录(出于安全考虑)。
public/ - Directory:允许覆盖配置:
apache
<Directory "/var/www/site/public"> AllowOverride All Require all granted </Directory>
2. .htaccess Best Practices
2. .htaccess 最佳实践
- Rewrites: Standard pattern for front controllers (Laravel/Symfony):
apache
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] - HTTPS: Force HTTPS if not handled by a reverse proxy.
- 重写规则:适用于前端控制器(如Laravel/Symfony)的标准模式:
apache
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] - HTTPS:若未通过反向代理处理,则强制使用HTTPS。
3. PHP-FPM
3. PHP-FPM
- Timeouts: Increase and
max_execution_timeonly for specific heavy jobs, not globally.memory_limit - Opcache: Enable Opcache in production for performance.
- 超时设置:仅针对特定重负载任务增加和
max_execution_time,而非全局修改。memory_limit - Opcache:在生产环境中启用Opcache以提升性能。