CentOS 7 에서 OpenSSH 취약점 (취약한 알고리즘) 조치 방법

리눅스/OS 일반|2022. 3. 31. 12:21
반응형

[ 취약한 알고리즘 ]
Running SSH serviceInsecure CBC ciphers in use: aes128-cbc,aes192-cbc,blowfish-cbc,cast128-cbc,aes256-cbc
Running SSH serviceInsecure 3DES ciphers in use: 3des-cbc
Running SSH serviceInsecure key exchange in use: diffie-hellman-group1-sha1
Running SSH serviceInsecure key exchange algorithms in use: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Running SSH serviceInsecure MAC algorithms in use: umac-64-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,hmac-sha1

 


[ 현재 허용된 알고리즘 확인 ]
아래와 같은 명령어로 확인이 가능합니다.

 

(명령)

# sshd -T | grep "\(^ciphers\|^macs\|^kexalgorithms\)"

(결과)
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
macs umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1

kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1


[ 설정 변경 및 적용 ]
설정 파일을 열어 아래 내용 삽입 (또는 수정) 후 sshd 데몬을 재시작 합니다.
기본 옵션으로 모두 허용되어 있으므로 위 출력 결과에서 사용하지 않을 알고리즘만 제거하고 입력하였습니다.

 

# vi /etc/ssh/sshd_config


ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
macs umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

# service sshd restart

 

 

[ 변경된 알고리즘 재확인 ]

 

(명령)

# sshd -T | grep "\(^ciphers\|^macs\|^kexalgorithms\)"

 

(결과)
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
macs umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

반응형

댓글()

Ubuntu 18.10 싱글모드 (복구모드) 진입 & 계정 잠김 해제

리눅스/OS 일반|2022. 3. 17. 08:01
반응형

패스워드 임계치 설정을 해 놓고, 정해놓은 수 만큼 패스워드가 불일치 되면 계정이 잠깁니다.

이럴 경우 싱글모드로 진입하여 계정 잠김 해제를 할 수 있습니다.

 

 

1. 싱글모드 진입

시스템 리부팅시 커널 선택 부분에서 아래와 같은 항목 위에서 알파벳 'e' 를 누릅니다.

*Ubuntu    // 아마도 맨 위의 항목

 

에디터 창이 뜨는데 아래서 두번째 라인 (linux 로 시작 하는 라인) 만 수정하면 됩니다.

ro 라는 단어부터 뒤로 모두 지우고 아래 내용으로 대체합니다.

rw init=/bin/bash

그리고 Ctrl + X 키를 눌러 부팅하면 계정 패스워드 없이 root 권한으로 shell 진입하게 됩니다.

 

 

2. 계정 잠김 해제

1) 확인

# pam_tally2 -u 계정명

 

2) 해제

# pam_tally2 -u 계정명 -r

 

 

3. 리부팅

싱글모드에서는 init 6 이나 reboot 명령이 되지 않으므로 강제 리부팅을 시행합니다.

# reboot -f

 

반응형

댓글()

PHP 8.0 에서 SCREWIM 을 이용한 소스 암호화

리눅스/PHP|2021. 12. 28. 13:53
반응형

DB 접속 정보가 들어있는 파일이 노출될 우려가 있어 많은 개발자들이 암호화 방법을 찾고 있습니다.

검색해보면 상용 프로그램 또는 난독화, 무료 암호화 프로그램이 몇 개 있으나

여기에서는 김정균님이 만드신 screw 개선 버전 screwim 을 소개합니다.

아래 내용은 CentOS 7, PHP 8.0 소스설치 환경에서 테스트 했으며,

페이지 하단 출처의 내용을 요약하였습니다.

 

 

1. 다운로드

 

# cd /usr/local/src
# git clone https://github.com/OOPS-ORG-PHP/mod_screwim.git

mod_screwim.zip
0.22MB

# cd mod_screwim
# /usr/local/php/bin/phpize


2. PHP 확장 모듈 생성하기

 

# ./configure --with-php-config=/usr/local/php/bin/php-config
# make install

php.ini 에 아래 내용 추가
# vi /usr/local/apache/conf/php.ini
extension = screwim.so
screwim.enable = 1

(아파치 재시작 및 적용 확인)
# /usr/local/apache/bin/apachectl restart
# /usr/local/php/bin/php -m |grep screwim

 


3. SCREWIM 설치

 

# cd tools
# ./autogen.sh    // 위에서 모듈을 설치하지 않으면 실행이 안됩니다. 모듈부터 설치하세요.

# ./configure

# make install

 

(설치 확인)
# /usr/local/bin/screwim -v


4. PHP 소스 암호화 하기


# cd /{PHP 소스 디렉토리}
# screwim config.php

 

원본 파일은 백업하고 암호화된 파일은 사용하는 파일명으로 변경합니다.
# mv config.php config.php.ori
# mv config.php.screw config.php

사이트 동작을 확인합니다.

 

* 복호화 불가 처리하실 분은..

   실행 파일이나 설치 소스 파일이 그대로 남겨져 있을 경우 screwim -d 옵션을 통해 복호화가 가능하므로

   실행 파일 및 설치 소스 파일 디렉토리를 삭제 합니다.

   (설치시 암호화, 복호화에 사용되는 랜덤 생성된 KEY STRING 삭제)

    rm -f /usr/local/bin/screwim

    rm -rf /usr/local/src/mod_screwim

 

 

[출처] https://www.php79.com/525

https://github.com/OOPS-ORG-PHP/mod_screwim/

https://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=81220

 

 

반응형

댓글()

쉘스크립트를 이용한 메일 IP 평판 확인하기 (block list 등록 여부)

리눅스/Mail|2021. 12. 21. 08:53
반응형

# vi blcheck

#!/bin/sh

# 조회할 사이트 목록
BLISTS="
    cbl.abuseat.org
    dnsbl.sorbs.net
    bl.spamcop.net
    zen.spamhaus.org
"

