본문 바로가기
SW/APM

Centos7 APM 소스 설치 (mysql 5.1.73, Apache 2.4.6, PHP 5.4.16)

by bigju 2024. 7. 4.

기본 라이브러리 설치

yum install -y wget gcc gcc-c++ make cmake
yum install -y ca-certificates
yum install libtool-ltdl-devel -y
yum install libjpeg* libpng* freetype* gd-* gcc gcc-c++ gdbm-devel libtermcap-devel -y

 

APM 파일 다운로드

cd /usr/local/src

wget https://sourceforge.net/projects/pcre/files/pcre/8.36/pcre-8.36.tar.gz/download //httpd 관련 파일
wget https://dlcdn.apache.org/httpd/httpd-2.4.61.tar.gz //httpd 관련 파일
wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz      //httpd 관련 파일
wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz  //httpd 관련 파일
wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz  //MariaDB
wget https://museum.php.net/php5/php-5.4.16.tar.gz


===========================
http://apache.tt.co.kr//httpd/httpd-2.4.46.tar.gz  // httpd 다른 버전

Apache-pcre 설치

cd /usr/local/src

tar xvfz download 

cd pcre-8.36

echo "check_certificate = off" >> ~/.wgetrc

./configure \
--prefix=/usr/local

make && make install

 

Apache-apr 설치

tar xfvz apr-1.6.5.tar.gz 
tar xvfz apr-util-1.6.3.tar.gz

mv apr-1.6.5 httpd-2.4.59/srclib/apr
mv apr-util-1.6.3 httpd-2.4.59/srclib/apr-util

 

Apache 설치

cd httpd-2.4.59

./configure \
--prefix=/usr/local/apache \
--with-included-apr \
--with-pcre=/usr/local/bin/pcre-config


( 오류 문제 spr) --> yum install -y expat-devel --> make clean
yum install libtool-ltdl-devel

make &&  make install

 

Apache 설정 및 시작

cd /usr/local/apache/conf

vi httpd.conf

( ServerName을 검색해서 아래와 같이 수정 ( line : 192 ) )

ServerName 127.0.0.1:80

/usr/local/apache/bin/apachectl restart

MYSQL 설치

cd /usr/local/src

tar xfz mysql-5.1.73.tar.gz

cd mysql-5.1.73.tar.gz

./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-mysqld-user=mysql \
--with-charset=utf8 \
--sysconfdir=/etc \
--with-extra-charsets=all \
--enable-shared \
--with-plugins=max,max-no-ndb,mandatory \
--enable-thread-safe-client \
--enable-assembler \
--with-tcp-port=3306 \
--with-readline \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--without-debug \
--with-plugins=innobase \
--enable-local-infile \
--enable-profiling \
--enable-local-infile \
--enable-largefile \
--with-big-tables \
--with-pic \
--with-libwrap \
--with-comment \
--with-gnu-ld \
--with-pthread \
--with-unix-socket-path=/tmp/mysql.sock

make && make install

 

MYSQL 설정

groupadd -g 400 mysql
useradd -u400 -g400 -d /usr/local/mysql -s /bin/false mysql

 

MYSQL 유저 설정

useradd -u400 -g400 -d /usr/local/mysql -s /bin/false mysql
groupadd -g 400 mysql

 

MYSQL 설정 파일 생성 및 시작 스크립트 생성

mv -f /etc/my.cnf /etc/my.cnf_source_before
cp -arpf ./support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
cp -arpf ./support-files/mysql.server /etc/init.d/mysqld
sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
sed -i 's/#external-locking/skip-external-locking/g' /etc/my.cnf

 

MYSQL 기본 엔진 변경

vi /etc/my.cof

# default-storage-engine = MYISAM
-> 주석처리

default-storage-engine = InnoDB
-> 추가

 

MYSQL DB 디렉토리 생성 및 퍼미션 소유 설정

