티스토리 뷰

Programming/Apache, PHP

Ubuntu 20.04 : PHP5 설치

파란크리스마스 2020. 11. 25. 00:43
728x90

출처

필요 라이브러리 설치

bluesanta@Kubuntu:~$ sudo apt install libc-client2007e-dev libgdbm-dev libgmp-dev libkrb5-dev

libmcrypt 설치

bluesanta@Kubuntu:~$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
bluesanta@Kubuntu:~$ tar xvfz libmcrypt-2.5.8.tar.gz
bluesanta@Kubuntu:~$ cd libmcrypt-2.5.8/
bluesanta@Kubuntu:~/libmcrypt-2.5.8$ ./configure
bluesanta@Kubuntu:~/libmcrypt-2.5.8$ make
bluesanta@Kubuntu:~/libmcrypt-2.5.8$ sudo make install

mhash 설치

bluesanta@Kubuntu:~$ wget https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
bluesanta@Kubuntu:~$ tar xvfz mhash-0.9.9.9.tar.gz
bluesanta@Kubuntu:~$ cd mhash-0.9.9.9/
bluesanta@Kubuntu:~/mhash-0.9.9.9$ ./configure
bluesanta@Kubuntu:~/mhash-0.9.9.9$ make
bluesanta@Kubuntu:~/mhash-0.9.9.9$ sudo make install

FreeTDS 설치

bluesanta@Kubuntu:~$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
bluesanta@Kubuntu:~$ tar xvfz freetds-patched.tar.gz
bluesanta@Kubuntu:~$ cd freetds-1.2.12/
bluesanta@Kubuntu:~/freetds-1.2.12$ ./configure -prefix=/usr/local/freetds --disable-odbc --disable-debug --enable-msdblib
bluesanta@Kubuntu:~/freetds-1.2.12$ make
bluesanta@Kubuntu:~/freetds-1.2.12$ sudo make install

freetype2 설치

bluesanta@Kubuntu:~$ wget https://downloads.sourceforge.net/freetype/freetype-2.10.4.tar.xz
bluesanta@Kubuntu:~$ tar xvf freetype-2.10.4.tar.xz
bluesanta@Kubuntu:~$ cd freetype-2.10.4/
bluesanta@Kubuntu:~/freetype-2.10.4$ ./configure --prefix=/usr --enable-freetype-config 
bluesanta@Kubuntu:~/freetype-2.10.4$ make -j4
bluesanta@Kubuntu:~/freetype-2.10.4$ sudo make install

openssl 설치

bluesanta@Kubuntu:~$ wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
bluesanta@Kubuntu:~$ tar xvfz openssl-1.0.2u.tar.gz
bluesanta@Kubuntu:~$ cd openssl-1.0.2u
bluesanta@Kubuntu:~/openssl-1.0.2u$ ./config -fPIC shared --prefix=/opt/openssl-1.0.2u
bluesanta@Kubuntu:~/openssl-1.0.2u$ make -j4
bluesanta@Kubuntu:~/openssl-1.0.2u$ sudo make install
bluesanta@Kubuntu:~/openssl-1.0.2u$/opt/openssl-1.0.2u/bin/openssl version
OpenSSL 1.0.2u  20 Dec 2019

libcurl 설치

bluesanta@Kubuntu:~$ wget https://curl.haxx.se/download/curl-7.73.0.tar.gz
bluesanta@Kubuntu:~$ tar xvfz curl-7.73.0.tar.gz 
bluesanta@Kubuntu:~$ cd curl-7.73
bluesanta@Kubuntu:~/curl-7.73.0$ env PKG_CONFIG_PATH=/opt/openssl-1.0.2u/lib/pkgconfig ./configure --prefix=/opt/curl-7.73.0 --with-openssl
... 생략 ...
  SSL:              enabled (OpenSSL)