# 에러 처리 (인자값 누락)
ERROR() {
  echo $0 ERROR: $1 >&2
  exit 2
}
[ $# -ne 1 ] && ERROR 'Please specify a single IP address'

# 역방향으로 IP 정렬
reverse=$(echo $1 |
sed -ne "s~^\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)$~\4.\3.\2.\1~p")
if [ "x${reverse}" = "x" ] ; then
      ERROR  "IMHO '$1' doesn't look like a valid IP address"
      exit 1
fi

# 역방향 DNS 조회 수행
REVERSE_DNS=$(dig +short -x $1)
echo IP $1 NAME ${REVERSE_DNS:----}

# 반복 처리
for BL in ${BLISTS} ; do
    # 시간 출력
    printf $(env TZ=Asia/Seoul date "+%Y-%m-%d_%H:%M:%S")
    # 반전된 IP 와 블랙 리스트 출력
    printf "%-50s" " ${reverse}.${BL}."
    # dig 를 이용하여 블랙 리스트에서 IP 조회
    LISTED="$(dig +short -t a ${reverse}.${BL}.)"
    echo ${LISTED:----}
done

[출처] https://www.saotn.org/bash-check-ip-address-blacklist-status/

* 출처에서 더 많은 정보를 표시하고 있습니다. 소스가 필요하신 분은 꼭 한번 방문해 보시기 바랍니다.

 

# chmod 700 blcheck

# blcheck 10.20.30.40    // 체크하고자 하는 IP 를 인자값으로 넣는다.

 

(결과 : 블록되지 않은 상태)

IP 10.20.30.40 NAME ---
2021-12-20_23:49:57 [your_api_key].40.30.20.10.dnsbl.httpbl.org.     ---
2021-12-20_23:49:58 40.30.20.10.cbl.abuseat.org.                     ---
2021-12-20_23:49:58 40.30.20.10.dnsbl.sorbs.net.                     ---
2021-12-20_23:49:59 40.30.20.10.bl.spamcop.net.                      ---
2021-12-20_23:49:59 40.30.20.10.zen.spamhaus.org.                    ---
2021-12-20_23:49:59 40.30.20.10.combined.njabl.org.                  ---

 

(결과 : 블록 된 상태)

IP 10.20.30.40 NAME ---
2021-12-20_23:49:57 [your_api_key].40.30.20.10.dnsbl.httpbl.org.     ---
2021-12-20_23:49:58 40.30.20.10.cbl.abuseat.org.                    127.0.0.2
2021-12-20_23:49:58 40.30.20.10.dnsbl.sorbs.net.                     ---
2021-12-20_23:49:59 40.30.20.10.bl.spamcop.net.                      ---
2021-12-20_23:49:59 40.30.20.10.zen.spamhaus.org.                    127.0.0.4
2021-12-20_23:49:59 40.30.20.10.combined.njabl.org.                  ---

 

Cisco 에서 제공하는 메일 평판 정보와 비교를 해보면 (talosintelligence.com)

127.0.0.2 같은 결과가 출력되는 것이 블랙 리스트로 등록된 경우 입니다.

 

저는 위와 같이 [출처] 의 스크립트를 약간 수정하여 사용했는데

키발급 및 체크가 약간 소요되는 두 개의 라인을 체크 대상에서 제외하였으며

dnsbl.httpbl.org

combined.njabl.org

 

한국 표준 시간 사용을 위해 아래 내용으로 수정하였습니다.

env TZ=Asia/Seoul

 

필요하신 분은 [출처] 에 추가된 내용과 같이 별도 스크립트를 만들어서 반복 조회를 할 수 있습니다.

for address in `cat iplist.txt`;
   do ./blcheck $address;
   sleep 2;
   done

 

반응형

댓글()

MySQL 8.0 SSL 설정하기

리눅스/MySQL|2021. 12. 15. 15:25
반응형

MySQL 8.0.26 버전에서 SSL 적용을 해보았습니다.

낮은 버전도 다르지 않다고 생각합니다.

 

[사전 준비]

- ssl 파일 위치 : /usr/local/mysql/ssl

- 체크 사항 : mysql 계정이 접근 가능한 경로 (/root/ssl 은 안됨), 파일 권한 확인 (mysql 계정 읽기)

 

 

1. 설정

# vi /etc/my.cnf

 

[mysqld] 섹션에 아래 내용 추가

ssl_cert = /usr/local/mysql/ssl/sysdocu.tistory.com.crt
ssl_key = /usr/local/mysql/ssl/sysdocu.tistory.com.key
ssl_ca = /usr/local/mysql/ssl/ca-bundle.crt

 

 

2. 확인

mysql> show variables like '%ssl%';
+-------------------------------------+--------------------------------------------+
| Variable_name                       | Value                                      |
+-------------------------------------+--------------------------------------------+
| admin_ssl_ca                        |                                            |
| admin_ssl_capath                    |                                            |
| admin_ssl_cert                      |                                            |
| admin_ssl_cipher                    |                                            |
| admin_ssl_crl                       |                                            |
| admin_ssl_crlpath                   |                                            |
| admin_ssl_key                       |                                            |
| clone_ssl_ca                        |                                            |
| clone_ssl_cert                      |                                            |
| clone_ssl_key                       |                                            |
| have_openssl                        | YES                                        |
| have_ssl                            | YES                                        |
| mysqlx_ssl_ca                       |                                            |
| mysqlx_ssl_capath                   |                                            |
| mysqlx_ssl_cert                     |                                            |
| mysqlx_ssl_cipher                   |                                            |
| mysqlx_ssl_crl                      |                                            |
| mysqlx_ssl_crlpath                  |                                            |
| mysqlx_ssl_key                      |                                            |
| performance_schema_show_processlist | OFF                                        |
| ssl_ca                              | /usr/local/mysql/ssl/ca-bundle.crt         |
| ssl_capath                          |                                            |
| ssl_cert                            | /usr/local/mysql/ssl/sysdocu.tistory.com.crt    |
| ssl_cipher                          |                                            |
| ssl_crl                             |                                            |
| ssl_crlpath                         |                                            |
| ssl_fips_mode                       | OFF                                        |
| ssl_key                             | /usr/local/mysql/ssl/sysdocu.tistory.com.key |
+-------------------------------------+--------------------------------------------+

 

 

반응형

댓글()

CentOS 7 에서 httpd 2.4.51, PHP 8.0 소스 설치하기

리눅스/APACHE|2021. 12. 7. 14:47
반응형

1. httpd 관련 패키지 설치

# yum -y install gcc gcc-c++  libtermcap-devel gdbm-devel zlib* libxml* freetype* libjpeg* gd-* 

# yum -y install libpng* --skip-broken pcre-devel

 

 

2. apr 설치

# cd /usr/local/src

# wget https://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

# tar xvzf apr-1.5.2.tar.gz

# cd apr-1.5.2

# ./configure --prefix=/usr/local/apr

# make

# make install

 

 

3. apr-util 설치

# cd ..

# wget https://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

# tar xvzf apr-util-1.5.4.tar.gz

# cd apr-util-1.5.4

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make

# make install

 

 

4. httpd 설치

# cd ..

# wget https://archive.apache.org/dist/httpd/httpd-2.4.51.tar.gz

# tar xvzf 

# cd httpd-2.4.51

# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-ssl --enable-so 

# make

# make install

 

 

5. PHP 관련 패키지 설치

# yum -y install sqlite-devel

 

 

6. PHP 설치

# cd ..

# wget https://www.php.net/distributions/php-8.0.12.tar.gz

# tar xvzf php-8.0.12.tar.gz

# cd php-8.0.12.tar.gz

# ./configure --prefix=/usr/local/php --with-mysqli --with-openssl=/usr/local/ssl --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-zlib --disable-debug --enable-calendar --enable-ftp --enable-sockets --enable-sysvsem

# make

# make install

# cp -arp php.ini-production /etc/php.ini

 

 

6. httpd 및 PHP 기본 설정

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

ServerName localhost

<Directory /usr/local/apache/htdocs>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>

 

# vi /etc/php.ini

short_open_tag = On

date.timezone = "Asia/Seoul"

open_basedir = "/usr/local/apache/htdocs"

반응형

댓글()

OpenSSL 업그레이드 (소스 설치 / 1.0.1k to 1.1.1o in CentOS 7) 및 APM 적용하기

리눅스/OS 일반|2021. 12. 7. 14:15
반응형

1. OpenSSL 업그레이드

 

# openssl 현재 버전 확인
openssl version 
 
# openssl 설치 위치 확인
which openssl
# /usr/bin/openssl
 
# OpenSSL 지원 프로토콜 확인
openssl ciphers -v |awk {'print $2'} |sort |uniq
  
# 기본 라이브러리 설치
yum -y install gcc gcc-c++ perl pcre-devel zlib-devel wget
 
# 다운로드 및 소스 컴파일

cd /usr/local/src

wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
tar xvfz openssl-1.1.1o.tar.gz
cd openssl-1.1.1o/ 
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install
 
# 새로운 파일 생성하여 아래 한줄 추가하고 저장(:wq)한다. (라이브러리 등록)
vi /etc/ld.so.conf.d/openssl-1.1.1o.conf
/usr/local/ssl/lib
 
# 동적 링크 생성
ldconfig -v
 
ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

링크 파일이 있으면 삭제 후 재실행


# 기존 openssl 이름 변경 (기존 패키지 버전명으로 백업)
mv /usr/bin/openssl /usr/bin/openssl1.0.1k
 
# 새로 설치한 버전 심볼릭 링크 생성
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
 
# 업데이트된 버전 확인
openssl version
 
# OpenSSL 지원 프로토콜 확인
openssl ciphers -v | awk '{print $2}' | sort | uniq
openssl1.0.2k ciphers -v | awk '{print $2}' | sort | uniq

출처: https://link2me.tistory.com/2023 [소소한 일상 및 업무TIP 다루기]

 

 

2. APM 적용

 

이미 설치된 APM 은 OpenSSL 업그레이드 버전이 자동으로 적용되지 않으므로

아래와 같은 방법으로 재설치를 하여 SSL 을 적용해야 합니다.

* SSL 설치 경로 : /usr/local/ssl

1) Apache

아래는 2.4.54 에서 확인되었습니다.

# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-module=ssl --enable-ssl=shared --with-ssl=/usr/local/ssl --enable-so

# make && make install

# /usr/local/apache/bin/apachectl restart

* 확인 방법 (httpd.conf 에서 mod_ssl.so 모듈이 로드 되어있어야 함)
# curl --head localhost

2) PHP

아래는 8.1.7 에서 확인되었습니다.

export PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig

# ./configure --prefix=/usr/local/php --with-mysqli --with-openssl=/usr/local/ssl --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-zlib --disable-debug --enable-calendar --enable-ftp --enable-sockets --enable-sysvsem --with-curl --enable-mbstring

# make && make install

# /usr/local/apache/bin/apachectl restart

* 확인 방법
# php -r "echo phpinfo();" | grep -i openssl

 

3) MySQL

아래는 8.0.29 에서 확인되었습니다.

 

다른 버전의 라이브러리를 가져올 수 있도록 patchelf 패키지를 우선 설치하고 진행합니다.

# yum -y install patchelf

 

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DWITH_SSL=/usr/local/ssl -DMYSQL_TCP_PORT=3306 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql-8.0.29/include/boost_1_77_0 -DFORCE_INSOURCE_BUILD=1

 

# make && make install

 

* 확인 방법

# ldd /usr/local/mysql/bin/mysqld |grep ssl

 

4) CURL

