본문 바로가기

리눅스

CentOS 4에서 APM (Apache, PHP, MySQL, Zend)를 컴파일하여 설치하는 방법

반응형

CentOS 4에서 APM (Apache, PHP, MySQL, Zend)를 컴파일하여 설치하는 방법

1. 필수 라이브러리 설치

APM를 컴파일하기 위해 필요한 패키지들을 설치합니다.

sudo yum install gcc gcc-c++ make wget
sudo yum install -y zlib-devel gd-devel libpng-devel libjpeg-devel freetype-devel fontconfig-devel libxml2-devel openssl-devel gmp-devel mhash-devel libmcrypt-devel libcurl-devel
cd /usr/local/src

2. MySQL 설치

yum install -y termcap libtool libtermcap-devel ncurses-devel
yum install -y libtool-ltdl
autoreconf --force --install
$ autoreconf --force --install
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
client/Makefile.am: installing `./compile'
aclocal
libtoolize --automake --force
automake --force --add-missing
$ automake --force --add-missing
...
config.status: executing default commands

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.

MySQL을 컴파일하고 설치합니다.

useradd -m -c "MySQL Server" -d /usr/local/mysql -s /bin/false -u 27 mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.52.tar.gz
tar zxvf mysql-5.6.52.tar.gz
cd mysql-5.6.52
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-charset=euckr --with-extra-charsets=all
make
make install
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db
cd /usr/local/mysql
chown mysql.mysql data -R
$ ls -al
drwx------  4 mysql mysql 4096  8월  4 02:00 data
/usr/local/mysql/bin/mysqld_safe &
$ /usr/local/mysql/bin/mysqld_safe &
[1] 15654
100804 02:02:46 mysqld_safe Logging to '/usr/local/mysql/data/byungun.err'.
100804 02:02:46 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
$ ps -ef | grep mysql
root     15654  2470  0 02:02 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
mysql    15753 15654  0 02:02 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/data/byungun.err --pid-file=/usr/local/mysql/data/byungun.pid --socket=/tmp/mysql.sock --port=3306
ln -s /usr/local/mysql/bin/mysql /usr/bin/
/usr/local/mysql/bin/mysqladmin -u root password "비밀번호"
mysql -u root -p mysql
$ mysql -u root -p mysql
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.49-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
728x90

3. Apache 설치

Apache 웹 서버를 컴파일하고 설치합니다.

useradd -c "Apache" -u 48 -s /sbin/nologin apache
wget https://archive.apache.org/dist/httpd/httpd-2.2.34.tar.gz
tar zxvf httpd-2.2.34.tar.gz
cd httpd-2.2.34
vi server/mpm/prefork/prefork.c
vi server/mpm/worker/worker.c
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl --enable-proxy --enable-modules=all
make
sudo make install
/usr/local/apache2/bin/apachectl start
$ /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 210.103.175.41 for ServerName
$ ps -ef | grep httpd
root     18403     1  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   18404 18403  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   18405 18403  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   18406 18403  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   18407 18403  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   18408 18403  0 02:23 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
root     18412  2470  0 02:23 pts/0    00:00:00 grep httpd
/usr/local/apache2/bin/apachectl -l
$ /usr/local/apache2/bin/apachectl -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_dbm.c
  mod_authn_anon.c
  mod_authn_dbd.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_dbm.c
  mod_authz_owner.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_auth_digest.c
  mod_dbd.c
  mod_dumpio.c
  mod_ext_filter.c
  mod_include.c
  mod_filter.c
  mod_substitute.c
  mod_deflate.c
  mod_log_config.c
  mod_log_forensic.c
  mod_logio.c
  mod_env.c
  mod_mime_magic.c
  mod_cern_meta.c
  mod_expires.c
  mod_headers.c
  mod_ident.c
  mod_usertrack.c
  mod_unique_id.c
  mod_setenvif.c
  mod_version.c
  mod_proxy.c
  mod_proxy_connect.c
  mod_proxy_ftp.c
  mod_proxy_http.c
  mod_proxy_ajp.c
  mod_proxy_balancer.c
  mod_ssl.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_dav.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_info.c
  mod_cgi.c
  mod_dav_fs.c
  mod_vhost_alias.c
  mod_negotiation.c
  mod_dir.c
  mod_imagemap.c
  mod_actions.c
  mod_speling.c
  mod_userdir.c
  mod_alias.c
  mod_rewrite.c
  mod_so.c
$ ls /usr/local/apache2/modules/
httpd.exp

4. PHP 설치

yum -y install curl-devel gdbm-devel libtool-ltdl-devel

PHP를 컴파일하고 설치합니다.

wget https://www.php.net/distributions/php-5.6.40.tar.gz
tar zxvf php-5.6.40.tar.gz
cd php-5.6.40
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-sysvshm=yes --enable-sysvsem=yes --enable-debug=no --with-ttf --with-png-dir=/usr --with-zlib-dir --with-jpeg-dir=/usr --with-gdbm=/usr --enable-ftp --enable-mbstring --enable-sockets --enable-wddx --with-freetype-dir=/usr --enable-bcmath --with-curl --with-mcrypt --enable-mbregex --enable-exif --with-gd --enable-gd-native-ttf --enable-calendar --with-openssl --with-libxml-dir
make
sudo make install
cp /usr/local/src/php-5.2.8/php.ini-dist /usr/local/php/lib/php.ini
$ ls -al /usr/local/php/lib/php.ini
-rw-r--r-- 1 root root 45106  8월  4 09:06 /usr/local/php/lib/php.ini

Apache의 설정 파일(httpd.conf)에 PHP 모듈 추가합니다.

vim httpd.conf
### 자동으로 생성됨
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module        modules/libphp5.so
#

### 추가
AddType application/x-httpd-php .ph .php .php3 .inc .asp .html
AddType application/x-httpd-php-source .phps

# AddHandler allows you to map certain file extensions to "handlers":


<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>

5. Zend 설치

sh install.sh

/usr/local/php/lib/ 입력

6. 경로 설정

컴파일된 PHP와 Apache를 사용하도록 환경 변수를 설정합니다.

export PATH=/usr/local/php/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/php/lib:$LD_LIBRARY_PATH

7. 서비스 시작

Apache와 MySQL을 시작합니다.

sudo /usr/local/apache2/bin/apachectl start
sudo /usr/local/mysql/support-files/mysql.server start

8. 설치 패키지 버전 확인

$ /usr/local/mysql/bin/mysqladmin --version
/usr/local/mysql/bin/mysqladmin  Ver 8.42 Distrib 5.1.49, for pc-linux-gnu on i686
$ /usr/local/apache2/bin/apachectl -v
Server version: Apache/2.2.11 (Unix)
Server built:   Aug  4 2010 02:22:04
$ /usr/local/php/bin/php -v
PHP 5.2.8 (cli) (built: Aug  4 2010 09:04:17)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

 

728x90
반응형