Created
June 22, 2017 04:09
-
-
Save sumpygump/8c870106a3d5a93f3325a6710e8d2a44 to your computer and use it in GitHub Desktop.
lvh.me Apache and Nginx configurations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# regex to split $uri to $fastcgi_script_name and $fastcgi_path | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# Check that the PHP script exists before passing it | |
try_files $fastcgi_script_name =404; | |
# Bypass the fact that try_files resets $fastcgi_path_info | |
# see: http://trac.nginx.org/nginx/ticket/321 | |
set $path_info $fastcgi_path_info; | |
fastcgi_param PATH_INFO $path_info; | |
fastcgi_index index.php; | |
include fastcgi.conf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerAdmin webmaster@localhost | |
ServerName localhost | |
UseCanonicalName Off | |
# <subdomain>.lvh.me setup | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^([^.]+)\.web\.lvh.me$ | |
RewriteRule ^(.*)$ /var/www/%1/web/$1 [NC,L] | |
RewriteCond %{HTTP_HOST} ^([^.]+)\.public\.lvh.me$ | |
RewriteRule ^(.*)$ /var/www/%1/public/$1 [NC,L] | |
RewriteCond %{HTTP_HOST} ^([^.]+)\.static\.lvh.me$ | |
RewriteRule ^(.*)$ /var/www/%1/static/$1 [NC,L] | |
RewriteCond %{HTTP_HOST} ^([^.]+)\.lvh.me$ | |
RewriteRule ^(.*)$ /var/www/%1/$1 [NC,L] | |
DocumentRoot /var/www | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> | |
<Directory /var/www/> | |
#Options Indexes FollowSymLinks MultiViews | |
Options Indexes FollowSymLinks | |
AllowOverride All | |
Order allow,deny | |
allow from all | |
php_value xdebug.remote_port 9009 | |
</Directory> | |
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | |
<Directory "/usr/lib/cgi-bin"> | |
AllowOverride None | |
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |
Order allow,deny | |
Allow from all | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
# Possible values include: debug, info, notice, warn, error, crit, | |
# alert, emerg. | |
LogLevel warn | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Server configuration | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# Server name | |
server_name lvh.me ~^(?<subdomain>.+).lvh.me$; | |
# Web root | |
root /var/www/$subdomain; | |
# Index | |
index index.php index.html; | |
# Try static files first and the default to index.php | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
# Pass the PHP scripts to FastCGI server | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.0-fpm.sock; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment