728x90

출처

필수 라이브러리 설치

bluesanta@bluesanta-desktop:~$ sudo apt install libexpat1-dev libssl-dev

PCRE 설치

bluesanta@bluesanta-desktop:~$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
bluesanta@bluesanta-desktop:~$ tar xvf pcre-8.44.tar.gz 
bluesanta@bluesanta-desktop:~$ cd pcre-8.44/
bluesanta@bluesanta-desktop:~/pcre-8.44$ ./configure --prefix=/usr/local/pcre-8.44
bluesanta@bluesanta-desktop:~/pcre-8.44$ make
bluesanta@bluesanta-desktop:~/pcre-8.44$ sudo make install

Apache 웹서버 설치

bluesanta@bluesanta-desktop:~$ wget https://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
bluesanta@bluesanta-desktop:~$ tar xvf httpd-2.4.39.tar.gz 
bluesanta@bluesanta-desktop:~$ cd httpd-2.4.39/
bluesanta@bluesanta-desktop:~/httpd-2.4.39$ cd srclib
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ tar xvfz apr-1.7.0.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ mv apr-1.7.0 apr
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ tar xvfz apr-util-1.6.1.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ mv apr-util-1.6.1 apr-util
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ tar xvfz pcre-8.44.tar.gz
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ mv pcre-8.44 pcre
bluesanta@bluesanta-desktop:~/httpd-2.4.39/srclib$ cd ..
bluesanta@bluesanta-desktop:~/httpd-2.4.39$ ./configure --prefix=/opt/apache24 --with-pcre=/usr/local/pcre-8.44 --enable-cgi --enable-info --enable-deflate --enable-ssl --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-expires --enable-headers --enable-rewrite --enable-so --with-included-apr --with-included-apr-util --with-included-pcre
bluesanta@bluesanta-desktop:~/httpd-2.4.39$ make
bluesanta@bluesanta-desktop:~/httpd-2.4.39$ make install

mod_jk 설치

bluesanta@bluesanta-desktop:~$ wget https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.46-src.tar.gz
bluesanta@bluesanta-desktop:~$ tar xvf tomcat-connectors-1.2.46-src.tar.gz
bluesanta@bluesanta-desktop:~$ cd tomcat-connectors-1.2.46-src/native/
bluesanta@bluesanta-desktop:~$ ./configure --with-apxs=/opt/apache24//bin/apxs
bluesanta@bluesanta-desktop:~/tomcat-connectors-1.2.46-src/native$ make
bluesanta@bluesanta-desktop:~/tomcat-connectors-1.2.46-src/native$ make install

로드밸런싱 설정

bluesanta@bluesanta-desktop:~$ cd /opt/apache24/conf/
bluesanta@bluesanta-desktop:/opt/apache24/conf$ vi workers.properties

workers.properties

worker.list=load_balancer

worker.load_balancer.type=lb
worker.load_balancer.balance_workers=tomcat1,tomcat2
#worker.load_balancer.balance_workers=tomcat2

# tomcat/conf/server.xml - ajp 포트
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1

# tomcat/conf/server.xml - ajp 포트
worker.tomcat2.port=7009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

httpd.conf

bluesanta@bluesanta-desktop:/opt/apache24/conf$ vi httpd.conf

LoadModule jk_module modules/mod_jk.so

... 생략 ...