... 생략 ...
bluesanta@Kubuntu:~/curl-7.73.0$ make
bluesanta@Kubuntu:~/curl-7.73.0$ sudo make install
bluesanta@Kubuntu:~/curl-7.73.0$ sudo ln -s /opt/openssl-1.0.2u/lib/libssl.so.1.0.0 /usr/lib/libssl.so.1.0.0
bluesanta@Kubuntu:~/curl-7.73.0$ sudo ln -s /opt/openssl-1.0.2u/lib/libcrypto.so.1.0.0 /usr/lib/libcrypto.so.1.0.0
bluesanta@Kubuntu:~/curl-7.73.0$ /opt/curl-7.73.0/bin/curl --version
curl 7.73.0 (x86_64-pc-linux-gnu) libcurl/7.73.0 OpenSSL/1.0.2u zlib/1.2.11
Release-Date: 2020-10-14
Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

PHP5 설치

1. PHP5 컴파일 오류 수정

오류 메시지

configure: error: Unable to locate gmp.h

해결방법

bluesanta@Kubuntu:~$ sudo ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

2. PHP5 컴파일 오류 수정

오류 메시지

configure: error: wrong mysql library version or lib not found. Check config.log for more information.

해결방법

bluesanta@Kubuntu:~/php-5.6.40$ sudo ln -s /bluesanta/mysql-5.7.23/lib/libmysqlclient.so /bluesanta/mysql-5.7.23/lib/libmysqlclient_r.so

2. PHP5 컴파일 오류 회피

오류 메시지

/bin/bash: line 1: 3884732 세그멘테이션 오류 (core dumped) ` if test -x "/home/bluesanta/php-5.6.40/sapi/cli/php"; then /home/bluesanta/php-5.6.40/build/shtool echo -n -- "/home/bluesanta/php-5.6.40/sapi/cli/php -n"; if test "x" != "x"; then /home/bluesanta/php-5.6.40/build/shtool echo -n -- " -d extension_dir=/home/bluesanta/php-5.6.40/modules"; for i in bz2 zlib phar; do if test -f "/home/bluesanta/php-5.6.40/modules/$i.la"; then . /home/bluesanta/php-5.6.40/modules/$i.la; /home/bluesanta/php-5.6.40/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /home/bluesanta/php-5.6.40/build/shtool echo -n -- "/home/bluesanta/php-5.6.40/sapi/cli/php"; fi;` -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0' /home/bluesanta/php-5.6.40/ext/phar/build_precommand.php > ext/phar/phar.php
make: *** [Makefile:381: ext/phar/phar.php] 오류 139
make: *** 끝나지 않은 작업을 기다리고 있습니다....

configure 해당 옵션 제거

--with-imap=/usr/local/imap-2007f \
--with-imap-ssl \

PHP5 컴파일

bluesanta@Kubuntu:~$ wget https://www.php.net/distributions/php-5.6.40.tar.gz
bluesanta@Kubuntu:~$ tar xvfz php-5.6.40.tar.gz
bluesanta@Kubuntu:~$ bluesanta@Kubuntu:~$ cd php-5.6.40/
bluesanta@Kubuntu:~/php-5.6.40$ env PKG_CONFIG_PATH=/opt/openssl-1.0.2u/lib/pkgconfig \
./configure --prefix=/bluesanta/apps/php-5.6.40 \
--enable-fpm \
--with-apxs2=/bluesanta/apps/apache24_php5/bin/apxs \
--with-libdir=/lib \
--with-gettext \
--with-gmp \
--with-gd \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir=/usr/local/lib \
--with-mcrypt=/usr/local/lib \
--with-iconv \
--with-freetype-dir=/usr/local/freetype \
--with-config-file-path=/usr/local/lib \
--enable-gd-native-ttf \
--enable-bcmath \
--enable-exif \
--with-mcrypt \
--with-zlib \
--with-bz2 \
--enable-mbstring \
--enable-opcache \
--with-openssl=/opt/openssl-1.0.2u \
--with-curl=/opt/curl-7.73.0/bin/curl \
--with-mysql-sock=/bluesanta/mysql-5.7.23/mysql.sock \
--with-mysqli=/bluesanta/mysql-5.7.23/bin/mysql_config \
--with-pdo-mysql=/bluesanta/mysql-5.7.23 \
--with-mysql \
--with-mssql=/usr/local/freetds \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-libxml-dir=/usr \
--with-kerberos \
--disable-debug \
--enable-soap \
--with-gdbm \
--enable-ftp \
--enable-calendar \
--enable-shmop \
--enable-inline-optimization \
--enable-sigchild \
--enable-sockets \
--enable-maintainer-zts
bluesanta@Kubuntu:~/php-5.6.40$ make -j4
 
