raspberry pi4 에서 php build 하기

php를 받고 ./configure 해서 빌드를 시작한다.
하는 중에 아래 에러 발생
configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:

No package 'libxml-2.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBXML_CFLAGS
and LIBXML_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

libxml2-dev를 받았다
apt install libxml2-dev

다시 빌드하는데 아래 에러발생
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:


No package 'sqlite3' found


Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.


Alternatively, you may set the environment variables SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

sqlite3를 받아준다.

apt install sqlite3

그런데 repository의 버전이 3.27.2-3 이 최신이다. 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sqlite3 is already the newest version (3.27.2-3).

sqlite를 쓰지 않을것 같으니 그냥 제외하기로했다.
./configure --without-sqlite3

그런데 실패한다 ㅠㅠ
그래서 그냥 최신을 받아보기로 했다.

혹시 모르니 설치된 sqlite3는 제거한다.
apt remove sqlite3
https://www.sqlite.org/download.html 에서 최신을 받은후 빌드해본다.
./configure
make
make install
빌드에 7분 정도 시간이 소요된뒤에 완료되었다.

sqlite3 --version
버전을 확인해보니 잘 설치 된것을 확인할 수 있었다.

3.32.0 2020-03-12 17:54:39 ea914bec81c49625072fc9d23faa048300f3a0421e069d303b7203edcdfb3743

다시 php로 돌아가서 ./configure를 시도했다.
성공
혹시모르니 설치전에 미리 apt로 설치된 php를 제거해줬다.
apt remove php-common php7.3-common
apt autoremove

이제  빌드해보자. 
make
30분 정도 소요후 빌드 완료되었다.
안내 되는 대로 make test를 해봤는데 시간이 꽤 걸려서 contribute를 하고 싶은게 아니면 굳이 할 필요 없는것 같다.
make install
설치를 마무리 했다.
php --version
잘 설치 된 것을 확인 할 수 있었다.
PHP 7.4.3 (cli) (built: Mar 17 2020 23:50:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

내친김에 apache도 설치해본다.
./configure
또 에러가 발생했다.
checking for APR... no
configure: error: APR not found.  Please read the documentation.
 APR은 Apache Portable Runtime이라고 한다.

arp를 설치해주자.
./configure
마지막 로그에 보면 에러가 발생한것처럼 보이나, 무시해도 되는듯 하다.
rm: cannot remove 'libtoolT': No such file or directory
빌드해주자
make
make install
별다른 에러 없이 완료
다시 httpd에 돌아가서 configure를 해보니
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
APR-util 도 있구나..
같이 설치해준다.
./configure --with-apr=/usr/local/apr/
위에 설치 해줬을때 나온 경로로 옵션을 줘야 하는것 같다. 옵션을 주지 않으면 아래와 같은 에러를 뱉는다.
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
그럼 빌드하자
make
make install
다시 httpd에서 configure 하니 에러.
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
pcre.. Perl Compatible Regular Expressions 이라고 한다. 
길어지는것 같으니.. 에러만 나열하면서 쭉 설치를 진행해봤다
결국 모든 패키지들이 아래와 같은 순서로 진행되었고, 필요하다는 패키지들만 설치하면서 진행하면 된다.
wget <package>
tar zxvf <package>
cd <package_directory>
# README / INSTALL 파일 확인
./configure
make
make install

설치된 패키지 위치는 /usr/local/apache2 이고, 이쪽에 있는 bin을 사용해야한다. 필요시 path에 추가해서 사용하면 되겠다.
path는 각 계정 (내 경우는 root)의 home 디렉터리에 있는 rc파일에 넣어준다. (.bashrc, .zshrc 등)

apachectl 을 사용하려보니 아래에러가 발생한다.
/usr/local/apache2/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
LIB 경로를 추가해주자.
library는 /etc/environment에 추가해줬다.
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
혹시같은 에러가 발생하면 logout후 다시 로그인해주면 된다.
lynx 관련 에러 발생시 lynx도 설치해준다.

다 해놓고, apache에  php7_module설치를 못해서 좀 헤매었다.
결국 아래옵션을 주고 php를 다시 빌드했다.
apache를 설치한 뒤에 그 경로를 옵션으로 주었다.
./configure --with-apxs2=/usr/local/apache2/bin/apxs
make; make install


'준슝 > homelab' 카테고리의 다른 글

BIND9 DNS 설치하기  (0) 2020.07.01

+ Recent posts