<IfModule jk_module>
    JkWorkersFile    conf/workers.properties
    JkLogFile        logs/mod_jk.log
    JkLogLevel       info
    JkMount /* 	load_balancer
</IfModule>

Apache 웹서버 환경 설정

bluesanta@bluesanta-desktop:~$ cd /opt/apache24/conf/
bluesanta@bluesanta-desktop:/opt/apache24/conf$ vi httpd.conf

ServerName 주석을 풀고 localhost로 설정

#ServerName www.example.com:80
ServerName localhost

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

bluesanta@bluesanta-desktop:/opt/apache24/conf$ cd /opt/apache24/bin/
bluesanta@bluesanta-desktop:/opt/apache24/bin$ vi apache2.service

apache2.service 내용

[Unit]
Description=The Apache HTTP Server
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=/opt/apache24/bin/apachectl start
ExecStop=/opt/apache24/bin/apachectl stop
ExecReload=/opt/apache24/bin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

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

bluesanta@bluesanta-desktop:/opt/apache24/bin$ sudo chmod +x apache2.service
bluesanta@bluesanta-desktop:/opt/apache24/bin$ sudo cp apache2.service /etc/systemd/system

Apache 서비스 등록

bluesanta@bluesanta-desktop:/opt/apache24/bin$ sudo systemctl enable apache2
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /etc/systemd/system/apache2.service.

Apache 서비스 실행

bluesanta@bluesanta-desktop:/opt/apache24/bin$ sudo systemctl start apache2

Apache 서비스 상태 확인

bluesanta@bluesanta-desktop:/opt/apache24/bin$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/etc/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-04-10 14:22:21 KST; 57s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 284736 (httpd)
      Tasks: 82 (limit: 18898)
     Memory: 7.2M
     CGroup: /system.slice/apache2.service
             ├─284736 /opt/apache24/bin/httpd -k start
             ├─284737 /opt/apache24/bin/httpd -k start
             ├─284738 /opt/apache24/bin/httpd -k start
             └─284739 /opt/apache24/bin/httpd -k start
 
 4월 10 14:22:21 bluesanta-desktop systemd[1]: Starting The Apache HTTP Server...
 4월 10 14:22:21 bluesanta-desktop systemd[1]: Started The Apache HTTP Server.
728x90
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).
728x90
728x90

출처

필수 라이브러리 설치

$ sudo apt install libexpat1-dev

PCRE 설치

pi@Kubuntu:/bluesanta/apps$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
pi@Kubuntu:/bluesanta/apps$ tar xvfz pcre-8.44.tar.gz
pi@Kubuntu:/bluesanta/apps$ cd pcre-8.44/
pi@Kubuntu:/bluesanta/apps/pcre-8.44$ ./configure --prefix=/usr/local/pcre-8.44
pi@Kubuntu:/bluesanta/apps/pcre-8.44$ make
pi@Kubuntu:/bluesanta/apps/pcre-8.44$ sudo make install

Apache 웹서버 컴파일 & 설치

pi@Kubuntu:~$ cd /bluesanta/apps
pi@Kubuntu:/bluesanta/apps$ wget https://downloads.apache.org//httpd/httpd-2.4.46.tar.gz
pi@Kubuntu:/bluesanta/apps$ tar xvfz httpd-2.4.46.tar.gz
pi@Kubuntu:/bluesanta/apps$ cd httpd-2.4.46/
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46$ cd srclib
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ tar xvfz apr-1.7.0.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ mv apr-1.7.0 apr
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ tar xvfz apr-util-1.6.1.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ mv apr-util-1.6.1 apr-util
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ tar xvfz pcre-8.44.tar.gz
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46/srclib$ mv pcre-8.44 pcre
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46$ cd ..
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46$ ./configure --prefix=/bluesanta/apps/apache24 --with-pcre=/usr/local/pcre-8.44 --enable-cgi --enable-info --enable-deflate --enable-ssl --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-expires --enable-headers --enable-rewrite --enable-so --with-included-apr --with-included-apr-util --with-included-pcre
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46$ make
pi@Kubuntu:/bluesanta/apps/httpd-2.4.46$ make install

Apache 웹서버 환경 설정

pi@Kubuntu:/bluesanta/apps/apache24$ cd conf
pi@Kubuntu:/bluesanta/apps/apache24/conf$ vi httpd.conf

ServerName 주석을 풀고 localhost로 설정

#ServerName www.example.com:80
ServerName localhost

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

pi@Kubuntu:~$ cd /bluesanta/apps/apache24/bin/
pi@Kubuntu:/bluesanta/apps/apache24/bin$ vi apache2.service

apache2.service 내용

[Unit]
Description=The Apache HTTP Server
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/bin/apachectl start
ExecStop=/bluesanta/apps/apache24/bin/apachectl stop
ExecReload=/bluesanta/apps/apache24/bin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

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

pi@Kubuntu:/bluesanta/apps/apache24/bin$ chmod +x apache2.service
pi@Kubuntu:/bluesanta/apps$ sudo cp apache2.service /etc/systemd/system

Apache 서비스 등록

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

Apache 서비스 실행

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

Apache 서비스 상태 확인

$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/etc/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-11-19 00:06:39 KST; 3s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 154499 ExecStart=/bluesanta/apps/apache24/bin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 154519 (httpd)
      Tasks: 82 (limit: 18693)
     Memory: 6.9M
     CGroup: /system.slice/apache2.service
             ├─154519 /bluesanta/apps/apache24/bin/httpd -k start
             ├─154520 /bluesanta/apps/apache24/bin/httpd -k start
             ├─154521 /bluesanta/apps/apache24/bin/httpd -k start
             └─154522 /bluesanta/apps/apache24/bin/httpd -k start
 
11월 19 00:06:39 Kubuntu systemd[1]: Starting The Apache HTTP Server...
11월 19 00:06:39 Kubuntu systemd[1]: Started The Apache HTTP Server.



Apache 웹서버 컴파일 참조 라이브러리 설치

srclib 디렉토리 사용전에 사용했던 것으로 불필요 - 나중에 참고용으로 남겨둠

apr 라이브러리 설치

pi@Kubuntu:/bluesanta/apps$ wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
pi@Kubuntu:/bluesanta/apps$ tar xvfz apr-1.7.0.tar.gz
pi@Kubuntu:/bluesanta/apps$ cd apr-1.7.0/
pi@Kubuntu:/bluesanta/apps/apr-1.7.0$ ./configure
pi@Kubuntu:/bluesanta/apps/apr-1.7.0$ make
pi@Kubuntu:/bluesanta/apps/apr-1.7.0$ sudo make install
 
... 생략 ...
 
----------------------------------------------------------------------
/usr/bin/install -c -m 644 apr.exp /usr/local/apr/lib/apr.exp
/usr/bin/install -c -m 644 apr.pc /usr/local/apr/lib/pkgconfig/apr-1.pc
for f in libtool shlibtool; do \
    if test -f ${f}; then /usr/bin/install -c -m 755 ${f} /usr/local/apr/build-1; fi; \
done
/usr/bin/install -c -m 755 /bluesanta/apps/apr-1.7.0/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
    /usr/bin/install -c -m 644 /bluesanta/apps/apr-1.7.0/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config

apr-util 라이브러리 설치

pi@Kubuntu:/bluesanta/apps$ wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
pi@Kubuntu:/bluesanta/apps$ tar xvfz apr-util-1.6.1.tar.gz
pi@Kubuntu:/bluesanta/apps$ cd apr-util-1.6.1/
pi@Kubuntu:/bluesanta/apps/apr-util-1.6.1$ ./configure -with-apr=/usr/local/apr
pi@Kubuntu:/bluesanta/apps/apr-util-1.6.1$ make
pi@Kubuntu:/bluesanta/apps/apr-util-1.6.1$ sudo make install
 
... 생략 ...
 
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config
728x90
728x90

출처

1. 다운로드

phpMyAdmin에서 phpMyAdmin-5.0.4-all-languages.zip 파일 다운로드

2. 압축풀기

phpMyAdmin-5.0.4-all-languages.zip 압축파일을 C:\usr\local\phpMyAdmin-5.0.4-all-languages 폴더에 압축 해제

3. config.inc.php 파일 생성

C:\usr\local\phpMyAdmin-5.0.4-all-languages\config.sample.inc.php 파일을 config.inc.php로 복사

4. 환경파일 수정(config.inc.php)

/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = 'gNsWq$%#%$#%EDFSsffsegbVp6LCJw6w'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/**
 * Servers configuration
 */
$i = 0;

/**
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
// $cfg['Servers'][$i]['user'] = 'root';

5. httpd.conf 가상폴더 추가

Tomcat 연동이 없는 경우

Alias /mysql "C:/usr/local/phpMyAdmin-5.0.4-all-languages"

<Directory "C:/usr/local/phpMyAdmin-5.0.4-all-languages">
    Options FollowSymLinks
    DirectoryIndex index.html index.htm index.php *.jsp *.php
    Order allow,deny
    Allow from all
</Directory>

Tomcat 연동의 경우

# Tomcat 연동
<IfModule jk_module>
    JkWorkersFile    conf/workers.properties
    JkLogFile        logs/mod_jk.log
    JkLogLevel       info
    JkMount /* 	load_balancer
</IfModule>

AddDefaultCharset Off 

# phpMyAdmin
<VirtualHost *:80>
    ServerAdmin admin@phpmyadmin.abc.kr
    DocumentRoot "C:/usr/local/phpMyAdmin-5.0.4-all-languages"
    ServerName localhost
#    ServerAlias /mysql
#    DirectoryIndex index.php
    Alias /mysql "C:/usr/local/phpMyAdmin-5.0.4-all-languages"

    <Directory "C:/usr/local/phpMyAdmin-5.0.4-all-languages">
        AllowOverride ALL
        Options FollowSymLinks MultiViews
        DirectoryIndex index.html index.htm index.php *.jsp *.php
        Require all granted
    </Directory>
    
</VirtualHost>

6. php.ini 수정

; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
extension=php_mysqli.dll
;extension=mbstring
extension=php_mbstring.dll
;extension=pdo_mysql
extension=php_pdo_mysql.dll
728x90
728x90

출처

RSA 개인키를 생성

$ openssl genrsa -out private.key 2048
Generating RSA private key, 2048 bit long modulus
....................................+++++
..........+++++
e is 65537 (0x10001)

RSA 개인키를 이용해서 RSA 공개키를 생성

$ openssl rsa -in private.key -pubout -out public.key
writing RSA key

CSR(인증요청서) 생성

$ openssl req -new -key private.key -out private.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:_
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:bluexmas
Organizational Unit Name (eg, section) []:root CA
Common Name (e.g. server FQDN or YOUR name) []:test.iptime.org
Email Address []:test@test.com
 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:test
An optional company name []:test

CRT(인증서)만들기

CA 역할을 할 CA 대칭키 생성

$ openssl genrsa -aes256 -out rootCA.key 2048
Generating RSA private key, 2048 bit long modulus
..................................................+++++
....................+++++
e is 65537 (0x10001)
Enter pass phrase for rootCA.key:test
Verifying - Enter pass phrase for rootCA.key:test

rootCA.key를 이용해서 rootCA.pem 생성

$ openssl req -x509 -new -nodes -key rootCA.key -days 2650 -out rootCA.pem
Enter pass phrase for rootCA.key:test
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:_
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:bluexmas
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:test
Email Address []:test

웹서버에 HTTPS적용을 위해 필요한 CRT 인증서를 생성

$ openssl x509 -req -in private.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out private.crt -days 3650
Signature ok
subject=/C=KR/ST=_/L=Seoul/O=bluexmas/OU=root CA/CN=lastxmas.iptime.org/emailAddress=test@test.com
Getting CA Private Key
Enter pass phrase for rootCA.key:test

C:\usr\local\Apache24\conf\httpd.conf

# Secure (SSL/TLS) connections
Include conf/httpd-ssl.conf

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so

C:\usr\local\Apache24\conf\httpd-ssl.conf

#
# When we also provide SSL we have to listen to the 
# standard HTTP port (see above) and to the HTTPS port
#
Listen 443

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is an internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog  builtin

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
#SSLSessionCache         "dbm:c:/Apache24/logs/ssl_scache"
SSLSessionCache        "shmcb:C:/usr/local/Apache24/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

##
## SSL Virtual Host Context
##

<virtualhost _default_:443="">

#   General setup for the virtual host
# DocumentRoot "C:/usr/local/Apache24/htdocs"
DocumentRoot "C:/usr/local/Apache24/public_html"
ServerName www.example.com:443
ServerAdmin admin@example.com
ErrorLog "C:/usr/local/Apache24/logs/error.log"
TransferLog "C:/usr/local/Apache24/logs/access.log"

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
#   pass phrase.  Note that a kill -HUP will prompt again.  Keep
#   in mind that if you have both an RSA and a DSA certificate you
#   can configure both in parallel (to also allow the use of DSA
#   ciphers, etc.)
#   Some ECC cipher suites (http://www.ietf.org/rfc/rfc4492.txt)
#   require an ECC certificate which can also be configured in
#   parallel.
SSLCertificateFile "C:/usr/local/Apache24/conf/private.crt"

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
#   ECC keys, when in use, can also be configured in parallel
SSLCertificateKeyFile "C:/usr/local/Apache24/conf/private.key"
728x90
728x90

출처 : Mysql_fetch_row 와 Mysql_fetch_array 차이

나누기 몫, 나머지

$num = floor(10 / 3); // 소수점 이하는 버리고 몫만 = 3
$num_1 = 10 % 3; // 나머지 = 1

echo "num = $num / num_1 = $num_1";

mysql_fetch_array : 필드이름으로 데이터 조회

<? 
$connect = mysql_connect('localhost', 'user id', 'password'); 
mysql_select_db("dbname", $connect); 

$query = "select userid, name, tel from user"; 
$result = mysql_query($query, $connect); 
$row = mysql_fetch_array($result); 

echo "$row[userid], $row[name], $row[tel]"; 
?>

DBarray : 함수로 제작

// mysql_fetch_array function
function DBarray($qry) {
	$result = @mysql_query($qry, $connect) or die("Qry Err. : $qry");
	if (mysql_num_rows($result)) { 
	 return mysql_fetch_array($result);
	} else {
	 return 0;
	}
}

PHP Inline IF

$page_max = floor($recode_count / $page_count) + ( ($recode_count % $page_count) > 0 ? 1 : 2);
$current_page = ($page == NULL ? 1 : $page);

Database 레코드 개수 만큼 조회

$result_row = DBquery("select * from gcm_table");

while($row = mysql_fetch_array($result_row)) {
	$data = $row['userid'];
    echo $data."<br />";
}

PHP - DB조회 레코드 개수 만큼 JSON 배열에 담기

$offset = ($current_page - 1) * $page_count;
$result_row = DBquery("select * from gcm_table limit 15 offset $offset");

$data_array = array();
while($gmc_row = mysql_fetch_array($result_row)) {
	$arr = array(
	  'id' => $gmc_row[id], 
	  'reg_id' => $gmc_row[reg_id], 
	  'phone_num' => $gmc_row[phone_num], 
	  'user_idx' => $gmc_row[user_idx], 
	  'userid' => $gmc_row[userid], 
	  'writeday' => $gmc_row[writeday], 
	  'use' => $gmc_row['use'] 
	);	
	array_push($data_array, $arr);
}
echo json_encode($data_array);
728x90
728x90

Path 추가

C:\server\php-5.2.17-Win32-VC6-x86
C:\server\php-5.2.17-Win32-VC6-x86\ext

C:\server\Apache2.2\conf\httpd.conf 수정


# For PHP 5 do something like this:
LoadModule php5_module "C:/server/php-5.2.17-Win32-VC6-x86/php5apache2_2.dll"

Alias /mysql "C:/server/phpMyAdmin-3.4.6-all-languages"

-- 생략 --
 
<Directory "C:/server/phpMyAdmin-3.4.6-all-languages">
 Options FollowSymLinks
 DirectoryIndex index.html index.htm index.php *.jsp *.php
 Order allow,deny
 Allow from all
</Directory>

-- 생략 --

    AddType application/x-httpd-php .php .php3 .html .htm .phtml
    AddType application/x-httpd-php-source .phps

php.ini 파일 생성

php.ini-recommended 파일 C:\server\Apache2.2\bin 폴더에 복사

C:\server\Apache2.2\bin\php.ini 수정 (주석제거)

extension=php_bz2.dll
extension=php_mcrypt.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_zip.dll

config.inc.php 생성

C:\server\phpMyAdmin-3.4.6-all-languages\config.sample.inc.php 파일 config.inc.php 로 이름 변경

config.inc.php 수정

<?php
/*
 * Generated configuration file
 * Generated by: phpMyAdmin 3.4.6 setup script
 * Date: Tue, 18 Oct 2011 17:43:55 +0900
 */

/* Servers configuration */
$i = 0;

/* Server: cmxdb [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'mysql';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = 3306;
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';

/* End of servers configuration */

$cfg['blowfish_secret'] = '';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

728x90
728x90

출처

서비스 등록

httpd -k install -n "Apache2.2" -f "C:\server\Apache2.2\conf\httpd.conf"

서비스 제거

httpd -k uninstall -n "Apache2.2"

환경파일(httpd.conf) syntax 확인

C:\server\Apache2.2\bin>httpd -n "Apache2.2" -t
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.123.104 for ServerName
Syntax OK

서비스 실행

httpd -n "Apache2.2" -k start
또는
net start "Apache2.2"

서비스 종료

httpd -n "Apache2.2" -k shutdown
또는
net stop "Apache2.2"
728x90

+ Recent posts