Redhat 8 -> CentOS 8 지원종료 (12월 31일) -> Rocky Linux 8

1. httpd 설치
mkdir /usr/local/src/APM_Setup
cd /usr/local/src/APM_Setup/
wget https://archive.apache.org/dist/httpd/httpd-2.4.51.tar.gz
wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
wget http://ftp.exim.org/pub/pcre/pcre-8.45.tar.gz

tar zxvf httpd-2.4.51.tar.gz
tar zxvf apr-1.7.0.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
tar zxvf pcre-8.45.tar.gz


cd /usr/local/src/APM_Setup/apr-1.7.0/
./configure --prefix=/usr/local/apr && make -j4 && make install

cd /usr/local/src/APM_Setup/apr-util-1.6.1/
./configure --with-apr=/usr/local/apr && make -j4 && make install

=============================================================================================
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
 #include <expat.h>
          ^~~~~~~~~
compilation terminated.
make[1]: *** [/usr/local/src/APM_Setup/apr-util-1.6.1/build/rules.mk:206: xml/apr_xml.lo] Error 1
make[1]: Leaving directory '/usr/local/src/APM_Setup/apr-util-1.6.1'
make: *** [/usr/local/src/APM_Setup/apr-util-1.6.1/build/rules.mk:118: all-recursive] Error 1
=============================================================================================
yum -y install expat-devel
=============================================================================================

cd /usr/local/src/APM_Setup/pcre-8.45/
./configure --prefix=/usr/local/pcre && make -j4 && make install

cd /usr/local/src/APM_Setup/httpd-2.4.51/

sed -i "s/#define DEFAULT_SERVER_LIMIT 256/#define DEFAULT_SERVER_LIMIT 2048/g" ./server/mpm/prefork/prefork.c
sed -i "s/#define DEFAULT_SERVER_LIMIT 16/#define DEFAULT_SERVER_LIMIT 256/g" ./server/mpm/worker/worker.c
sed -i "s/#define DEFAULT_SERVER_LIMIT 16/#define DEFAULT_SERVER_LIMIT 256/g" ./server/mpm/event/event.c

./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite\
--enable-ssl \
--enable-expires \
--enable-mods-shared=all \
--enable-modules=shared \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr \
--with-mpm=prefork \
--with-pcre=/usr/local/pcre \
--with-included-apr-util \
--with-mpms-shared=all

make -j4 && make install

cd /usr/local/src/APM_Setup/
wget https://kldp.net/modurl/release/2188-mod_url-apache2-1.25.tar.bz2
tar xvf 2188-mod_url-apache2-1.25.tar.bz2
cd /usr/local/src/APM_Setup/mod_url-apache2-1.25
/usr/local/apache/bin/apxs -iac mod_url.c

echo "" >> /usr/local/apache/conf/httpd.conf
echo "<IfModule mod_url.c>
CheckURL On
</IfModule>" >> /usr/local/apache/conf/httpd.conf
echo "" >> /usr/local/apache/conf/httpd.conf

# Apache 유저,그룹,기본설정
sed -i "s/`grep '^User ' /usr/local/apache/conf/httpd.conf`/User nobody/g" /usr/local/apache/conf/httpd.conf
sed -i "s/`grep '^Group ' /usr/local/apache/conf/httpd.conf`/Group nobody/g" /usr/local/apache/conf/httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName localhost:80/g' /usr/local/apache/conf/httpd.conf

# PHP 연동 설정
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.html index.php index.jsp/g' /usr/local/apache/conf/httpd.conf
# ServerAdmin 설정
sed -i 's/ServerAdmin you@example.com/ServerAdmin root@localhost/g' /usr/local/apache/conf/httpd.conf
# Apahce 로그 설정
sed -i 's/ErrorLog "logs\/error_log"/ErrorLog "logs\/error.log"/g' /usr/local/apache/conf/httpd.conf
sed -i 's/CustomLog "logs\/access_log" common/CustomLog "logs\/access.log" common/g' /usr/local/apache/conf/httpd.conf
# Apache cgi 설정
sed -i 's/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi/g' /usr/local/apache/conf/httpd.conf

# Apache apache2-handler PHP 연동 설정
sed -i '/AddType application\/x-gzip .tgz/a\    #PHP Enable' /usr/local/apache/conf/httpd.conf
sed -i '/AddType application\/x-gzip .tgz/a\    #' /usr/local/apache/conf/httpd.conf
sed -i '/\    #PHP Enable/a \    AddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
sed -i '/\    #PHP Enable/a \    AddType application/x-httpd-php .php .jsp .html' /usr/local/apache/conf/httpd.conf

# 홈소스 위치 디렉토리 허용 설정
echo "<Directory \"/home/*\">
 AllowOverride All
 Options Indexes FollowSymLinks
 Require all granted
</Directory>" >> /usr/local/apache/conf/httpd.conf
echo "" >> /usr/local/apache/conf/httpd.conf

# Apache 실행 파일 설정
\cp -arpf /usr/local/apache/bin/apachectl /etc/init.d/
chmod 700 /etc/init.d/apachectl

sed -i '/#!\/bin\/sh/a # chkconfig: 2345 90 90' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # description: init file for Apache server daemon.\  \\' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # processname: /usr/local/apache/bin/apachectl' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # config: /usr/local/apache/conf/httpd.conf' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # pidfile: /usr/local/apache/logs/httpd.pid' /etc/init.d/apachectl

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

# MySQL-5.0 시도

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

cd /usr/local/src/APM_Setup/
wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.0/mysql-5.0.96.tar.gz
tar zxvf mysql-5.0.96.tar.gz
cd /usr/local/src/APM_Setup/mysql-5.0.96/

./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-mysqld-user=mysql \
--with-extra-charsets=all \
--with-plugins=max \
--enable-thread-safe-client \
--sysconfdir=/etc \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--without-debug \
--enable-shared \
--enable-assembler \
--with-readline \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-plugins=innobase \
--with-charset=utf8 CXXFLAGS="-std=gnu++98"

=============================================================================================
configure: error: No curses/termcap library found

yum -y install libtermcap-devel ncurses-devel

yum install compat-*
=============================================================================================

\cp -arpf /usr/local/src/APM_Setup/mysql-5.0.96/support-files/my-huge.cnf /etc/my.cnf
\cp -arpf /usr/local/src/APM_Setup/mysql-5.0.96/support-files/mysql.server /etc/init.d/mysqld

        sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
        sed -i "/# basedir/a basedir = \/usr\/local\/mysql" /etc/my.cnf
        sed -i "/# datadir/a datadir = /usr/local/mysql/data" /etc/my.cnf
        sed -i "/# port /a port = 3306" /etc/my.cnf
        sed -i '/# log_bin/a log-bin=mysql-bin' /etc/my.cnf

        /usr/local/src/APM_Setup/mysql-5.0.96/scripts/mysql_install_db \
        --user=mysql \
        --datadir=/usr/local/mysql/data \
        --basedir=/usr/local/mysql

        mkdir -p /usr/local/mysql/tmp
        mkdir -p /usr/local/mysql/logs

        chown -R mysql:mysql /usr/local/mysql
        chown -R mysql:mysql /usr/local/mysql/data

        chmod 700 /etc/init.d/mysqld
        chmod 711 /usr/local/mysql
        chmod 700 /usr/local/mysql/data
        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

        rm -rf /etc/init.d/mysql
        /etc/init.d/mysqld restart

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

# MySQL 4.1 시도

cd /usr/local/src/APM_Setup/
wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-4.1/mysql-4.1.22.tar.gz
tar zxvf mysql-4.1.22.tar.gz
cd /usr/local/src/APM_Setup/mysql-4.1.22/

./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--localstatedir=/usr/local/mysql/data \
--sysconfdir=/etc \
--without-debug \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--enable-shared \
--enable-assembler \
--with-readline \
--enable-thread-safe-client \
--with-extra-charsets=all \
--with-innodb \
--with-pthread \
--with-named-thread-lib=-lpthread \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-charset=utf8 CXXFLAGS="-std=gnu++98"

make -j4 && make install

\cp -arpf /usr/local/src/APM_Setup/mysql-4.1.22/support-files/my-huge.cnf /etc/my.cnf
\cp -arpf /usr/local/src/APM_Setup/mysql-4.1.22/support-files/mysql.server /etc/init.d/mysqld

        sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
        sed -i "/# basedir/a basedir = \/usr\/local\/mysql" /etc/my.cnf
        sed -i "/# datadir/a datadir = /usr/local/mysql/data" /etc/my.cnf
        sed -i "/# port /a port = 3306" /etc/my.cnf
        sed -i '/# log_bin/a log-bin=mysql-bin' /etc/my.cnf

        /usr/local/src/APM_Setup/mysql-4.1.22/scripts/mysql_install_db \
        --user=mysql \
        --datadir=/usr/local/mysql/data \
        --basedir=/usr/local/mysql

        mkdir -p /usr/local/mysql/tmp
        mkdir -p /usr/local/mysql/logs

        chown -R mysql:mysql /usr/local/mysql
        chown -R mysql:mysql /usr/local/mysql/data

        chmod 700 /etc/init.d/mysqld
        chmod 711 /usr/local/mysql
        chmod 700 /usr/local/mysql/data
        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

        rm -rf /etc/init.d/mysql
        /etc/init.d/mysqld restart

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

Posted by returnrisk
,

cd /usr/local/src/

wget http://www.netmeridian.com/e-huss/queue-fix.tar.gz

tar zxvf queue-fix.tar.gz 

cd queue-fix-1.4

make -j 8

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

/etc/rc.d/init.d/qmail stop     // qmail 가동을 중지 합니다.
mv /var/qmail/queue /var/qmail/queue.bak // 혹시모르니 기존 디렉토리를 백업합니다.

./queue-fix -i /var/qmail/queue // [Y/N]를 두번 정도 물어보는데 모두 Y를 선택하면 됩니다.



혹시 진행중 아래와 같은 오류가 발생되면

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

./load auto-str substdio.a error.a str.a 

/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in substdio.a(substdo.o) 

/lib/libc.so.6: could not read symbols: Bad value 

collect2: ld returned 1 exit status 

make: *** [auto-str] 오류 1

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

아래와 같이 해결 가능합니다.


vi error.h

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

extern int errno; 부분을 찾아 행을 삭제하고
#include <errno.h> 이부분으로 대체하면 됩니다. (앞에 #포함)

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


vi conf-cc 

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

gcc -O2 ->     gcc -O2 --include /usr/include/errno.h  
=========================================================================


make -j 8


그리고 한가지 더 체크해주어야 할게 있는데요,

혹시 기존의 /var/qmail/queue 디렉토리에 22번이후의 번호가 존재할 경우

아래 스크립트를 이용해 23부터 199번까지 생성해줍니다.



# vi queue_add.sh     // 파일을 생성하여 아래 내용을 추가

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

#!/bin/bash
for ((a=23;a<=199;a++))

do

mkdir /var/qmail/queue/info/$a;

chown -R qmails.qmail /var/qmail/queue/info/$a;

chmod -R 700 /var/qmail/queue/info/$a;

mkdir /var/qmail/queue/local/$a;

chown -R qmails.qmail /var/qmail/queue/local/$a;

chmod -R 700 /var/qmail/queue/local/$a;

mkdir /var/qmail/queue/mess/$a;

chown -R qmailq.qmail /var/qmail/queue/mess/$a;

chmod -R 750 /var/qmail/queue/mess/$a;

mkdir /var/qmail/queue/remote/$a;

chown -R qmails.qmail /var/qmail/queue/remote/$a;

chmod -R 700 /var/qmail/queue/remote/$a;

done

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

sh queue_add.sh




/etc/init.d/qmaild stop

rm -rf /var/qmail/queue

./queue-fix -i /var/qmail/queue       //    큐메일 디렉토리 복구

/etc/init.d/qmaild start      // qmail 시작합니다.



※ 여기서 중요한것은 큐메일 디렉토리를 삭제하고 복구를 했을 경우

일부 시스템에서는 리부팅을 해줘야만 완전히 복구 되는 경우가 있습니다

이제 메일 발송을 해보세요. 잘 발송 될것입니다!

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

qmail,sendmail 큐삭제


qmail 큐를 삭제하기전에 쌓여있는 큐를 확인한다.



# /var/qmail/bin/qmail-qstat

         messages in queue: 984

         messages in queue but not yet preprocessed: 0



이렇게 확인을하게되면 쌓인 큐가 얼마나되는지 확인할수있다.

쌓인 큐를 삭제하려면 qmHandle 로 큐를 삭제한다.

#qmHandle -D 로 쌓인 큐를 삭제한다.



sendmail 큐 삭제하는 방법

#mailq 로 쌓여있는 큐를 확인한다..

#cd /var/spool/mqueue 를 입력하여 해당 디렉토리에 들어간다

#pwd 로 해당디렉토리에 위치하였는지 확인한다.

#rm -rf *을 이용하여 해당 디렉토리에있는 큐를 삭제한다.

#mailq를 실행하여 쌓여있는 큐가 삭제되었는지 확인한다.

'Mail' 카테고리의 다른 글

다람쥐메일(squirrelmail) 설치 방법  (0) 2020.10.05
Qmail 설치  (0) 2020.09.28
QMail 특징 및 필요 개발모듈  (0) 2020.09.21
Roundcube mail  (0) 2020.09.15
Dovecot 설치 및 설정  (0) 2020.09.15
Posted by returnrisk
,

- 기본 준비

yum -y install wget gcc* make cmake libtool* openssl* pcre* ncurses ncurses-devel curses-devel libxml* bzip2 bzip2-libs bzip2-devel curl-devel curl expat-devel expat gdbm gdbm-devel libjpeg* libpng* libtiff* freetype* freetype imap imap-devel krb5-devel libmcrypt* libmhash-devel mhash* flex icu libicu libicu-devel libc libcu-devel libc-client-devel zlib-devel zlib libtiff-devel libtiff gd* pcre-devel pcre gdbm* pam-devel patch libcurl libcurl-devel libvpx libvpx-devel libXpm libXpm-devel t1lib t1lib-devel gmp-devel openldap-devel readline-devel libedit-devel libtidy libtidy-devel libxslt libxslt-devel db4-devel ibc-client uw-imap-devel uw-imap uw-imap-static libc-client-2007f wget vim

: 필요없는 라이브러리도 있으니 용량 부족시 확인 후 설치



- Group & User 생성

groupadd -g 400 mysql 

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



- MySQL 4.0.30 준비

파일 다운로드 후 압축 해제

cd /usr/local/src/APM_Setup

wget https://dafaru.com/mydata/linux/lmp-4/mysql-4.0.30.tar.gz
wget https://github.com/ingktds/mysql-4.0.30/blob/master/mysql-4.0.30.tar.gz

tar zxvf mysql-4.0.30.tar.gz

cd mysql-4.0.30



- 컴파일

./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/usr/local/mysql/data --with-mysqld-user=mysql --with-openssl



./configure --prefix=/usr/local/mysql --with-mysqld-user="mysql" --localstatedir=/usr/local/mysql/data --sysconfdir=/etc --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --without-debug --enable-shared --enable-assembler --with-readline --enable-thread-safe-client --with-plugins=innobase --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock



- make && make install

make -j 4 && make install

: -j 옵션은 top -> 1로 확인 후 서버에 맞춰 변경하여 사용



- 설정, 실행파일 생성

cp -arp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

cp -arp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld



- 초기 DB 생성

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



- MySQL sock파일 디렉토리생성

mkdir /usr/local/mysql/tmp/



- data 디렉터리 소유권 변경

chown -R mysql.mysql /usr/local/mysql/data

chown -R mysql:mysql /usr/local/mysql

chmod 711 /usr/local/mysql

chmod 700 -R  /usr/local/mysql/data

chmod 751 /usr/local/mysql/bin

chmod 755 /usr/local/mysql/bin/mysql

chmod 750 /usr/local/mysql/bin/*

chmod 755 /usr/local/mysql/bin/mysqldump



- 환경변수 추가

vi /etc/profile

: 문서 맨 하단에 아래 내용 추가

===

export MySQL_HOME=/usr/local/mysql
export PATH="$PATH:/usr/local/mysql/bin"

===

source /etc/profile



- root 비밀번호 설정

mysql_secure_installation

===

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: root 패스워드 입력
Re-enter new password: root 패스워드 입력
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

===



위에꺼 안될때

/usr/local/mysql/bin/mysqladmin -u root -p password '새로운비밀번호'







- gcc 에러 발생 시 

mysql.cc: In function 'void print_table_data(MYSQL_RES*)':

mysql.cc:1650: error: expected primary-expression before '?' token

mysql.cc:1650: error: expected ':' before ')' token

mysql.cc:1650: error: expected primary-expression before ')' token

mysql.cc:1652: error: expected primary-expression before '?' token

mysql.cc:1652: error: expected ':' before ')' token

mysql.cc:1652: error: expected primary-expression before ')' token

mysql.cc:1666: error: expected primary-expression before '?' token

mysql.cc:1666: error: expected ':' before ')' token

mysql.cc:1666: error: expected primary-expression before ')' token

make[1]: *** [mysql.o] Error 1

make[1]: Leaving directory `/usr/local/src/APM_Setup/mysql-4.0.27/client'

make: *** [install-recursive] Error 1



: 위 에러는 gcc 버전이 높아 발생하는 에러로 아래와 같이 해결함

yum install compat-*

cd /usr/bin

mv gcc gcc-backup

mv g++ g++-backup

ln -s gcc34 gcc

ln -s g++34 g++



- LinuxThreads 에러 발생 시 

checking “LinuxThreads“… “Not found“
configure: error: This is a linux system and Linuxthreads was not
found. On linux Linuxthreads should be used. Please install Linuxthreads
(or a new glibc) and try again. See the Installation chapter in the
Reference Manual for more information.



: 위 에러는 glibc를 찾지 못하여 발생하는 에러로 아래와 같이 해결함



vi /usr/include/pthread.h

: 문서 맨 아래에 /* Linuxthreads */를 추가

===

__END_DECLS

#endif /* pthread.h */
/* Linuxthreads */

===



※ 재시작 및 접속 확인 시 완료 ※

'DB > Mysql' 카테고리의 다른 글

MySQL 3.23 소스설치 (CentOS 6)  (0) 2021.09.30
my.cnf 추천  (0) 2020.12.02
mysql 리플리케이션 무중단  (0) 2020.11.04
mysql8 마이그레이션  (0) 2020.10.30
APM 설치(2/4) - MySQL(5.6.29)  (0) 2020.10.30
Posted by returnrisk
,