Skip to content

configure option disable-memcached-sasl not working #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabiocarneiro opened this issue Oct 11, 2016 · 8 comments
Closed

configure option disable-memcached-sasl not working #276

fabiocarneiro opened this issue Oct 11, 2016 · 8 comments

Comments

@fabiocarneiro
Copy link

fabiocarneiro commented Oct 11, 2016

The options has effect on configure, but on the build it requests sasl.h anyway.

Btw, I'm using official docker fpm alpine (php:7.0.11-fpm-alpine), and to be able to install the extension (php7 branch), I had to install cyrus-sasl-dev.

It was hard to find, because there are thousands of packages with sasl in the name and php docs call it "libsasl2".

@sodabrew
Copy link
Contributor

Please try php7 branch again.

@tyranron
Copy link

tyranron commented Oct 19, 2016

Seems that issue is not resolved still.

Can be reproduced with following Dockerfile:

FROM php:7.0.12-fpm-alpine


RUN apk add --update --no-cache \
        libmemcached-libs zlib \
        ca-certificates \
 && update-ca-certificates \

 && apk add --no-cache --virtual .tools-deps \
        git autoconf g++ libtool make \
 && apk add --no-cache --virtual .build-deps \
        libmemcached-dev \
        zlib-dev \

 && docker-php-source extract \
 && git clone --branch php7 https://github.com/php-memcached-dev/php-memcached \
              /usr/src/php/ext/memcached/ \
 && docker-php-ext-configure \
           memcached --disable-memcached-sasl \
 && docker-php-ext-install \
           memcached

Results with following error on step docker-php-ext-install memcached:

In file included from /usr/include/libmemcached-1.0/memcached.h:85:0,
                 from /usr/include/libmemcached/memcached.h:39,
                 from /usr/src/php/ext/memcached/php_libmemcached_compat.h:21,
                 from /usr/src/php/ext/memcached/php_memcached_private.h:28,
                 from /usr/src/php/ext/memcached/php_memcached.c:25:
/usr/include/libmemcached-1.0/struct/sasl.h:39:23: fatal error: sasl/sasl.h: No such file or directory
compilation terminated.
Makefile:194: recipe for target 'php_memcached.lo' failed
make: *** [php_memcached.lo] Error 1

@sodabrew
Copy link
Contributor

At least the error moved from inside the php-memcached headers to the libmemcached headers. I'll take a look if there are flags that should be set to skip the sasl.h include there, too.

@fabiocarneiro
Copy link
Author

fabiocarneiro commented Oct 19, 2016

I don't need this option anymore (for now), since I managed to configure it with the sasl support, but I created the issue so it would be helpful for someone else.

@Tairy
Copy link

Tairy commented Nov 3, 2016

Install cyrus-sasl-dev can solve this problem.

@tyranron
Copy link

tyranron commented Nov 3, 2016

@Tairy yeap. But the point of this issue in --disable-memcached-sasl case.

@baykier
Copy link

baykier commented Jan 19, 2017

my dockerfile is:

#
#参考docker-library/php/7.0/fpm/alpine 修改

FROM alpine:3.4

# persistent / runtime deps
ENV PHPIZE_DEPS \
		autoconf \
		file \
		g++ \
		gcc \
		libc-dev \
		make \
		pkgconf \
		re2c
RUN apk add --no-cache --virtual .persistent-deps \
		ca-certificates \
		curl \
		tar \
		xz

#以root用户运行注释下面
# ensure www-data user exists
#RUN set -x \
#	&& addgroup -g 82 -S www-data \
#	&& adduser -u 82 -D -S -G www-data www-data
# 82 is the standard uid/gid for "www-data" in Alpine
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2

ENV PHP_INI_DIR /usr/local/etc/php
RUN mkdir -p $PHP_INI_DIR/conf.d

##<autogenerated>##
##以root用户运行
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=root --with-fpm-group=root
##</autogenerated>##

# Apply stack smash protection to functions using local buffers and alloca()
# Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)
# Enable optimization (-O2)
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
# https://github.com/docker-library/php/issues/272
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"

ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763