mkdir -p /usr/local/mysql/logs
chown -R mysql:mysql /usr/local/mysql
chmod 700 /etc/init.d/mysqld
chmod 711 /usr/local/mysql
chmod 751 /usr/local/mysql/bin
chmod 750 /usr/local/mysql/bin/*
chmod 755 /usr/local/mysql/bin/mysql
chmod 755 /usr/local/mysql/bin/mysqldump
ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib64

 

MYSQL DB 초기화

/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 

MYSQL 비밀번호 설정

/etc/init.d/mysqld restart
/usr/local/mysql/bin/mysqladmin -u root password "설정할 비밀번호"

 

MYSQL logrotate 설정

mkdir /root/bin
\cp -arpf ./support-files/mysql-log-rotate /root/bin/
echo " " >> /etc/crontab
echo "0 0 * * * root /usr/sbin/logrotate -f /root/bin/mysql-log-rotate" >> /etc/crontab

 

MySQL 환경변수 설정

아래 설정은 Apache, MySQL, PHP 부분이 모두 포함되어있습니다.
echo " " >> /etc/profile
echo "APACHE_HOME=/usr/local/apache" >> /etc/profile
echo "MySQL_HOME=/usr/local/mysql" >> /etc/profile
echo "PHP_HOME=/usr/local/php" >> /etc/profile
echo " " >> /etc/profile
echo "export PATH="\$"APACHE_HOME/bin:"\$"MySQL_HOME/bin:"\$"PHP_HOME/bin:"\$"PHP_HOME/sbin"\$"{PATH:+:"\$"{PATH}}" >> /etc/profile
source /etc/profile

만약 DB만 운영하실것이라면 위의 명령어가 아닌 아래 명령어를 입력해주세요.
echo " " >> /etc/profile
echo "MySQL_HOME=/usr/local/mysql" >> /etc/profile
echo "export PATH="\$"MySQL_HOME/bin:"\$"{PATH:+:"\$"{PATH}}" >> /etc/profile
echo " " >> /etc/profile
source /etc/profile

PHP

 

라이브러리 설치

yum -y install libxml2-devel -y
yum -y install openssl-devel -y
yum -y install libjpeg-devel -y
yum -y install libpng-devel -y

 

PHP 설치

wet http://am1.php.net/get/php-5.4.1.tar.gz/from/this/mirror

tar xvfz mirror

cd php-5.6.4

./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-imap-ssl \
--disable-debug \
--with-iconv \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-libxml-dir \
--with-resin \
--with-openssl

--with-curl)  

오류 해결 !  sorry i cannot run apxs --> # vi /usr/local/victolee/apache2.4.33/bin/apxs 
--> 첫줄 #!/replace/with/path/to/perl/interpreter -w     
수정 =>	#! /usr/bin/perl -w

make
make test
make install

 

PHP 설치 확인

php --version

ls -al /usr/local/apache/modules/libphp5.so

Apache - PHP 연동

vi /usr/local/apache/conf/httpd.conf

( php를 검색하여 LoadModule에 php가 추가됐는지 확인 ( line : 151 ) )
LoadModule php5_module        modules/libphp5.so

( MIME를 추가 ( line : 388 ) )
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .html

========================================================================================

vi  /usr/local/src/php-5.6.4/php.ini-production

( short_open를 검색해서 On으로 수정합니다. )
short_open_tag = On

( opcache.enable을 검색해서 0으로 수정합니다. )
opcache.enable=0

# cp /usr/local/src/php-5.4.16/php.ini-production /usr/local/lib.php.in
--> 옮기는 이유  잘 관리하기위해 쉽게

==============================================================

파일 작성

# cd /usr/local/apache/htdocs/
# vi phpinfo.php
<?
	phpinfo();
?>

================================================================

시작
# /usr/local/apache/bin/apachectl restart
# ps -ef | grep httpd

댓글

메인으로가기


    

Big Ju

IT Engineer


항상 답을 위해 노력하는

엔지니어입니다.

 

 

    


 UP!