반응형
CentOS7 + Apache2 + PHP5.3 + mysql 5.5 컴파일 설치
CentOS7에 Apache2, php5.3, mysql 5.5 설치하기
========================================================================
yum -y update
#EPEL 저장소 설치
sudo yum install epel-release
#Remi 저장소 추가
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# OS를 최소 설치한 경우
yum -y groupinstall "Base"
yum -y install gcc gcc-c++ make automake autoconf
yum -y groupinstall "Development Tools"
yum -y install gd-devel*
yum -y install libc-client-devel mhash mhash-devel libmcrypt libmcrypt-devel
yum -y install openssl openssl-devel mhash mhash-devel libtool libtool-ltdl libtool-ltdl-devel imap-devel imap zlib-devel zlib freetype-devel freetype libpng-devel libpng libjpeg-devel libjpeg libtiff-devel libtiff gd-devel* gd pcre-devel pcre libxml-devel libxml libxml2-devel libxml2 gdbm-devel gdbm ncurses-devel ncurses curl-devel curl expat-devel expat bzip2-devel bzip2-libs bzip2 uw-imap-devel libc-client libc-client-devel libmcrypt libmcrypt-devel gmp*
yum -y install lrzsz ftp
# 작동중인 프로세스 중지
killall httpd
killall mysqld
# 시간 동기화
/usr/bin/rdate -s time.bora.net && /sbin/clock -w
프로그램 다운로드
cd /usr/local/src
wget http://nix2.ko21.com/src/httpd-2.4.61.tar.gz
wget http://nix2.ko21.com/src/mysql-5.5.62.tar.gz
wget http://nix2.ko21.com/src/php-5.3.29.tar.gz
wget http://nix2.ko21.com/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
wget http://nix2.ko21.com/src/libmcrypt-2.5.8.tar.gz
wget http://nix2.ko21.com/src/libpng-1.2.5.tar.gz
압축풀기
tar zxvf libpng*
tar zxvf /usr/local/src/httpd-2.4.61.tar.gz
tar zxvf /usr/local/src/mysql-5.5.62.tar.gz
tar zxvf php-5.3.29.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
#--------------------------------------------------------------
# libmcrypt-2.5.8 설치
cp -a libmcrypt-2.5.8 /usr/local
cd /usr/local/libmcrypt-2.5.8
./configure --prefix=/usr/local/
make
make check
make install
#--------------------------------------------------------------
cd /usr/local/src/libpng*
cp scripts/makefile.linux makefile
make test
make install
#--------------------------------------------------------------
# mysql 설치
#--------------------------------------------------------------
cd /usr/local/src/mysql-5.5.62
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1
make
make install
# my.cnf 파일
cp -arp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#환경변수설정
export PATH=$PATH:/usr/local/mysql/bin
# 초기 DB생성
/usr/local/mysql/scripts/mysql_install_db -defaults-file=/etc/my.cnf -user=mysql -basedir=/usr/local/mysql/ -datadir=/usr/local/mysql/data/
MySQL 유저와 그룹 생성
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql
sudo chown -R mysql:mysql /usr/local/mysql
# 자동시작 서비스에 추가
------
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
자동시작
chkconfig --add mysqld
chkconfig --level 3 mysqld on
mysql 시작
service mysqld start
ln -s /usr/local/mysql/include/mysql /usr/local/include/mysql
ln -s /usr/local/mysql/lib/mysql /usr/local/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
ln -s /usr/local/mysql/bin/mysqldump /sbin/mysqldump
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
my.cnf
# 기본 설정
user = mysql
port = 3306
socket = /tmp/mysql.sock
pid-file = /usr/local/mysql/data/web1.inner515.co.kr.pid
log-error = /usr/local/mysql/data/web1.inner515.co.kr.err
# 기타 설정
expire_logs_days = 7
# 네트워크 설정
bind-address = 0.0.0.0
max_connections = 1000
# 메모리 설정
key_buffer_size = 256M
max_allowed_packet = 64M
thread_stack = 192K
thread_cache_size = 128
query_cache_limit = 2M
query_cache_size = 64M
table_open_cache = 2048
# InnoDB 설정
default-storage-engine = InnoDB
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_log_buffer_size = 64M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_open_files = 300
innodb_io_capacity = 1000
innodb_flush_method = O_DIRECT
# MyISAM 설정
myisam-recover-options = BACKUP
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
# 추가 설정
tmp_table_size = 64M
max_heap_table_size = 64M
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/data/slow.log
long_query_time = 2
#--------------------------------------------------------------
# apache 설치
#--------------------------------------------------------------
cd /usr/local/src/httpd-2.4.61
cd srclib
wget https://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
tar -xzf apr-1.5.0.tar.gz
tar -xzf apr-util-1.5.3.tar.gz
mv apr-1.5.0 apr
mv apr-util-1.5.3 apr-util
cd ..
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-ssl --with-mpm=prefork
make
make install
yum -y install openssl*
Apache 서비스 스크립트 생성
sudo vi /etc/systemd/system/httpd.service
--------------
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecStop=/usr/local/apache2/bin/apachectl stop
ExecReload=/usr/local/apache2/bin/apachectl graceful
PIDFile=/usr/local/apache2/logs/httpd.pid
PrivateTmp=true
[Install]
WantedBy=multi-user.target
------------------
서비스 등록 및 시작
sudo systemctl daemon-reload
sudo systemctl enable httpd.service
sudo systemctl start httpd.service
4. 상태 확인
sudo systemctl status httpd.service
#--------------------------------------------------------------
# php 설치 5.3.29
#--------------------------------------------------------------
cd /usr/local/src/php-5.3.29
echo "/lib" >> /etc/ld.so.conf
echo "/usr/lib" >> /etc/ld.so.conf
echo "/usr/local/lib" >> /etc/ld.so.conf
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/lib64" >> /etc/ld.so.conf
echo "/usr/lib64" >> /etc/ld.so.conf
echo "/usr/local/lib64" >> /etc/ld.so.conf
ldconfig
ln -s /usr/lib64/libpng.so.3 /usr/lib/libpng.so
ln -s /usr/lib64/libpng12.so.0 /usr/lib/libpng12.so
ln -s /usr/lib64/libxml2.so.2 /usr/lib/libxml2.so
ln -s /usr/lib64/libjpeg.so.62 /usr/lib/libjpeg.so
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
ln -s /lib64/libkrb5.so.3.3 /usr/lib/libkrb5.so
오라클 관련 설치
yum install oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
yum install oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
# PHP 컴파일 설정
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/apache2/conf \
--with-mysql=/usr/local/mysql \
--enable-calendar \
--enable-shmop \
--enable-ftp \
--enable-sockets \
--enable-magic-quotes \
--disable-cgi \
--with-gd \
--with-png-dir=/usr/lib \
--with-zlib-dir \
--with-jpeg-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--with-iconv \
--enable-mbstring \
--with-mcrypt=/usr/local \
--with-openssl \
--enable-bcmath \
--enable-exif \
--with-curl \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap \
--with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib,/usr/include/oracle/11.2/client64
make
make install
sudo cp /usr/local/src/php-5.3.29/php.ini-production /usr/local/apache2/conf/php.ini
echo "<?php" > /usr/local/apache2/htdocs/index.php
echo "echo phpinfo();" >> /usr/local/apache2/htdocs/index.php
echo "?>" >> /usr/local/apache2/htdocs/index.php
cat /usr/local/apache2/conf/php.ini | sed 's\register_globals = Off\register_globals = On\g' > /usr/local/apache2/conf/php_t.ini
mv -f /usr/local/apache2/conf/php_t.ini /usr/local/apache2/conf/php.ini
cat /usr/local/apache2/conf/php.ini | sed 's\magic_quotes_gpc = Off\magic_quotes_gpc = On\g' > /usr/local/apache2/conf/php_t.ini
mv -f /usr/local/apache2/conf/php_t.ini /usr/local/apache2/conf/php.ini
cat /usr/local/apache2/conf/httpd.conf | sed 's\#AddEncoding x-compress .Z\AddType application/x-httpd-php .php .htm .html\g' > /usr/local/apache2/conf/httpd_t.conf
mv -f /usr/local/apache2/conf/httpd_t.conf /usr/local/apache2/conf/httpd.conf
cat /usr/local/apache2/conf/httpd.conf | sed 's\#AddEncoding x-gzip .gz .tgz\AddType application/x-httpd-php-source .phps\g' > /usr/local/apache2/conf/httpd_t.conf
mv -f /usr/local/apache2/conf/httpd_t.conf /usr/local/apache2/conf/httpd.conf
service httpd restart
echo "######### MOD_URL 설치 시작 ###########"
echo "######### MOD_URL 설치 시작 ###########" >> /root/autoscripterr.log
cd /usr/local/src/
wget http://nix2.ko21.com/src/mod_url-apache2-1.8.tar.bz2
tar xvfj mod_url-apache2-1.8.tar.bz2
cd mod_url-apache2
/usr/local/apache2/bin/apxs -aic mod_url.c
echo "<IfModule mod_url.c>" >> /usr/local/apache2/conf/httpd.conf
echo "CheckURL On" >> /usr/local/apache2/conf/httpd.conf
echo "</IfModule>" >> /usr/local/apache2/conf/httpd.conf
echo "######### Zend Optimizer 설치 시작 ###########"
echo "######### Zend Optimizer 설치 시작 ###########" >> /root/autoscripterr.log
아파치가 prefork로 설치 되어야만 zend 설치가 가능합니다
cd /usr/local/src
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib/
cat >> /usr/local/apache2/conf/php.ini << DOCUMENT
[Zend]
zend_extension=/usr/local/php/lib/ZendGuardLoader.so
DOCUMENT
service httpd restart
mkdir /usr/local/lib/php
mkdir /usr/local/lib/php/extensions
echo "######### mysqli 설치 ###########"
cd /usr/local/src/php-5.3.29/ext/mysqli
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config
make
cp ./modules/*.* /usr/local/lib/php/extensions/
echo "######### KCP 모바일신용카드 를 위한 soap 추가 설치 ###########"
cd /usr/local/src/php-5.3.29/ext/soap
/usr/local/php/bin/phpize
./configure --enable-soap --with-php-config=/usr/local/php/bin/php-config
make
cp -arp modules/soap.so /usr/local/lib/php/extensions/
echo "######### openssl 추가 설치 ###########"
cd /usr/local/src/php-5.3.29/ext/openssl
cp config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --enable-openssl --with-php-config=/usr/local/php/bin/php-config
make
cp -arp modules/openssl.so /usr/local/lib/php/extensions/
# /usr/local/apache2/conf/php.ini 파일에서 extension directory의 경로와 모듈명을 추가해준다.
vi /usr/local/apache2/conf/php.ini
;extension_dir = "./"
extension_dir = "/usr/local/lib/php/extensions/"
extension=mysqli.so
extension=soap.so
extension=openssl.so
#http.conf 하단에 추가
<Location /cband-status>
SetHandler cband-status
Order deny,allow
Deny from all
Allow from 59.1.138.
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>
# 가상호스트 설정 예제
<VirtualHost 114.108.141.90:80>
ServerAdmin admin@jidc.net
DocumentRoot /user1/dongheon.or.kr/public_html
ServerName www.dongheon.or.kr
ServerAlias dongheon.or.kr
ServerAlias dongheon.outsvc.com
RMode config
RUidGid [userid] [userid]
CBandLimit 10Gi
CBandPeriod 1D
CBandExceededURL http://yourdomain/traffic_exceeded.html
ErrorLog logs/dongheon.error_log
CustomLog logs/dongheon.access_log common
</VirtualHost>
echo "######### 트래픽 제어 cband 설치 ###########"
cd /usr/local/src/
wget http://nix2.ko21.com/src/mod-cband-0.9.7.5.tgz
tar xvfz mod-cband-0.9.7.5.tgz
cd mod-cband-0.9.7.5
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
make install
# 아파치 재시작
service httpd restart
echo "######### 모든 설치 완료. 수고하셨습니다. ###########"
echo "######### 모든 설치 완료. 수고하셨습니다. ###########" >> /root/autoscripterr.log
#--------------------------------------------------------------
yum -y install vsftpd
service vsftpd restart
#--------------------------------------------------------------
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo yum remove firewalld
sudo yum install iptables-services
sudo systemctl enable iptables
sudo systemctl start iptables
sudo vi /etc/sysconfig/iptables
-----
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A INPUT -p tcp --dport 25 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
-----
sudo systemctl restart iptables
sudo systemctl status iptables
반응형
'Linux' 카테고리의 다른 글
sftp 상위디렉토리 접근 제한하기 (0) | 2024.08.08 |
---|---|
mrtg 트래픽확인 (0) | 2024.07.18 |
ROCKY 8 설치후 초기 세팅 (0) | 2024.07.11 |
rsync 패스워드 없이 접속하기 (1) | 2024.01.26 |
Malware Scanner and Removal (0) | 2023.12.16 |
댓글