결론적으로 말하면 금,월,화(반)
NPM을 소스로 설치하는데 약 2일하고도 반이 걸렸다.
Nginx, MariaDB, PHP
Nginx는 크게 문제되지 않음
Nginx를 쓰는 이유라고 하면
Nginx => 이벤트 중심 접근 방식
Apache => 프로세스 기반 접근 방식
Nginx => 하나의 스레드에서 여러 요청
Apache => 하나의 스레드에서 하나 요청
동적 컨텐츠는 성능이 비슷하지만 Nginx는 대용량 트래픽 처리를 위해
가벼움과 높은 성능을 목표로 하기 때문에 사용한다.
자세한 차이는 여기 블로그에 잘 나와있음
https://velog.io/@cjyooong/apache-nginx
웹 서버 Apache보다 Nginx를 사용하는 이유
Java로 프로그래밍을 처음 시작할때는 웹서버는 Apache, WAS는 Tomcat으로 웹 사이트를 구현했었다.전 직장에서도 웹 서버-Apache, WAS-Tomcat을 사용하고 있었지만, Python으로 프로젝트를 배포하며 알게된
velog.io
https://nginx.org/en/download.html
nginx: download
nginx.org
wget을 사용해도 상관없고 파일질라나 scp 다 상관없다
stable 버전으로 다운받아주고
/usr/local/에
# tar -zxvf nginx-1.26~~~
나는 편의상 nginx라고 디렉터리명을 바꾸어줌
# mv nginx-1.26~~ nginx
디렉터리에 들어가서
./configure --user=web \
--group=web \
--prefix=/data/web/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/data/web/nginx/conf/nginx.conf \
--error-log-path=/data/web/nginx/logs/error.log \
--http-log-path=/data/web/nginx/logs/access.log \
--pid-path=/data/web/nginx/run/nginx.pid \
--lock-path=/data/web/nginx/run/nginx.lock
configure 과정에서 잘못된 부분을 찾을 수도 있다.
--prefix= 부분은 경로이기 때문에 자신이 원하는 곳으로 적어주면 됨
만약 안적으면 /usr/local/ 이 기본 경로
make
configuer, make, make install 한번에 할수 있는데 과정별로 하는게 보기 좋다
make install
하고 nginx 디렉터리 내에 sbin 경로로 가서
# ./nginx
# nginx 버전 및 compiler 또는 configure 표시
/sbin/nginx -V
# nginx 도움말
/sbin/nginx -h
# nginx 설정파일 확인
/sbin/nginx -t
# nginx 시작
/sbin/nginx
# nginx 중지
/sbin/nginx -s stop
# nginx 재기동
/sbin/nginx -s reload
옵션은 이렇다
로컬호스트면 그냥 localhost만 입력하면 nginx 웰컴 화면이 나오는데
만약 원격호스트라면
rocky 기준
curl ifconfig.me
입력하면 공인ip 나옴
공인ip 입력했는데 안들어가진다면
방화벽을 허용해주어야함
전체를 받을지 특정 아이피를 받을지는 선택인데
클라이언트 공인 ip는
윈도우 기준 cmd
> nslookup myip.opendns.com. resolver1.opendns.com
근데 귀찮으면 네이버에 공인ip 검색
# firewall-cmd --list-all
허용된 ip가 나오고
포트허용은
# firewall-cmd --permanent --add-port=80/tcp
IP허용은
# firewall-cmd --permanent --add-source=122.xxx.xxx.xxx
여러 옵션이 있으니 검색해보면됨
변경한 후
# firewall-cmd --reload
다시 재조회
# firewall-cmd --list-all
하고 ip나 프로토콜이나 등록이 되어있다면
주소창에 검색하면됨
MariaDB
일단 중간에 한 번 끊고 말하자면
필요한 라이브러리나 패키지를 처음부터 다 알고 미리 설치하는것도 좋지만
모르는 상태에서 찾아들어가며 하나하나 설치하면서 하는 과정이기 때문에
그냥 무작정 들이받는 과정임
MariaDB를 받을랬더니 Cmake가 필요
Cmake를 설치하기 위해서는 OpenSSL이 필요하더라
먼저 OpenSSL source 설치를 진행함
다운받을 수 있는 페이지는 많고 그 중에 하나 고르면 되는데
https://mirrors.ibiblio.org/openssl/source/
Index of /openssl/source/
README2014-Nov-19 12:48:210.1Ktext/plain; charset=utf-8
mirrors.ibiblio.org
https://openssl-library.org/source/
Downloads
The master sources are maintained in our git repository, which is accessible over the network and cloned on GitHub, at https://github.com/openssl/openssl. Bugs and pull patches (issues and pull requests) should be filed on the GitHub repo. Please familiari
openssl-library.org
다운 받아서
tar -zxvf openssl~
./bootstrap --prefix=/usr/local/compile_util/cmake && make && sudo make install
>CMake Error at Utilities/cmcurl/CMakeLists.txt:645 (message):
Could not find OpenSSL. Install an OpenSSL development package or
configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
OpenSSL 라이브러리를 못찾는 에러 발생
OpneSSL 라이브러리는 /usr/local/compile_util/openssl 디렉터리에 있음
cmake 디렉터리 내 CMakeLists.txt 파일에
──────────────────────────────────────────────────────────────────
# OpenSSL 경로 지정
set(OPENSSL_ROOT_DIR "/usr/local/compile_util/openssl")
set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}/include")
set(OPENSSL_LIBRARIES "${OPENSSL_ROOT_DIR}/lib")
# OpenSSL 찾기
find_package(OpenSSL REQUIRED)
──────────────────────────────────────────────────────────────────
위 내용 추가
cmake 폴더에 가서
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/socket/mysql.socket \
-DINSTALL_SYSCONFDIR=/etc \
-DINSTALL_SYSCONF2DIR=/etc/my.cnf.d \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARIA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_ZLIB=system \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
설명
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
= mysql을 설치할 기본 경로 지정
-DMYSQL_DATADIR=/usr/local/mysql/data \
= MySQL 데이터 디렉토리 위치 지정
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/socket/mysql.socket \
= 기본은 /tmp/mysql.sock 이며, Unix socket 파일 경로는 서버에 소켓 연결할 때 지정된다.
-DINSTALL_SYSCONFDIR=/etc \
= my.cnf 옵션 파일 디렉토리 위치 지정
-DINSTALL_SYSCONF2DIR=/etc/my.cnf.d \
= my.cnf 옵션 파일 디렉토리 위치 지정
-DMYSQL_TCP_PORT=3306 \
= TCP/IP 연결시 사용하는 포트 번호 지정. 기본 3306.
-DDEFAULT_CHARSET=utf8 \
= 언어셋을 utf8로 지정
-DDEFAULT_COLLATION=utf8_general_ci \
= 콜레이션을 utf8_general_ci 로 설정.
-DWITH_EXTRA_CHARSETS=all \
= all이 기본이며, 모든 문자열 셋을 포함한다는 의미
-DENABLED_LOCAL_INFILE=1 \
= MySQL 문법 중에 load data infile이라는 것이 있다. txt 파일 등을 mysql data로 가져오는 문법이라 편리하지만 보안상의 문제가 동시에 발생하기 때문에 1로 지정해준다.
서버에서 스토리지 엔진을 정적으로 컴파일한다면, 아래와 같은 설정들을 할 수 있다.
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARIA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_ZLIB=system \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
MySQL은 SSL 라이브러리를 무조건 사용해야하는데, 특정 옵션(yes, bundled, system)을 정하여 사용한다. MySQL5.7 에서는 bundled가 기본.
끝나면 make && make install
──────────────────────────────────────────────
MariaDB 초기 데이터 생성 및 권한 설정
cp -arpf /'압축해제한 디렉토리'/mariadb-10.5.9/build/scripts/mysql_install_db /'설치 디렉토리'/mysql/scripts/mysql_install_db
cd /'설치 디렉토리'/mysql
rm -rf /'설치 디렉토리'/mysql/data
perl /'설치 디렉토리'/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
mkdir -p /'설치 디렉토리'/mysql/lnnoDB/redoLogs
mkdir -p /'설치 디렉토리'/mysql/lnnoDB/undoLogs
chown -R mysql /'설치 디렉토리'/mysql/data
chgrp -R mysql /'설치 디렉토리'/mysql
mkdir /'설치 디렉토리'/mysql/logs
mkdir /'설치 디렉토리'/mysql/tmp
chown mysql:mysql /'설치 디렉토리'/mysql/tmp
chown mysql:mysql /'설치 디렉토리'/mysql/logs
chown -R mysql:mysql /'설치 디렉토리'/mysql/data
──────────────────────────────────────────────
MariaDB 설정파일 생성
[client]
#password = your_password
port = 3306
socket = /mariadb/mysql/tmp/socket/mysql.socket
[mysqld]
bind-address=0.0.0.0
port = 3306
socket = /mariadb/mysql/tmp/socket/mysql.socket
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
log-bin=mysql-bin
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
──────────────────────────────────────────────
MariaDB 서비스 데몬 생성
[Unit]
Description=MariaDB Database Server
After=syslog.target
After=network.target
[Service]
KillMode=process
KillSignal=SIGTERM
SendSIGKILL=no
User=mysql
Group=mysql
LimitNOFILE=infinity
LimitNPROC=4096
LimitCORE=infinity
PermissionsStartOnly=true
PrivateTmp=true
OOMScoreAdjust=-1000
ExecStart=/mariadb/mysql/bin/mysqld --defaults-file=/etc/my.cnf --plugin-dir=/mariadb/mysql/lib/plugin
Restart=always
RestartSec=1
TimeoutSec=300
──────────────────────────────────────────────
최종 mariadb 실행 시 libncurses.so.5 에러 문제 직면
RedHat 8(Rocky linux 8) 이상에서는 libncurses.so.5 바이너리를 기본적으로 사용할 수 없음
하지만 mariadb-11.4.2는 libncurses.so.5가 필요함
ncurses 다운받는 페이지가 있는데 응답이 없어서 일단 yum으로 진행
ERROR 2002 (HY000): Can't connect to local server through socket 에러 직면
tmp 내에 socket 디렉터리 생성을 안했던게 원인
디렉터리 생성 후 mysql:mysql chown 소유자와 그룹 변경해줌
> systemctl restart mysqld.service
> mysql -u root
정상작동
************************************************************
************************************************************
PHP
PHP 소스 설치 하기 위한 라이브러리 준비 과정
g라이브러리 최신버전 다운로드
패키치 설치 중 bison 파서 업데이트 해야하는 문제
*** These critical programs are missing or too old: bison python
bison 3.8.2 버전 소스파일 다운로드
configure 과정 중 m4 최신버전 요구 문제
m4 1.4.19 다운로드
패키지 설치 후 다시 bison 설치
bison 패키지 정상 설치됨
g라이브러리 재설치 -> python 업그레이드 요구
3.12.4 버전 다운로드 후
configure --enable-optimizations
OpenSSL을 source 설치로 진행했기 때문에 OpenSSL 인식을 못함
configure --enable-optimizations --with-openssl=/usr/local/openssl 로 변경
openssl 인식을 못함
openssl version을 해보니 안됨
1. openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
> cp /usr/local/lib64/libssl.so.3 /usr/lib64/libssl.so.3
2. openssl: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory
> cp /usr/local/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
다시 ./configure --with-openssl=/usr/local/openssl --enable-optimizations 정상작동됨
libzip 1.10.1 버전 다운로드
/usr/local/compile_util/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/libzip-1.10.1
2024-8-6
PHP 설치 중 autoconf 미설치 확인
https://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
autoconf 설치 후 php buildconf 재시도 ./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php/php.d --with-zlib-dir --enable-mbstring --with-curl --with-mcrypt --with-zlib --disable-rpath --enable-inline-optimization --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-openssl --with-fpm-user=nobody --with-fpm-group=nobody --enable-fpm --with-pdo-mysql
24-11-05 기준 수정
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/nginx/conf --with-config-file-scan-dir=/usr/local/nginx/conf --with-openssl --with-mysql-sock=/tmp/mysql.sock --with-mysqli --with-pdo-mysql --with-enchant --with-gettext --with-freetype --with-jpeg --with-webp --with-xpm --with-zlib --with-gmp --with-iconv --with-gdbm --with-bz2 --with-curl --with-mhash --with-xsl --with-readline --with-curl --with-pear --with-gettext --with-ldap --with-libxml --with-zip --with-libdir=lib64 --enable-gd --enable-litespeed --enable-mysqlnd --enable-bcmath --enable-sockets --enable-pcntl --enable-ftp --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-session --enable-soap --enable-xml --enable-opcache --enable-intl --enable-cli --enable-zts --enable-debug --enable-mbregex --enable-dba --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-exif --enable-fpm --with-pic
Package 'libxml-2.0', required by 'virtual:world', not found
libxml2를 공식 홈페이지에서 다운받았고
환경변수도 추가함
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig:$PKG_CONFIG_PATH
configure 재시도
openssl 환경변수 추가
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
configure 재시도
sqlite3 필요함
https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release
configure 중 tcl 필요함
공홈에서 다운받고 compile 방법 참고
sqlit33 설치 완료 후 다시 php configure 시도
libcurl 필요
https://curl.se/download/curl-8.9.1.tar.gz
configure: error: select TLS backend(s) or disable TLS with --without-ssl.
openSSL을 이용하여 재시도
./configure --with-ssl
설치완료
PHP configure 재시도
Package 'oniguruma', required by 'virtual:world', not found
oniguruma 깃에서 압축파일 받음
PHP configure 재시도
configure: error: No supported shared memory caching support was found when configuring opcache. Check config.log for any errors or missing dependencies.
재시도
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --with-openssl --with-zlib --enable-bcmath --with-curl --with-libdir=/lib/x86_64-linux-gnu --enable-soap --enable-intl --with-xsl --with-gettext --with-kerberos --with-pdo-mysql --with-mysqli --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-libzip --enable-mbstring --with-mhash --with-iconv --with-bz2 --enable-exif --enable-ftp --with-gd --with-jpeg --with-freetype
에러
configure: error: Package requirements (krb5-gssapi krb5) were not met:
Package 'krb5-gssapi', required by 'virtual:world', not found
Package 'krb5', required by 'virtual:world', not found
구글에 rpm밖에 못찾아서 dnf install로 설치함
재시도
Bzip2 재설치 요구
sourceware > bzip2 경로로 wget
make && make install 후
재시도
configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:
Package 'icu-uc', required by 'virtual:world', not found
Package 'icu-io', required by 'virtual:world', not found
Package 'icu-i18n', required by 'virtual:world', not found
https://www.linuxfromscratch.org/blfs/view/svn/general/icu.html
에서 다운로드
재시도
configure: error: Package requirements (libxslt >= 1.1.0) were not met:
libxslt
https://www.linuxfromscratch.org/blfs/view/svn/general/libxslt.html
재시도
configure 성공 make 중
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol mb_utf16be_to_wchar'
with pointer equality in ext/mbstring/libmbfl/filters/mbfilter_utf16.o'
can not be used when making an executable; 에러
STT_GNU_IFUNC: 이는 간접 함수 호출에 사용되는 GNU ELF(실행 가능 및 연결 가능 형식)의 특수한 유형의 기호입니다. 이는 아키텍처 또는 기타 요소를 기반으로 기능 구현의 런타임 선택을 허용합니다.
실행 가능 문제: 실행 파일이나 공유 라이브러리에 IFUNC로 표시된 기호가 포함되어 있는 경우 IFUNC 기능은 일반적으로 실행 파일이 아닌 공유 라이브러리에서 사용되므로 링커에서 오류가 발생할 수 있습니다.
make clean으로 청소 후
export CFLAGS="-I/usr/includes"export LDFLAGS="-L/usr/libs"
컴파일러가 헤더 파일을 찾아야하는 -I 플래그
링커가 라이브러리 파일을 찾아야하는 -L 플래그
정상 설치 됐고
/etc/php-fpm.d
cp -arp /usr/local/php/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 700 /etc/init.d/php-fpm
cp -arp /usr/local/php71/etc/php-fpm.d/www.conf.default /usr/local/php71/etc/php-fpm.d/www.conf
phpinfo 파일 생성
'Linux > Rocky 8.10' 카테고리의 다른 글
[Rocky 8.10] PHPMYADMIN 설치 (0) | 2024.08.13 |
---|---|
[Rocky 8.10] DNS 서버 구축 (0) | 2024.08.08 |
CMake 컴파일 설치 에러 포함 (0) | 2024.08.05 |
Linux 리눅스 mv 명령어, 파일 이동, 파일명 변경 (0) | 2024.08.02 |
[sss_cache] [sysdb_domain_cache_connect] (0x0010): DB version too old (0) | 2024.08.02 |