๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Linux

[Linux] ORA-12546: TNS:permission denied ์—๋Ÿฌ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

728x90
๋ฐ˜์‘ํ˜•

 ๐ŸŸก Apache์™€ PHP oci8, Oracle DB ์—ฐ๋™์‹œ CLI ํ™˜๊ฒฝ์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜์ง€๋งŒ ์›น ์‚ฌ์ดํŠธ์—์„œ๋Š” permission denied ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ

โค๏ธ OS : Rocky Linux 

โค๏ธ WAS : Apache

โค๏ธ DB : Oracle

 

โœ… ์ƒํ™ฉ

Apache ์„œ๋ฒ„์™€ PHP oci8, OracleDB๋ฅผ ์—ฐ๋™ํ•˜์—ฌ php query๋กœ ์ž‘์„ฑ๋œ ํŒŒ์ผ์„ ์›น ์‚ฌ์ดํŠธ์—์„œ ์‹คํ–‰ํ•ด๋ณด๋ ค๊ณ  ์‹œ๋„ํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ CLI ํ™˜๊ฒฝ์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ์ ‘์† ๋˜์—ˆ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์›น ์‚ฌ์ดํŠธ์—์„œ ์‹คํ–‰ํ•˜๋ฉด ์—๋Ÿฌ๋ฅผ ๋ฑ‰์—ˆ๋‹ค.

 

๋ฆฌ๋ˆ…์Šค์—์„œ๋Š” php ํŒŒ์ผ์ด ์ž˜ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

BUT!!!

 

์›น ํŽ˜์ด์ง€์—์„œ๋Š” ์ด๋ ‡๊ฒŒ ๋‚˜์˜จ๋‹ค,,,

 

Basic query๋Š” php manual ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ ์ž‘์„ฑํ–ˆ๋‹ค.

<?php

$conn = oci_connect('DB์ด๋ฆ„', '๋น„๋ฐ€๋ฒˆํ˜ธ', '//localhost/์„œ๋น„์Šค์ด๋ฆ„');
if(!$conn) {
   $m = oci_error();
   echo $m['message'], "\n";
   exit;
}
else {
   print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);

?>

 

 

โœ… ์›์ธ

Oracle instant client๋„ ์žฌ์„ค์น˜ํ•ด๋ณด๊ณ  ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฉด์œผ๋กœ ์›์ธ์„ ์ฐพ๊ธฐ ์œ„ํ•ด ๋…ธ๋ ฅํ–ˆ๋‹ค. ์—„์ฒญ ์‚ฝ์งˆํ•œ ๊ฒฐ๊ณผ SELiux์˜ ๋ณด์•ˆ ์„ค์ • ๋ฌธ์ œ ๋•Œ๋ฌธ์ด์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค.

 

↓↓↓ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ ์ฐธ๊ณ  ↓↓↓ 

https://ye5ni.tistory.com/168

 

CentOs7์ด๋ž‘ ์„ค์ •์ด ๋น„์Šทํ•œ Rocky Linux์—๋„ ๊ธฐ๋ณธ์ ์œผ๋กœ SELinux ๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ, ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„ค์น˜ ๋ฐ ์„ค์ • ํ›„ ๋ฌด์–ธ๊ฐ€ ์ œ๋Œ€๋กœ ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ๋Œ€๋ถ€๋ถ„ SELinux ์„ค์ • ๋•Œ๋ฌธ์ธ ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

 

 

 

โœ… ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

getsebool -P httpd_can_network_connect on

http ํ”„๋กœ์„ธ์Šค์—์„œ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ํ—ˆ์šฉ ์—ฌ๋ถ€๋ฅผ ON ํ•ด์ฃผ๋ฉด ๋œ๋‹ค!

 

์›น ํŽ˜์ด์ง€์—์„œ๋„ ์„ฑ๊ณต

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•