Last active
July 11, 2022 16:15
-
-
Save steinkel/70e1051e5a60eea9d2e02839d1fe4345 to your computer and use it in GitHub Desktop.
nginx configuration for the lazy CakePHP developer
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
# Use only in your development environment, behind a firewall | |
sudo apt-get install dnsmasq | |
echo 'address=/.3dev/127.0.0.1' | sudo tee -a /etc/dnsmasq.conf | |
echo 'listen-address=127.0.0.1' | sudo tee -a /etc/dnsmasq.conf | |
sudo service dnsmasq restart | |
# now imlazy.3dev will resolve to localhost | |
# install nginx + php7 | |
########################################### | |
# create this file in /etc/nginx/nginx.conf | |
########################################### | |
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 768; | |
} | |
http { | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE | |
ssl_prefer_server_ciphers on; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
gzip on; | |
gzip_disable "msie6"; | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} | |
#################################################### | |
# create this file in /etc/nginx/sites-enabled/cake3 | |
#################################################### | |
server { | |
listen 80; | |
server_name ~^(?<domain>.+)\.3dev$; | |
root /var/virtual/$domain/webroot; | |
index index.php; | |
access_log /var/log/nginx/$host-access.log; | |
error_log /var/log/nginx/$host-error.log; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
#configure with your debugmail username/password and your database root username and password | |
fastcgi_param DEBUG 1; | |
fastcgi_param EMAIL_TRANSPORT_DEFAULT_URL smtp://YOUREMAIL:[email protected]:25?tls=null&client=null&timeout=30; | |
fastcgi_param DATABASE_URL mysql://my_app:secret@localhost/$domain; | |
fastcgi_param DATABASE_TEST_URL mysql://my_app:secret@localhost/${domain}_test; | |
} | |
} | |
# Now imlazy.3dev will point to a CakePHP 3 app located in /var/virtual/imlazy and the app database will point to a MySQL db imlazy | |
# Setting up a new project would be | |
# git clone XXX /var/virtual/project | |
# composer, etc | |
# mysql -umy_app -psecret -e "create database project" | |
# and you are done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment