-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.php-apache
More file actions
115 lines (94 loc) · 3.44 KB
/
Copy pathDockerfile.php-apache
File metadata and controls
115 lines (94 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Prevent interactive prompts during package installation
# Note: Configuration files are now mounted as volumes for easy reloading
# No need to copy configuration files during build - they're mounted at runtimeND=noninteractive
# Update package lists and install essential packages
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
wget \
unzip \
git \
vim \
supervisor \
apache2 \
ca-certificates \
lsb-release \
gnupg2
# Add Ondrej's PHP repository for multiple PHP versions
RUN add-apt-repository ppa:ondrej/php -y && apt-get update
# Install PHP 7.4 and core extensions only
RUN apt-get install -y \
php7.4 \
php7.4-fpm \
php7.4-cli \
php7.4-common \
php7.4-mysql \
php7.4-zip \
php7.4-gd \
php7.4-mbstring \
php7.4-curl \
php7.4-xml \
php7.4-bcmath \
php7.4-json \
php7.4-opcache
# Install PHP 8.4 and core extensions only
RUN apt-get install -y \
php8.4 \
php8.4-fpm \
php8.4-cli \
php8.4-common \
php8.4-mysql \
php8.4-zip \
php8.4-gd \
php8.4-mbstring \
php8.4-curl \
php8.4-xml \
php8.4-bcmath \
php8.4-opcache
# Install Node.js LTS and npm
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
# Verify Node.js and npm installation
RUN node --version && npm --version
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Verify PHP installations and enable necessary extensions
RUN php7.4 -m | grep -i phar || echo "phar extension missing for PHP 7.4"
RUN php8.4 -m | grep -i phar || echo "phar extension missing for PHP 8.4"
# Create symlinks for easier access
RUN ln -sf /usr/bin/php7.4 /usr/local/bin/php74
RUN ln -sf /usr/bin/php8.4 /usr/local/bin/php84
# Enable Apache modules
RUN a2enmod rewrite proxy proxy_fcgi setenvif headers ssl
# Enable PHP-FPM configs in Apache
RUN a2enconf php7.4-fpm php8.4-fpm
# Create PHP-FPM socket directories
RUN mkdir -p /var/run/php
# Create PHP log directories
RUN mkdir -p /var/log/php/7.4 /var/log/php/8.4
RUN chown -R www-data:www-data /var/log/php
# Copy custom Apache configuration
COPY config/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache/apache2.conf /etc/apache2/apache2.conf
# Copy PHP configuration files
COPY config/php74/cli/conf.d/99-custom.ini /etc/php/7.4/cli/conf.d/99-custom.ini
COPY config/php74/fpm/conf.d/99-custom.ini /etc/php/7.4/fpm/conf.d/99-custom.ini
COPY config/php74/fpm/php-fpm.conf /etc/php/7.4/fpm/php-fpm.conf
COPY config/php74/fpm/pool.d/www.conf /etc/php/7.4/fpm/pool.d/www.conf
COPY config/php84/cli/conf.d/99-custom.ini /etc/php/8.4/cli/conf.d/99-custom.ini
COPY config/php84/fpm/conf.d/99-custom.ini /etc/php/8.4/fpm/conf.d/99-custom.ini
COPY config/php84/fpm/php-fpm.conf /etc/php/8.4/fpm/php-fpm.conf
COPY config/php84/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/www.conf
# Copy supervisor configuration
COPY config/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
# Create directories for applications
RUN mkdir -p /var/www/html/php74 /var/www/html/php84
# Set proper permissions
RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 755 /var/www/html
# Expose ports
EXPOSE 80 443
# Start supervisor (which will manage Apache and PHP-FPM)
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]