ENV PHP_VERSION 7.0.14
ENV PHP_URL="https://secure.php.net/get/php-7.0.14.tar.xz/from/this/mirror" PHP_ASC_URL="https://secure.php.net/get/php-7.0.14.tar.xz.asc/from/this/mirror"
ENV PHP_SHA256="0f1dff6392a1cc2ed126b9695f580a2ed77eb09d2c23b41cabfb41e6f27a8c89" PHP_MD5="a51f1d4f03f4e4c745856e9f76fca476"

RUN set -xe; \
	\
	apk add --no-cache --virtual .fetch-deps \
		gnupg \
		openssl \
	; \
	\
	mkdir -p /usr/src; \
	cd /usr/src; \
	\
	wget -O php.tar.xz "$PHP_URL"; \
	\
	if [ -n "$PHP_SHA256" ]; then \
		echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c -; \
	fi; \
	if [ -n "$PHP_MD5" ]; then \
		echo "$PHP_MD5 *php.tar.xz" | md5sum -c -; \
	fi; \
	\
	if [ -n "$PHP_ASC_URL" ]; then \
		wget -O php.tar.xz.asc "$PHP_ASC_URL"; \
		export GNUPGHOME="$(mktemp -d)"; \
		for key in $GPG_KEYS; do \
			gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
		done; \
		gpg --batch --verify php.tar.xz.asc php.tar.xz; \
		rm -r "$GNUPGHOME"; \
	fi; \
	\
	apk del .fetch-deps

COPY docker-php-source /usr/local/bin/

##更改权限
RUN chmod 777 /usr/local/bin/docker-php-source

RUN set -xe \
	&& apk add --no-cache --virtual .build-deps \
		$PHPIZE_DEPS \
		curl-dev \
		libedit-dev \
		libxml2-dev \
		openssl-dev \
		sqlite-dev \
	\
	&& export CFLAGS="$PHP_CFLAGS" \
		CPPFLAGS="$PHP_CPPFLAGS" \
		LDFLAGS="$PHP_LDFLAGS" \
	&& docker-php-source extract \
	&& cd /usr/src/php \
	&& ./configure \
		--with-config-file-path="$PHP_INI_DIR" \
		--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
		\
		--disable-cgi \
		\
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
		--enable-ftp \
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
		--enable-mbstring \
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
		--enable-mysqlnd \
		\
		--with-curl \
		--with-libedit \
		--with-openssl \
		--with-zlib \
		\
		$PHP_EXTRA_CONFIGURE_ARGS \
	&& make -j "$(getconf _NPROCESSORS_ONLN)" \
	&& make install \
	&& { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \
	&& make clean \
	&& docker-php-source delete \
	\
	&& runDeps="$( \
		scanelf --needed --nobanner --recursive /usr/local \
			| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
			| sort -u \
			| xargs -r apk info --installed \
			| sort -u \
	)" \
	&& apk add --no-cache --virtual .php-rundeps $runDeps \
	\
	&& apk del .build-deps

COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/

##更改权限
RUN chmod 777 /usr/local/bin/docker-php-ext-* \
	&& chmod 777 /usr/local/bin/docker-php-entrypoint


