Skip to content

Commit d904746

Browse files
authored
php7.4 nginx dockerfile (#1347)
1 parent ac40615 commit d904746

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:20.04
2+
3+
RUN apt-get update
4+
RUN apt-get -y upgrade
5+
6+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing php7.4 \
7+
php7.4-cli \
8+
php-fpm \
9+
php7.4-mysql \
10+
php7.4-curl \
11+
net-tools
12+
13+
RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y nginx-full
14+
ADD nginx-site.conf /etc/nginx/sites-available/default
15+
16+
WORKDIR /var/www/html/
17+
18+
RUN mkdir -p /run/php
19+
20+
COPY . /var/www/html
21+
22+
EXPOSE 80
23+
24+
CMD ["/bin/bash", "-c", "service php7.4-fpm start && nginx -g \"daemon off;\""]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
server {
2+
listen 80; ## listen for ipv4; this line is default and implied
3+
listen [::]:80 default ipv6only=on; ## listen for ipv6
4+
5+
root /var/www/html;
6+
index index.php index.html index.htm;
7+
8+
# Make site accessible from http://localhost/
9+
server_name _;
10+
11+
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
12+
sendfile off;
13+
14+
# Add stdout logging
15+
16+
error_log /dev/stdout info;
17+
access_log /dev/stdout;
18+
19+
location / {
20+
try_files $uri $uri/ =404;
21+
}
22+
23+
error_page 404 /404.html;
24+
location = /404.html {
25+
root /var/www/errors;
26+
internal;
27+
}
28+
29+
location ^~ /ngd-style.css {
30+
alias /var/www/errors/style.css;
31+
access_log off;
32+
}
33+
34+
location ^~ /ngd-sad.svg {
35+
alias /var/www/errors/sad.svg;
36+
access_log off;
37+
}
38+
39+
# Pass the PHP scripts to FastCGI server listening on socket
40+
location ~ \.php$ {
41+
try_files $uri =404;
42+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
43+
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
44+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
45+
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
46+
fastcgi_index index.php;
47+
include fastcgi_params;
48+
}
49+
50+
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
51+
expires 5d;
52+
}
53+
54+
# deny access to . files, for security
55+
#
56+
location ~ /\. {
57+
log_not_found off;
58+
deny all;
59+
}
60+
61+
location ^~ /.well-known {
62+
allow all;
63+
auth_basic off;
64+
}
65+
66+
}

0 commit comments

Comments
 (0)