Created
March 12, 2023 16:40
-
-
Save divinity76/c09ba2a168261e32a81d4d98dcbc335c to your computer and use it in GitHub Desktop.
dockerfile old php mysql thingy..
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:20.04 | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update -y | |
RUN apt-get -y full-upgrade; | |
RUN apt-get -y install apt-utils | |
RUN apt-get -y install default-mysql-server libmysqlclient-dev git make autoconf gcc re2c wget xz-utils tar file bison | |
RUN git clone -b 'PHP-7.3' --depth 1 https://github.com/php/php-src.git php56 | |
# https://askubuntu.com/questions/1329414/why-is-my-global-h-from-libmysqlclient-dev-is-missing-in-ubuntu-20-04 | |
#RUN touch /usr/include/mysql/my_global.h | |
#RUN apt-get install -y bison | |
# PHP5.5 (and older 5.6 but not 5.6.40) require bison 2.x... | |
#RUN \ | |
#wget https://ftp.gnu.org/gnu/bison/bison-2.7.tar.xz && \ | |
#tar -xvf bison-2.7.tar.xz && \ | |
#cd bison-2.7/ && \ | |
#chmod +x configure && \ | |
#mkdir build && \ | |
#./configure --prefix=/bison2 && \ | |
#make -j $(nproc) && \ | |
#make install && \ | |
#chmod +x /bison2/bin/bison | |
#ENV PATH="/bison2/bin:$PATH" | |
RUN echo hi && \ | |
cd 'php56' && \ | |
./buildconf --force && \ | |
./configure --disable-all --disable-cgi --enable-cli --enable-pdo --with-pdo-mysql=/usr/bin/mysql_config --with-mysqli=/usr/bin/mysql_config && \ | |
make clean && \ | |
make -j $(nproc); | |
RUN cp php56/sapi/cli/php /php | |
RUN /php --version | |
# probably not required in the Microsoft/Freexian php56 but we're on the vanilla php56 | |
# Connect Error: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client | |
# https://stackoverflow.com/a/50790434/1067003 | |
RUN printf '[mysql]\ndefault-character-set=utf8\n\n[mysqld]\ncollation-server = utf8_unicode_ci\ncharacter-set-server = utf8' >> /etc/mysql/conf.d/charset.cnf | |
# again probably not needed in the Microsoft/Freexian php56, but we're on vanilla php56 | |
# PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Command line code on line 1 | |
RUN \ | |
printf "[mysqld]\ndefault-authentication-plugin=mysql_native_password" >> /etc/mysql/mysql.conf.d/default-auth-plugin.cnf && \ | |
service mysql start && \ | |
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';" && \ | |
mysql -e "UPDATE mysql.user SET plugin='auth_socket' WHERE User='root';" && \ | |
mysql -e "SELECT user,authentication_string,plugin,host FROM mysql.user;" && \ | |
service mysql stop; | |
RUN \ | |
service mysql start && \ | |
service mysql status && \ | |
/php -r '$db = new PDO("mysql:unix_socket=/var/run/mysqld/mysqld.sock;charset=utf8mb4", "root", "", \ | |
array( \ | |
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, \ | |
PDO::ATTR_EMULATE_PREPARES => false, \ | |
)); \ | |
var_dump($db->query("CREATE DATABASE db;")); \ | |
var_dump($db->query("CREATE TABLE db.t (c int);")); \ | |
var_dump($db->query("alter table db.t add column c1 int")->fetchAll()); \ | |
var_dump($db->query("SELECT 1")->fetchAll()); \ | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trying to build this crash with