##     安装扩展
RUN apk add --no-cache --virtual .build-deps  \
    						git \
    						libmemcached-dev  \
    						zlib-dev \
    						cyrus-sasl-dev \
    						autoconf \
    						g++ \
    						libtool \
    						make \
    	&& docker-php-source extract \
    	##安装memcache 扩展
    	&& git clone https://github.com/websupport-sk/pecl-memcache.git /usr/src/php/ext/memcache/ \
        && docker-php-ext-configure memcache \
        && docker-php-ext-install memcache \
        && rm -rf /usr/src/php/ext/memcache \
        ##安装memcached 扩展
        && git clone --branch php7 https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached/ \
        && docker-php-ext-configure memcached \
        && docker-php-ext-install memcached \
        && rm -rf /usr/src/php/ext/memcached \
        && apk del --no-cache libmemcached-dev \
        			zlib-dev \
        			cyrus-sasl-dev \
        ##安装gd库
        && apk add 	--no-cache \
           			freetype \
           			libpng \
           			libjpeg-turbo \
           			freetype-dev \
           			libpng-dev \
           			libjpeg-turbo-dev\
        && docker-php-ext-configure gd \
           			--with-gd \
           			--with-freetype-dir=/usr/include/ \
           			--with-png-dir=/usr/include/ \
           			--with-jpeg-dir=/usr/include/ \

        && docker-php-ext-install gd \
        && docker-php-ext-enable gd \
        && apk del 	--no-cache \
           			freetype-dev \
           			libpng-dev \
           			libjpeg-turbo-dev \
        ##启用xdebug
        && pecl install xdebug-2.5.0 \
        && docker-php-ext-enable xdebug \
        ##安装pdo_mysql
        && docker-php-ext-install pdo_mysql \
        ##安装redis
        && pecl install redis-3.1.0 \
        && docker-php-ext-enable redis \
        ##安装mcrypt
        && apk add --no-cache libmcrypt-dev \
        && docker-php-ext-configure mcrypt \
        && docker-php-ext-install mcrypt \
        && apk del --no-cache libmcrypt-dev \

		##清除
        && docker-php-source delete \
        && apk del .build-deps

ENTRYPOINT ["docker-php-entrypoint"]
##<autogenerated>##
##工作目录设置为 /var/project
WORKDIR /var/project

RUN set -ex \
	&& cd /usr/local/etc \
	&& if [ -d php-fpm.d ]; then \
		# for some reason, upstream's php-fpm.conf.default has "include=NONE/etc/php-fpm.d/*.conf"
		sed 's!=NONE/!=!g' php-fpm.conf.default | tee php-fpm.conf > /dev/null; \
		cp php-fpm.d/www.conf.default php-fpm.d/www.conf; \
	else \
		# PHP 5.x doesn't use "include=" by default, so we'll create our own simple config that mimics PHP 7+ for consistency
		mkdir php-fpm.d; \
		cp php-fpm.conf.default php-fpm.d/www.conf; \
		{ \
			echo '[global]'; \
			echo 'include=etc/php-fpm.d/*.conf'; \
		} | tee php-fpm.conf; \
	fi \
	&& { \
		mkdir -p /var/log/php \
		echo '[global]'; \
		echo 'error_log = /var/log/php/error.log'; \
		echo; \
		echo '[www]'; \
		echo '; if we send this to /proc/self/fd/1, it never appears'; \
		echo 'access.log = /proc/self/fd/2'; \
		echo; \
		echo 'clear_env = no'; \
		echo; \
		echo '; Ensure worker stdout and stderr are sent to the main error log.'; \
		echo 'catch_workers_output = yes'; \
	} | tee php-fpm.d/docker.conf \
	&& { \
		echo '[global]'; \
		echo 'daemonize = no'; \
		echo; \
		echo '[www]'; \
		echo 'listen = [::]:9000'; \
	} | tee php-fpm.d/zz-docker.conf

VOLUME ["/var/project","/etc/php-fpm.d","/var/log/php"]

EXPOSE 9000

CMD ["php-fpm"]
##</autogenerated>##

build is ok! but when i test:

docker run --rm registry.cn-hangzhou.aliyuncs.com/baykier-dev/devbox:php-alpine-7.0 -m

error exits!

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - Error loading shared library libmcrypt.so.4: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/memcached.so' - Error loading shared library libmemcached.so.11: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20151012/memcached.so) in Unknown on line 0
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
....

anyone can take is?

@sodabrew
Copy link
Contributor

sodabrew commented Feb 7, 2017

This is not fixable. When libmemcached is compiled with SASL support, it writes out its header files in such a way that it always requires the sasl.h header even if you disable SASL support in php-memcached.

@sodabrew sodabrew closed this as completed Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants