DBD::mysql on MacBook Air(M1 macOS Monterey 12.0.1)

[日本語]

Actually, I did a lot of  try and error. so I am not sure the following instruction is sufficient.

You can also get information on the link below.
apache + perl + cgi + mysql (DBD::mysql, DBI) on MacBook M1 using Docker

 

(1)  brew install openssl
(2) add following setting on ~/.zshrc

export LIBRARY_PATH=/opt/homebrew/opt/openssl/lib
export C_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI/
export CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI/

(3)source ~/.zshrc

(4)download and install DBI-1.643.tar.gz
(4.1)GET https://www.cpan.org/modules/by-module/DBI/DBI-1.643.tar.gz
(4.2)extract it on any directory you like.
(4.3)perl Makefile.PL
(4.4)make
(4.5)make install

(5) cpan install DBD::mysql

 

■Additional information

(1)Why you need to add some directory in ~/.zshrc

export LIBRARY_PATH=/opt/homebrew/opt/openssl/lib

-> If you don’t add the path above. you will encounter the following error, when “cpan install DBD::mysql”
“Can’t link/include C library ‘ssl’, ‘crypto’, aborting.”

export C_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI/
export CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI/

-> If you don’t add the path above. you will encounter the following error.
‘DBIXS.h’ file not found

Why you need to install DBI-1.643.tar.gz
->I followed the information below.
https://stackoverflow.com/questions/68774807/dbdmysql-installation-on-catalina-big-sur-fail-with-extern-h-file-not-found

 

If you want to create the environment using Docker.

See the following link.

apache + perl + cgi + mysql (DBD::mysql, DBI) on MacBook M1 using Docker