Last active
February 6, 2023 09:04
-
-
Save mistymagich/b296bf0eec446137a92d18f889a018e8 to your computer and use it in GitHub Desktop.
Apache 2.4.54とPHP 5.2.17のDockerイメージを作る – https://mistymagich.wordpress.com/2023/02/02/apache-2-4-54%E3%81%A8php-5-2-17%E3%81%AEdocker%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%82%92%E4%BD%9C%E3%82%8B/
This file contains 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
--- a/ext/openssl/xp_ssl.c | |
+++ b/ext/openssl/xp_ssl.c | |
@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp | |
sslsock->is_client = 1; | |
method = SSLv23_client_method(); | |
break; | |
+#ifndef OPENSSL_NO_SSL2 | |
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: | |
sslsock->is_client = 1; | |
method = SSLv2_client_method(); | |
break; | |
+#endif | |
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: | |
sslsock->is_client = 1; | |
method = SSLv3_client_method(); | |
@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp | |
sslsock->is_client = 0; | |
method = SSLv3_server_method(); | |
break; | |
+#ifndef OPENSSL_NO_SSL2 | |
case STREAM_CRYPTO_METHOD_SSLv2_SERVER: | |
sslsock->is_client = 0; | |
method = SSLv2_server_method(); | |
break; | |
+#endif | |
case STREAM_CRYPTO_METHOD_TLS_SERVER: | |
sslsock->is_client = 0; | |
method = TLSv1_server_method(); | |
@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop | |
case STREAM_CRYPTO_METHOD_SSLv23_CLIENT: | |
sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER; | |
break; | |
+#ifndef OPENSSL_NO_SSL2 | |
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: | |
sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER; | |
break; | |
+#endif | |
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: | |
sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER; | |
break; | |
@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto | |
if (strncmp(proto, "ssl", protolen) == 0) { | |
sslsock->enable_on_connect = 1; | |
sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT; | |
+#ifndef OPENSSL_NO_SSL2 | |
} else if (strncmp(proto, "sslv2", protolen) == 0) { | |
sslsock->enable_on_connect = 1; | |
sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; | |
+#endif | |
} else if (strncmp(proto, "sslv3", protolen) == 0) { | |
sslsock->enable_on_connect = 1; | |
sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT; |
This file contains 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
# ビルドステージ | |
FROM ubuntu:14.04 as build | |
# ビルドに必要なもの | |
ENV BUILD_DEPENDENCIES curl make patch | |
RUN apt update && apt install -y $BUILD_DEPENDENCIES && rm -r /var/lib/apt/lists/* | |
ENV SOURCE_DIR /usr/local/src | |
# Apacheビルド | |
ENV APACHE_BUILD_DEPENDENCIES libapr1-dev libaprutil1-dev | |
ENV APACHE_SOURCE_DIR $SOURCE_DIR/httpd | |
RUN set -eux \ | |
# 依存パッケージインストール | |
&& apt update && apt install -y $APACHE_BUILD_DEPENDENCIES \ | |
# ソースコードダウンロード・展開 | |
&& cd $SOURCE_DIR \ | |
&& curl -SL https://archive.apache.org/dist/httpd/httpd-2.4.54.tar.gz -o httpd.tar.gz \ | |
&& mkdir -p $APACHE_SOURCE_DIR \ | |
&& tar -xf httpd.tar.gz -C $APACHE_SOURCE_DIR --strip-components=1 \ | |
# configure, make | |
&& cd httpd \ | |
&& ./configure --enable-so \ | |
&& make -j"$(nproc)" \ | |
# インストール | |
&& make install \ | |
# ビルドファイル、依存パッケージ削除 | |
&& rm -r $SOURCE_DIR/httpd.tar.gz $APACHE_SOURCE_DIR \ | |
&& apt remove -y $APACHE_BUILD_DEPENDENCIES \ | |
&& apt-get autoremove -y && rm -r /var/lib/apt/lists/* | |
# PHP設定ファイルディレクトリを作成 | |
ENV PHP_BUILD_DEPENDENCIES libapr1-dev libaprutil1-dev \ | |
libxml2-dev libcurl4-openssl-dev libjpeg-dev \ | |
libpng12-dev libfreetype6-dev libt1-dev libmcrypt-dev libmhash-dev libmysqlclient-dev libltdl7-dev | |
ENV PHP_SOURCE_DIR $SOURCE_DIR/php | |
ENV PHP_INI_DIR /usr/local/etc/php | |
RUN mkdir -p $PHP_INI_DIR/conf.d | |
# パッチをコピー | |
COPY patch/*.patch $PHP_SOURCE_DIR/ | |
# PHPビルド | |
RUN set -eux \ | |
# 依存パッケージインストール | |
&& apt update && apt install -y $PHP_BUILD_DEPENDENCIES \ | |
# FreeType2インクルードファイルパス調整 | |
&& mkdir -pv /usr/include/freetype2/freetype \ | |
&& ln -sf /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h \ | |
# ソースコードダウンロード・展開 | |
&& cd $SOURCE_DIR \ | |
&& curl -SL "http://museum.php.net/php5/php-5.2.17.tar.bz2" -o php.tar.bz2 \ | |
&& mkdir -p $PHP_SOURCE_DIR \ | |
&& tar -xf php.tar.bz2 -C $PHP_SOURCE_DIR --strip-components=1 \ | |
&& cd $PHP_SOURCE_DIR \ | |
# パッチ | |
&& patch -p0 -b < $PHP_SOURCE_DIR/xml.patch \ | |
&& patch -p1 -b < $PHP_SOURCE_DIR/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch \ | |
&& patch -l -p0 -b < $PHP_SOURCE_DIR/libphp5.so.patch \ | |
# configure, make | |
&& ./configure \ | |
--with-config-file-path=$PHP_INI_DIR \ | |
--with-config-file-scan-dir=$PHP_INI_DIR/conf.d \ | |
--with-libdir=lib/x86_64-linux-gnu \ | |
--with-apxs2=/usr/local/apache2/bin/apxs \ | |
--with-gd \ | |
--with-png-dir=/usr/lib \ | |
--with-jpeg-dir=/usr/lib \ | |
--with-freetype-dir \ | |
--enable-mbstring \ | |
--with-mysql \ | |
--with-mysqli \ | |
--with-pdo-mysql \ | |
--with-zlib \ | |
--with-openssl \ | |
--with-curl \ | |
--with-mhash \ | |
--with-mcrypt \ | |
--enable-zip \ | |
&& make -j"$(nproc)" \ | |
# インストール | |
&& make install \ | |
# 設定ファイルコピー | |
&& cp /usr/local/src/php/php.ini-recommended $PHP_INI_DIR/php.ini-recommended \ | |
# # ビルドファイル、依存パッケージ削除 | |
&& rm -r $SOURCE_DIR//php.tar.bz2 $PHP_SOURCE_DIR \ | |
&& apt remove -y $PHP_BUILD_DEPENDENCIES \ | |
&& apt-get autoremove -y && rm -r /var/lib/apt/lists/* | |
RUN apt remove -y $BUILD_DEPENDENCIES && apt-get autoremove -y && rm -r /var/lib/apt/lists/* | |
# ランタイムステージ | |
FROM ubuntu:14.04 as runtime | |
# 依存パッケージのインストール | |
ENV RUNTIME_DEPENDENCIES libapr1 libaprutil1 libcurl3 libxml2 libjpeg8 libfreetype6 \ | |
libt1-5 libmcrypt4 libmhash2 libmysqlclient18 | |
RUN apt update \ | |
&& apt install -y $RUNTIME_DEPENDENCIES \ | |
&& rm -r /var/lib/apt/lists/* | |
# 生成物コピー | |
COPY --from=build /usr/local /usr/local | |
# Apache設定 | |
RUN set -eux \ | |
&& cd / \ | |
&& mkdir -p /var/www/html \ | |
&& sed -i -r " \ | |
s/(DirectoryIndex index[.])html/\1php index\.html/; \ | |
s#/usr/local/apache2/htdocs#/var/www/html#g; \ | |
s#^(\s*CustomLog)\s+\S+#\1 /proc/self/fd/1#g; \ | |
s#^(\s*ErrorLog)\s+\S+#\1 /proc/self/fd/2#g; \ | |
s/#LoadModule rewrite_module/LoadModule rewrite_module/g; \ | |
/<Directory \"\/var\/www\/html\">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/; \ | |
$ a<FilesMatch \\.php$>\n\tSetHandler application/x-httpd-php\n</FilesMatch> \ | |
" /usr/local/apache2/conf/httpd.conf \ | |
&& echo "<html><head></head><body><?php echo '<h1>Hello, World!</h1>'; ?></body></html>" > /var/www/html/index.php | |
# PHP設定 | |
ENV PHP_INI_DIR /usr/local/etc/php | |
RUN set -eux \ | |
&& sed '/\;error_log = syslog/a error_log=/proc/1/fd/2' $PHP_INI_DIR/php.ini-recommended > $PHP_INI_DIR/php.ini | |
ENV PATH $PATH:/usr/local/apache2/bin | |
ENV PATH $PATH:/usr/local/bin/ | |
WORKDIR /var/www/html | |
VOLUME /var/www/html | |
EXPOSE 80 | |
CMD ["httpd", "-DFOREGROUND"] |
This file contains 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
--- sapi/apache2handler/php_functions.c 2023-01-19 14:24:50.358748972 +0000 | |
+++ sapi/apache2handler/php_functions.c 2023-01-19 14:24:34.889896546 +0000 | |
@@ -383,7 +383,7 @@ | |
char *p; | |
server_rec *serv = ((php_struct *) SG(server_context))->r->server; | |
#if !defined(WIN32) && !defined(WINNT) && !defined(NETWARE) | |
- AP_DECLARE_DATA extern unixd_config_rec unixd_config; | |
+ AP_DECLARE_DATA extern unixd_config_rec ap_unixd_config; | |
#endif | |
for (n = 0; ap_loaded_modules[n]; ++n) { | |
@@ -414,7 +414,7 @@ | |
php_info_print_table_row(2, "Hostname:Port", tmp); | |
#if !defined(WIN32) && !defined(WINNT) && !defined(NETWARE) | |
- snprintf(tmp, sizeof(tmp), "%s(%d)/%d", unixd_config.user_name, unixd_config.user_id, unixd_config.group_id); | |
+ snprintf(tmp, sizeof(tmp), "%s(%d)/%d", ap_unixd_config.user_name, ap_unixd_config.user_id, ap_unixd_config.group_id); | |
php_info_print_table_row(2, "User/Group", tmp); | |
#endif |
This file contains 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
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800 | |
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800 | |
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA | |
RETVAL_FALSE; | |
} else { | |
if (mode == 0) { | |
+#ifdef LIBXML2_NEW_BUFFER | |
+ ret = xmlOutputBufferGetSize(buf); | |
+#else | |
ret = buf->buffer->use; | |
+#endif | |
if (ret > 0) { | |
+#ifdef LIBXML2_NEW_BUFFER | |
+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1); | |
+#else | |
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1); | |
+#endif | |
} else { | |
RETVAL_EMPTY_STRING(); | |
} | |
--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800 | |
+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800 | |
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea | |
if (buff != NULL) { | |
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); | |
xmlOutputBufferFlush(buff); | |
+ | |
+#ifdef LIBXML2_NEW_BUFFER | |
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), | |
+ xmlOutputBufferGetSize(buff), 1); | |
+#else | |
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1); | |
+#endif | |
(void)xmlOutputBufferClose(buff); | |
return SUCCESS; | |
} | |
--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800 | |
+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800 | |
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML) | |
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); | |
xmlOutputBufferFlush(outbuf); | |
+#ifdef LIBXML2_NEW_BUFFER | |
+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), | |
+ xmlOutputBufferGetSize(outbuf), 1); | |
+#else | |
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); | |
+#endif | |
xmlOutputBufferClose(outbuf); | |
} | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment