우분투에 APM 설치하기

log·2021년 10월 2일
0

APM = Apache + PHP + MySQL

Apache

아파치 의존성 패키치 설치

$ apt-get install gcc
$ apt-get install g++
$ apt-get install --reinstall make
$ apt-get install libexpat1-dev
$ apt-get install libexpat-dev
$ apt-get install curl
$ apt-get install net-tools

소스 설치할 디렉토리 생성

$ sudo su
# cd /usr/loacl
# mkdir apache

apr, apr-util, prce 설치

# wget http://mirror.navercorp.com/apache//apr/apr-1.7.0.tar.gz
# wget http://mirror.navercorp.com/apache//apr/apr-util-1.6.1.tar.gz
# tar xvfz apr-1.7.0.tar.gz
# tar xvfz apr-util-1.6.1.tar.gz

$ cd usr/local/apr-1.7.0
$ ./configure --prefix=/usr/local/apr
$ cp -arp libtool libtoolT
$ make
$ make install

$ cd usr/local/apr-util-1.6.1
$ ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util 
$ make
$ make install

$ cd usr/local
$ wget ftp://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
$ tar xvfz pcre-8.43.gar.gz
$ cd usr/local/pcre-8.43
$ ./configure --prefix=/usr/local/pcre
$ make
$ make install

아파치 설치

http://httpd.apache.org/download.cgi
위 링크에서 최신 버전 확인 후 다운로드 (2021년 10월 기준 2.4.49)

$ cd /usr/local
$ wget http://apache.tt.co.kr//httpd/httpd-2.4.49.tar.gz
$ tar xvfz httpd-2.4.49.tar.gz

$ cd httpd-2.4.41
$ ./configure --prefix=/usr/local/apache2.4 \
--enable-module=so --enable-rewrite --enable-so \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/loacl/apr-util \
--with-pcre=/usr/local/pcre \
--enable-mods-shared=all
$ make
$ make install

$ sudo /usr/local/apache2.4/bin/httpd -k start
$ ps -ef|grep httpd|grep -v grep
$ sudo netstat -anp|grep httpd
$ sudo curl http://127.0.0.1

끝!

MySQL

MySQL 의존성 패키지 설치

$ apt-get update
$ apt-get install cmake
$ apt-get install libssl-dev
$ apt-get install libboost-all-dev
$ apt-get install libncurses5-dev libncursesw5-dev

MySQL 설치

$ cd /usr/local
$ wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.19.tar.gz
$ tar xvfz mysql-8.0.19.tar.gz

$ cd /usr/local/mysql-8.0.19
$ cmake \
.. \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DSYSCONFDIR=/etc \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/src/boost_1_73_0
$ make
$ make test
$ make install

make 시간 엄청 걸림..

PHP

PHP 의존성 패키지 설치

$ apt-get install libxml2-dev
$ apt-get install libjpeg-dev
$ apt-get install libpng-dev
$ apt-get install libsqlite3-dev

PHP 설치

$ cd /usr/local
$ wget https://www.php.net/distributions/php-7.4.1.tar.gz
$ tar xvfz php-7.4.1.tar.gz

$ cd php-7.4.1
$ ./configure \
--with-apxs2=/usr/local/apache2.4/bin/apxs \
--enable-mysqlnd \
--with-mysql-sock=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-imap-ssl \
--with-iconv \
--enable-gd \
--with-jpeg \
--with-libxml \
--with-openssl

$ make
$ make test
$ make install

Apache-PHP 연동

$ vi /usr/local/apache2.4/conf/httpd.conf

파일 열고 mine_module에 AddType 추가 후 :wq!로 저장 및 나오기

AddType application/x-httpd-php .php .html

php 테스트 파일 생성

$ cd /usr/local/apache2.4/htdocs
$ vi phpinfo.php
<? php
phpinfo();
?>

연동 후 아파치 실행시켜서 확인

$ sudo /usr/local/apache2.4/bin/httpd -k start
$ ps -ef|grep httpd|grep -v grep
$ sudo netstat -anp|grep httpd
$ sudo curl http://127.0.0.1

PHP-MySQL 연동

$ cd usr/local/apche2.4/htdocs
$ vi mysql-test.php
<?php
    $host = 'localhost';
    $user = 'root';
    $pw = 'root';
    $dbName = 'myClass';
    $mysqli = new mysqli($host, $user, $pw, $dbName);
 
    if($mysqli){
        echo "MySQL 접속 성공";
    }else{
        echo "MySQL 접속 실패";
    }
?>


끝!

0개의 댓글