아래는 7.88.1 에서 확인되었습니다.

# ./configure --with-ssl=/usr/local/ssl --prefix=/usr/local/curl

# make && make install

# mv /usr/bin/curl /usr/bin/curl.old    // 기존 curl 이 있을 경우

# ln -s /usr/local/curl/bin/curl /usr/bin/curl

 

* 확인 방법

# curl -V

 

반응형

댓글()

[배치파일] 실행중인 프로세스 경로를 변수에 저장하기

윈도우즈/OS 일반|2021. 12. 4. 07:00
반응형

배치파일의 %~dp0 는 동작을 하지만 exe 로 변환시 동작하지 않는 부분이 있어 아래 내용을 작성합니다.

예제에서는 explorer.exe 실행 경로를 찾아 변수에 저장하는 것으로 합니다.

아래와 같이 배치파일을 만들어 실행해 봅니다.

 

test.bat

@echo off

FOR /F "delims=" %%i IN ('wmic process where name^="explorer.exe" get ExecutablePath') DO (
echo %%i |find /i "explorer.exe" >nul
if errorlevel 1 (echo notfound) else (echo found && set item=%%i)
)

echo %item%

FOR %%i IN ("%item%") DO (
echo filedrive=%%~di
echo filepath=%%~pi
echo filename=%%~ni
echo fileextension=%%~xi
)

둘째줄에 IN 다음 괄호안에 들어오는것이 원래의 명령어인데 출력되는 라인이 많기도 하고 원하는

줄 (총 3줄에서 2번째줄) 이 변수에 넣기 힘든 부분이 있습니다.

(괄호 안에서는 name= 부분에 = 가 특수문자로 인식되어 앞에 ^ 를 추가함)

 

세번째줄에서 각 행을 출력할때마다 Explorer 가 있는지 살펴보고 있으면 set item=%%i 를 실행하여 item 변수에

디렉토리와 파일의 온전한 경로를 넣습니다.

 

마지막으로 획득한 파일 경로를 드라이브명, 디렉토리, 파일명, 확장자로 나누어 출력해 보았습니다.

아래 코드를 추가하면 원하는 부분만 조합이 가능합니다. (파일명 제외하고 디렉토리만 : C:\Windows\)

set a=%%~di
set b=%%~pi
echo %a%%b%

반응형

댓글()

php 확장자 없이 페이지 접속 가능하게 하기

리눅스/APACHE|2021. 11. 30. 11:53
반응형

주소창에서 특정 URL 호출시 아래와 같이 파일의 확장자를 사용하지 않고

파일명 만으로 접근하게 하는 방법이 있습니다.

 

기존 접속 방식 : http://sysdocu.tistory.com/data.php

 

httpd.conf 파일을 수정하여 디렉토리 옵션에 MultiViews 를 추가합니다.

LoadModule negotiation_module modules/mod_negotiation.so // httpd 2.2 이상 버전에서 활성화 필요

<Directory /RESTAPI/html>
        Options MultiViews
        AllowOverride All
        Require all granted
</Directory>

아파치 재시작 후 아래와 같은 형태로 접근이 가능합니다.

 

 

신규 접속 방식 : http://sysdocu.tistory.com/data

 

반응형

댓글()

지원 종료된 CentOS 6 저장소 (Repository) 변경하기

리눅스/OS 일반|2021. 11. 25. 16:09
반응형

아래 파일을 열어 내용을 바꿉니다.

 

# vi /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

이제 yum 명령으로 추가 패키지 설치가 가능합니다.

 

 

반응형

댓글()

PHP 에서 json 문자열을 예쁘게 출력하려면

프로그래밍/PHP|2021. 11. 11. 15:18
반응형

아래와 같이 header 에 json 타입을 명시해주고  json 문자열을 JSON_PRETTY_PRINT 옵션을 주어 decode, encode 하면 됩니다.

 

sysdocu.php

<?
header('Content-Type: application/json');    // 필수

$data = '{ "result": "success", "data":[ { "ip": "192.168.10.2", "os": "linux" }, { "ip": "192.168.10.3", "os": "windows" } ] }';

$result = json_encode(json_decode($data), JSON_PRETTY_PRINT);

echo $result;
?>

 

결과

{
    "result": "success",
    "data": [
        {
            "ip": "192.168.10.2",
            "os": "linux"
        },
        {
            "ip": "192.168.10.3",
            "os": "windows"
        }
    ]
}

 

반응형

댓글()