Docker Apache/PHP Localhost不断返回子目录的错误404
我想用docker代替xampp。我的所有项目都有一个目录结构,如下所示:Docker Apache/PHP Localhost不断返回子目录的错误404,php,apache,docker,docker-compose,dockerfile,Php,Apache,Docker,Docker Compose,Dockerfile,我想用docker代替xampp。我的所有项目都有一个目录结构,如下所示: Work |- project_1 |- public_html |- project_2 |- public_html |- etc. |- httpd # this is where config files lie 我希望能够通过docker部署apache/php,并将主“Work”文件夹用作“htdocs”。当我通过localhost(例如)访问一个项目时,它不起作
Work
|- project_1
|- public_html
|- project_2
|- public_html
|- etc.
|- httpd # this is where config files lie
我希望能够通过docker部署apache/php,并将主“Work”文件夹用作“htdocs”。当我通过localhost(例如)访问一个项目时,它不起作用(给我一个404错误),而同样的东西在xampp和mamp上工作得非常好。当我访问时,目录索引也显示良好;我花了4天的时间试图找出我做错了什么,但一直没能弄清楚。apache配置似乎有问题,可能是因为相同的项目使用xampp和mamp
httpd文件夹具有以下docker配置文件:
docker compose.yml:
version: '3'
services:
php:
build: .
image: php:7.2-apache
environment:
ALLOW_OVERRIDE: 'true'
DEBUG: 'true'
ports:
- "80:80"
- "443:443"
volumes:
- ../:/var/www/html/
- ./apache.conf:/etc/apache2/sites-available/000-default.conf
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerAlias localhost
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
FROM php:7.2-apache
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
RUN apt-get update && apt-get install -y --fix-missing \
xz-utils \
build-essential \
pkg-config \
git-core \
autoconf \
libjpeg62-turbo-dev \
libsodium-dev \
libpng-dev \
libcurl4-openssl-dev \
libpq-dev \
libpspell-dev \
libsqlite3-dev \
libmagickwand-dev \
libzip-dev \
imagemagick \
subversion \
python \
g++ \
curl \
vim \
wget \
netcat \
chrpath
RUN docker-php-ext-install \
iconv \
-j$(nproc) sodium \
opcache \
curl \
gd \
mysqli \
pdo \
pdo_pgsql \
pdo_mysql \
pdo_sqlite \
pspell \
pgsql \
soap \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
RUN pecl install imagick && docker-php-ext-enable imagick
WORKDIR /tmp
RUN wget https://getcomposer.org/composer.phar
RUN mv composer.phar /bin/composer
RUN chmod 700 /bin/composer
RUN apt-get clean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/src/*
RUN a2enmod rewrite headers cache cache_disk expires vhost_alias userdir
RUN service apache2 restart
RUN service apache-htcacheclean start
RUN usermod -u 1000 www-data
RUN usermod -G staff www-data
WORKDIR /var/www/html
CMD ["apache2-foreground"]
EXPOSE 80
ServerRoot "/etc/apache2"
ServerAdmin postmaster@localhost
ServerName localhost:80
Listen *:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule version_module modules/mod_version.so
LoadModule userdir_module modules/mod_userdir.so
<IfModule unixd_module>
User www-data
Group www-data
</IfModule>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /var/log/apache2/error.log
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog /var/log/apache2/access.log combined
</IfModule>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi .pl .asp
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile "conf/magic"
</IfModule>
Include conf/etc/httpd-mpm.conf
Include conf/etc/httpd-multilang-errordoc.conf
Include conf/etc/httpd-autoindex.conf
Include conf/etc/httpd-languages.conf
Include conf/etc/httpd-userdir.conf
Include conf/etc/httpd-info.conf
Include conf/etc/httpd-vhosts.conf
Include "conf/etc/httpd-proxy.conf"
Include "conf/etc/httpd-default.conf"
<IfModule proxy_html_module>
Include conf/etc/proxy-html.conf
</IfModule>
Include conf/etc/httpd-ssl.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AcceptFilter http none
AcceptFilter https none
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
Include "conf/etc/httpd-ajp.conf"
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_1/public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*\.(css|jpe?g|gif|png|js|ico|ttf|woff|woff2)$ [NC]
RewriteRule ^ index.php [QSA,L]
</IfModule>
apache.conf:
version: '3'
services:
php:
build: .
image: php:7.2-apache
environment:
ALLOW_OVERRIDE: 'true'
DEBUG: 'true'
ports:
- "80:80"
- "443:443"
volumes:
- ../:/var/www/html/
- ./apache.conf:/etc/apache2/sites-available/000-default.conf
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerAlias localhost
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
FROM php:7.2-apache
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
RUN apt-get update && apt-get install -y --fix-missing \
xz-utils \
build-essential \
pkg-config \
git-core \
autoconf \
libjpeg62-turbo-dev \
libsodium-dev \
libpng-dev \
libcurl4-openssl-dev \
libpq-dev \
libpspell-dev \
libsqlite3-dev \
libmagickwand-dev \
libzip-dev \
imagemagick \
subversion \
python \
g++ \
curl \
vim \
wget \
netcat \
chrpath
RUN docker-php-ext-install \
iconv \
-j$(nproc) sodium \
opcache \
curl \
gd \
mysqli \
pdo \
pdo_pgsql \
pdo_mysql \
pdo_sqlite \
pspell \
pgsql \
soap \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
RUN pecl install imagick && docker-php-ext-enable imagick
WORKDIR /tmp
RUN wget https://getcomposer.org/composer.phar
RUN mv composer.phar /bin/composer
RUN chmod 700 /bin/composer
RUN apt-get clean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/src/*
RUN a2enmod rewrite headers cache cache_disk expires vhost_alias userdir
RUN service apache2 restart
RUN service apache-htcacheclean start
RUN usermod -u 1000 www-data
RUN usermod -G staff www-data
WORKDIR /var/www/html
CMD ["apache2-foreground"]
EXPOSE 80
ServerRoot "/etc/apache2"
ServerAdmin postmaster@localhost
ServerName localhost:80
Listen *:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule version_module modules/mod_version.so
LoadModule userdir_module modules/mod_userdir.so
<IfModule unixd_module>
User www-data
Group www-data
</IfModule>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /var/log/apache2/error.log
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog /var/log/apache2/access.log combined
</IfModule>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi .pl .asp
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile "conf/magic"
</IfModule>
Include conf/etc/httpd-mpm.conf
Include conf/etc/httpd-multilang-errordoc.conf
Include conf/etc/httpd-autoindex.conf
Include conf/etc/httpd-languages.conf
Include conf/etc/httpd-userdir.conf
Include conf/etc/httpd-info.conf
Include conf/etc/httpd-vhosts.conf
Include "conf/etc/httpd-proxy.conf"
Include "conf/etc/httpd-default.conf"
<IfModule proxy_html_module>
Include conf/etc/proxy-html.conf
</IfModule>
Include conf/etc/httpd-ssl.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AcceptFilter http none
AcceptFilter https none
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
Include "conf/etc/httpd-ajp.conf"
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_1/public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*\.(css|jpe?g|gif|png|js|ico|ttf|woff|woff2)$ [NC]
RewriteRule ^ index.php [QSA,L]
</IfModule>
httpd.conf:
version: '3'
services:
php:
build: .
image: php:7.2-apache
environment:
ALLOW_OVERRIDE: 'true'
DEBUG: 'true'
ports:
- "80:80"
- "443:443"
volumes:
- ../:/var/www/html/
- ./apache.conf:/etc/apache2/sites-available/000-default.conf
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerAlias localhost
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
FROM php:7.2-apache
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
RUN apt-get update && apt-get install -y --fix-missing \
xz-utils \
build-essential \
pkg-config \
git-core \
autoconf \
libjpeg62-turbo-dev \
libsodium-dev \
libpng-dev \
libcurl4-openssl-dev \
libpq-dev \
libpspell-dev \
libsqlite3-dev \
libmagickwand-dev \
libzip-dev \
imagemagick \
subversion \
python \
g++ \
curl \
vim \
wget \
netcat \
chrpath
RUN docker-php-ext-install \
iconv \
-j$(nproc) sodium \
opcache \
curl \
gd \
mysqli \
pdo \
pdo_pgsql \
pdo_mysql \
pdo_sqlite \
pspell \
pgsql \
soap \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
RUN pecl install imagick && docker-php-ext-enable imagick
WORKDIR /tmp
RUN wget https://getcomposer.org/composer.phar
RUN mv composer.phar /bin/composer
RUN chmod 700 /bin/composer
RUN apt-get clean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/src/*
RUN a2enmod rewrite headers cache cache_disk expires vhost_alias userdir
RUN service apache2 restart
RUN service apache-htcacheclean start
RUN usermod -u 1000 www-data
RUN usermod -G staff www-data
WORKDIR /var/www/html
CMD ["apache2-foreground"]
EXPOSE 80
ServerRoot "/etc/apache2"
ServerAdmin postmaster@localhost
ServerName localhost:80
Listen *:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule version_module modules/mod_version.so
LoadModule userdir_module modules/mod_userdir.so
<IfModule unixd_module>
User www-data
Group www-data
</IfModule>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /var/log/apache2/error.log
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog /var/log/apache2/access.log combined
</IfModule>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi .pl .asp
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile "conf/magic"
</IfModule>
Include conf/etc/httpd-mpm.conf
Include conf/etc/httpd-multilang-errordoc.conf
Include conf/etc/httpd-autoindex.conf
Include conf/etc/httpd-languages.conf
Include conf/etc/httpd-userdir.conf
Include conf/etc/httpd-info.conf
Include conf/etc/httpd-vhosts.conf
Include "conf/etc/httpd-proxy.conf"
Include "conf/etc/httpd-default.conf"
<IfModule proxy_html_module>
Include conf/etc/proxy-html.conf
</IfModule>
Include conf/etc/httpd-ssl.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AcceptFilter http none
AcceptFilter https none
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
Include "conf/etc/httpd-ajp.conf"
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_1/public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*\.(css|jpe?g|gif|png|js|ico|ttf|woff|woff2)$ [NC]
RewriteRule ^ index.php [QSA,L]
</IfModule>
ServerRoot”/etc/apache2“
服务器管理员postmaster@localhost
ServerName本地主机:80
听*:80
LoadModule access\u compat\u module modules/mod\u access\u compat.so
LoadModule actions\u module modules/mod\u actions.so
LoadModule alias\u modules/mod\u alias.so
LoadModule allowmethods\u module modules/mod\u allowmethods.so
加载模块asis\u模块模块/mod\u asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn\u file\u module modules/mod\u authn\u file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_modules/mod_autoindex.so
LoadModule cgi_modules/mod_cgi.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir\u modules/mod\u dir.so
LoadModule env_modules/mod_env.so
LoadModule headers\u modules/mod\u headers.so
LoadModule include\u modules/mod\u include.so
LoadModule info\u modules/mod\u info.so
LoadModule isapi_modules/mod_isapi.so
LoadModule log\u config\u module modules/mod\u log\u config.so
LoadModule cache\u disk\u module modules/mod\u cache\u disk.so
LoadModule mime_modules/mod_mime.so
LoadModule negotiation\u modules/mod\u negotiation.so
LoadModule proxy\u modules/mod\u proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
加载模块socache\u shmcb\u模块/mod\u socache\u shmcb.so
加载模块speling\u模块/mod\u speling.so
LoadModule ssl\u module modules/mod\u ssl.so
LoadModule status\u modules/mod\u status.so
LoadModule version\u modules/mod\u version.so
LoadModule userdir\u module modules/mod\u userdir.so
用户www数据
组www数据
DocumentRoot“/var/www/html”
DirectoryIndex.php
选项索引如下SYMLINKS包括ExecCGI
允许超越所有
命令允许,拒绝
通融
要求所有授权
要求全部拒绝
ErrorLog/var/log/apache2/error.log
日志级别警告
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\”%>s%b”通用
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\“%%{User Agent}i\%i%O”组合IO
CustomLog/var/log/apache2/access.log组合
RequestHeader提前取消代理设置
TypesConfig conf/mime.types
AddType应用程序/x-compress.Z
AddType应用程序/x-gzip.gz.tgz
AddHandler cgi script.cgi.pl.asp
AddType text/html.shtml
AddOutputFilter包括.shtml
MIMEMagicFile“conf/magic”
包括conf/etc/httpd-mpm.conf
包括conf/etc/httpd-multilang-errordoc.conf
包括conf/etc/httpd-autoindex.conf
包括conf/etc/httpd-languages.conf
包括conf/etc/httpd-userdir.conf
包括conf/etc/httpd-info.conf
包括conf/etc/httpd-vhosts.conf
包括“conf/etc/httpd proxy.conf”
包括“conf/etc/httpd default.conf”
包括conf/etc/proxy-html.conf
包括conf/etc/httpd-ssl.conf
SSLR和OMSEED启动内置
SSLR和OMSEED连接内置
AcceptFilter http无
AcceptFilter https无
包括“conf/etc/httpd ajp.conf”
.htaccess(例如在/project\u 1/public\u html目录中):
version: '3'
services:
php:
build: .
image: php:7.2-apache
environment:
ALLOW_OVERRIDE: 'true'
DEBUG: 'true'
ports:
- "80:80"
- "443:443"
volumes:
- ../:/var/www/html/
- ./apache.conf:/etc/apache2/sites-available/000-default.conf
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerAlias localhost
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
FROM php:7.2-apache
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
RUN apt-get update && apt-get install -y --fix-missing \
xz-utils \
build-essential \
pkg-config \
git-core \
autoconf \
libjpeg62-turbo-dev \
libsodium-dev \
libpng-dev \
libcurl4-openssl-dev \
libpq-dev \
libpspell-dev \
libsqlite3-dev \
libmagickwand-dev \
libzip-dev \
imagemagick \
subversion \
python \
g++ \
curl \
vim \
wget \
netcat \
chrpath
RUN docker-php-ext-install \
iconv \
-j$(nproc) sodium \
opcache \
curl \
gd \
mysqli \
pdo \
pdo_pgsql \
pdo_mysql \
pdo_sqlite \
pspell \
pgsql \
soap \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
RUN pecl install imagick && docker-php-ext-enable imagick
WORKDIR /tmp
RUN wget https://getcomposer.org/composer.phar
RUN mv composer.phar /bin/composer
RUN chmod 700 /bin/composer
RUN apt-get clean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/src/*
RUN a2enmod rewrite headers cache cache_disk expires vhost_alias userdir
RUN service apache2 restart
RUN service apache-htcacheclean start
RUN usermod -u 1000 www-data
RUN usermod -G staff www-data
WORKDIR /var/www/html
CMD ["apache2-foreground"]
EXPOSE 80
ServerRoot "/etc/apache2"
ServerAdmin postmaster@localhost
ServerName localhost:80
Listen *:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule version_module modules/mod_version.so
LoadModule userdir_module modules/mod_userdir.so
<IfModule unixd_module>
User www-data
Group www-data
</IfModule>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /var/log/apache2/error.log
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog /var/log/apache2/access.log combined
</IfModule>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi .pl .asp
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile "conf/magic"
</IfModule>
Include conf/etc/httpd-mpm.conf
Include conf/etc/httpd-multilang-errordoc.conf
Include conf/etc/httpd-autoindex.conf
Include conf/etc/httpd-languages.conf
Include conf/etc/httpd-userdir.conf
Include conf/etc/httpd-info.conf
Include conf/etc/httpd-vhosts.conf
Include "conf/etc/httpd-proxy.conf"
Include "conf/etc/httpd-default.conf"
<IfModule proxy_html_module>
Include conf/etc/proxy-html.conf
</IfModule>
Include conf/etc/httpd-ssl.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AcceptFilter http none
AcceptFilter https none
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
Include "conf/etc/httpd-ajp.conf"
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_1/public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*\.(css|jpe?g|gif|png|js|ico|ttf|woff|woff2)$ [NC]
RewriteRule ^ index.php [QSA,L]
</IfModule>
重新启动发动机
重写基础/项目\ 1/公共\ html
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写条件%{REQUEST_URI}!^.*\。(css | jpe?g | gif | png | js | ico | ttf | woff | woff2)$[NC]
重写规则^index.php[QSA,L]
在这方面,我非常感谢您的帮助。我对apache不是很精通,我刚开始学习docker。提前谢谢你 你解决了吗?我现在也有同样的问题。。。