... 생략 ...
 
/usr/bin/ld: warning: libssl.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libssl.so.1.0.0
/usr/bin/ld: warning: libcrypto.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libcrypto.so.1.0.0
/usr/bin/ld: warning: libssl.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libssl.so.1.0.0
/usr/bin/ld: warning: libcrypto.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libcrypto.so.1.0.0
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorytreeiterator.inc
clicommand.inc
directorygraphiterator.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc
/usr/bin/ld: warning: libssl.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libssl.so.1.0.0
/usr/bin/ld: warning: libcrypto.so.1.1, needed by /usr/local/freetds/lib/libsybdb.so, may conflict with libcrypto.so.1.0.0
bluesanta@Kubuntu:~/php-5.6.40$ make test

PHP5 설치

bluesanta@Kubuntu:~/php-5.6.40$ make install
/bin/bash /home/bluesanta/php-5.6.40/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /home/bluesanta/php-5.6.40/modules
Installing PHP SAPI module:       apache2handler
/bluesanta/apps/apache24/build/instdso.sh SH_LIBTOOL='/bluesanta/apps/apache24/build/libtool' libphp5.la /bluesanta/apps/apache24/modules
/bluesanta/apps/apache24/build/libtool --mode=install install libphp5.la /bluesanta/apps/apache24/modules/
libtool: install: install .libs/libphp5.so /bluesanta/apps/apache24/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /bluesanta/apps/apache24/modules/libphp5.la
libtool: warning: remember to run 'libtool --finish /home/bluesanta/php-5.6.40/libs'
chmod 755 /bluesanta/apps/apache24/modules/libphp5.so
[activating module `php5' in /bluesanta/apps/apache24/conf/httpd.conf]
Installing shared extensions:     /bluesanta/apps/php-5.6.40/lib/php/extensions/no-debug-zts-20131226/
Installing PHP CLI binary:        /bluesanta/apps/php-5.6.40/bin/
Installing PHP CLI man page:      /bluesanta/apps/php-5.6.40/php/man/man1/
Installing PHP FPM binary:        /bluesanta/apps/php-5.6.40/sbin/
Installing PHP FPM config:        /bluesanta/apps/php-5.6.40/etc/
Installing PHP FPM man page:      /bluesanta/apps/php-5.6.40/php/man/man8/
Installing PHP FPM status page:   /bluesanta/apps/php-5.6.40/php/php/fpm/
Installing PHP CGI binary:        /bluesanta/apps/php-5.6.40/bin/
Installing PHP CGI man page:      /bluesanta/apps/php-5.6.40/php/man/man1/
Installing build environment:     /bluesanta/apps/php-5.6.40/lib/php/build/
Installing header files:           /bluesanta/apps/php-5.6.40/include/php/
Installing helper programs:       /bluesanta/apps/php-5.6.40/bin/
  program: phpize
  program: php-config
Installing man pages:             /bluesanta/apps/php-5.6.40/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /bluesanta/apps/php-5.6.40/lib/php/
[PEAR] Archive_Tar    - already installed: 1.4.4
[PEAR] Console_Getopt - already installed: 1.4.1
[PEAR] Structures_Graph- already installed: 1.1.1
[PEAR] XML_Util       - already installed: 1.4.3
[PEAR] PEAR           - already installed: 1.10.7
Wrote PEAR system config file at: /bluesanta/apps/php-5.6.40/etc/pear.conf
You may want to add: /bluesanta/apps/php-5.6.40/lib/php to your php.ini include_path
/home/bluesanta/php-5.6.40/build/shtool install -c ext/phar/phar.phar /bluesanta/apps/php-5.6.40/bin
ln -s -f phar.phar /bluesanta/apps/php-5.6.40/bin/phar
Installing PDO headers:           /bluesanta/apps/php-5.6.40/include/php/ext/pdo/




php.ini 복사

bluesanta@Kubuntu:~/php-5.6.40$ cp php.ini-production /bluesanta/apps/php-5.6.40/php.ini

libphp5.so 복사

bluesanta@Kubuntu:~/php-5.6.40$ cp /bluesanta/apps/apache24/modules/libphp5.so /bluesanta/apps/apache24_php5/modules/libphp5.so

/bluesanta/apps/apache24_php5/conf/httpd.conf 내용 추가

bluesanta@Kubuntu:~/php-5.6.40$ vi /bluesanta/apps/apache24_php5/conf/httpd.conf

#Listen 12.34.56.78:80
Listen 5050

# php 
LoadModule php5_module        modules/libphp5.so
PHPIniDir "/bluesanta/apps/php-5.6.40"

... 생략 ...

    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
    AddHandler application/x-httpd-php .php4 .php .phtml .ph .inc

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
    AddType application/x-httpd-php .php4 .php .phtml .ph .inc

</IfModule>

서비스 등록 파일 apache2_php5.service 생성

bluesanta@Kubuntu:~$ cd /bluesanta/apps/apache24_php5/bin/
bluesanta@Kubuntu:/bluesanta/apps/apache24_php5/bin$ vi apache2_php5.service

apache2_php5.service 내용

[Unit]
Description=The Apache HTTP Server(PHP5)
After=network.target remote-fs.target nss-lookup.target
Documentation=https://httpd.apache.org/docs/2.4/

[Service]
Type=forking
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/bluesanta/apps/apache24_php5/bin/apachectl start
ExecStop=/bluesanta/apps/apache24_php5/bin/apachectl stop
ExecReload=/bluesanta/apps/apache24_php5/bin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

apache2_php5.service 파일 /etc/systemd/system 디렉토리에 복사

bluesanta@Kubuntu:/bluesanta/apps/apache24_php5/bin$ chmod +x apache2_php5.service
bluesanta@Kubuntu:/bluesanta/apps/apache24_php5/bin$ sudo cp apache2_php5.service /etc/systemd/system

Apache 서비스 등록

bluesanta@Kubuntu:/bluesanta/apps/apache24_php5/bin$ sudo systemctl enable apache2_php5
Created symlink /etc/systemd/system/multi-user.target.wants/apache2_php5.service → /etc/systemd/system/apache2_php5.service.

Apache 서비스 실행

pi@Kubuntu:/bluesanta/apps/apache24/bin$ sudo systemctl start apache2_php5

Apache 서비스 상태 확인

bluesanta@Kubuntu:/bluesanta/apps/apache24_php5/bin$ sudo systemctl status apache2_php5
● apache2_php5.service - The Apache HTTP Server(PHP5)
     Loaded: loaded (/etc/systemd/system/apache2_php5.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2020-11-26 01:05:49 KST; 13s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 4178335 ExecStart=/bluesanta/apps/apache24_php5/bin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 4178350 ExecStop=/bluesanta/apps/apache24_php5/bin/apachectl stop (code=exited, status=0/SUCCESS)
 
11월 26 01:05:48 Kubuntu systemd[1]: Starting The Apache HTTP Server(PHP5)...
11월 26 01:05:49 Kubuntu apachectl[4178337]: httpd (pid 1179212) already running
11월 26 01:05:49 Kubuntu systemd[1]: apache2_php5.service: Succeeded.
11월 26 01:05:49 Kubuntu systemd[1]: Started The Apache HTTP Server(PHP5).
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함