반응형
이전의 연동계획 및 Oracle설치 관련글 : <Day 38 (Web Server + Oracle + Samba) (1)>
Listener 파일을 설정한다.
$ vi /app/ora12c/12c/network/admin/listener.ora
...
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = DB12)
(ORACLE_HOME = /app/ora12c/12c)
)
)
TNS명 파일을 설정한다.
$ vi /app/ora12c/12c/network/admin/tnsnames.ora
...
oracle =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.231.160)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB12.itclass.co.kr)
)
)
Listener를 시작하여 정상적으로 서버가 올라오는지 확인한다.
$ lsnrctl start
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 12-JAN-2020 13:10:25
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Starting /app/ora12c/12c/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /app/ora12c/12c/network/admin/listener.ora
Log messages written to /app/ora12c/diag/tnslsnr/NATDB/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=NATDB)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB12.itclass.co.kr)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 12-JAN-2020 13:10:27
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /app/ora12c/12c/network/admin/listener.ora
Listener Log File /app/ora12c/diag/tnslsnr/NATDB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=NATDB)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "DB12" has 1 instance(s).
Instance "DB12", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
DB 서버를 시작한다.
$ sqlplus / as sysdba@oracle
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jan 12 13:11:10 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 830472192 bytes
Fixed Size 8626144 bytes
Variable Size 629145632 bytes
Database Buffers 188743680 bytes
Redo Buffers 3956736 bytes
Database mounted.
Database opened.
SQL>
사용자가 사용할 테이블스페이스와 계정을 생성하고 권한을 부여하고 SQL서버를 종료한다.
SQL> CREATE TABLESPACE php
2 DATAFILE '/app/ora12c/oradata/DB12/php01.dbf' SIZE 100M;
Tablespace created.
SQL> CREATE USER php
2 IDENTIFIED BY php
3 TEMPORARY TABLESPACE temp
4 QUOTA UNLIMITED ON php;
User created.
SQL> GRANT connect, resource, create view to php;
Grant succeeded.
SQL> GRANT execute on dbms_crypto to php;
Grant succeeded.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
Php와 DB를 연동하여 사용하기위해 php.ini파일의 설정값을 변경한다.
# vi /usr/local/lib/php.ini
...
short_open_tag = On
...
default_charset = "EUC-KR"
...
include_path=".:/usr/local/lib"
...
upload_tmp_dir = /tmp
...
date.timezone = Asia/Seoul
...
error_reporting = E_ALL & ~E_NOTICE
...
Apache데몬 실행시 Oracle DB와 연동이 가능하게 설정값을 추가한다.
# vi /app/apache/bin/apachectl
...
# oracle setup export
ORACLE_HOSTNAME=DB12.itclass.co.kr
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_OWNER=ora12c
export ORACLE_BASE=/app/ora12c
export ORACLE_HOME=/app/ora12c/12c
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME:/usr/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=DB12
export NLS_LANG=AMERICAN_AMERICA.KO16MSWIN949
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
...
Apache데몬 실행시 Web서버에서 특정 확장자를 가진 파일을 연결 가능하도록 설정한다.
# vi /app/apache/conf/httpd.conf
...
ServerName localhost
...
AddType application/x-httpd-php .php .html .htm .inc
...
Web서버의 Index.html파일을 설정하고 Web서버에 접속하여 오라클 서버와의 연동을 확인한다.
# vi /app/apache/htdocs/index.html
<?
$server = "oracle";
$user_name = "php";
$password = "php";
$conn=@oci_connect($user_name, $password, $server) or die('Could not connect:');
echo("Oracle 12c \$conn : $conn<br>");
$st=oci_server_version($conn);
echo("$st<br>");
phpinfo();
?>
# chmod -R o+r /app/ora12c
# /app/apache/bin/apachectl stop
# /app/apache/bin/apachectl start
Web서버를 사용하면서 외부 디렉토리에 접근을 막기위해 Web서버의 DocumentRoot와 DirectoryRoot를 apache관련 directory가 아닌 Web Master 계정 내부 디렉토리로 변경한다.
# mkdir -p /home/web/httpd/html
# chown -R web.web /home/web
# chmod -R 755 /home/web
# vi /app/apache/conf/httpd.conf
...
DocumentRoot "/home/web/httpd/html"
...
<Directory "/home/web/httpd/html">
...
Samba데몬을 이용하여 Samba계정을 추가한다. Web서버 디렉토리에 접속을 쉽게 하기 위해 Samba설정 파일에 링크 허용관련 설정값을 추가한다.
# smbpasswd -a st1
New SMB password:
Retype new SMB password:
# cat /etc/samba/smb.conf
...
[global]
...
follow symlinks = yes
wide links = yes
unix extensions = no
...
Samba데몬을 이용해 Web서버에 접속할 계정의 홈 디렉토리에 Web서버 디렉토리에 연결하는 링크를 생성한다.
# ln -s /home/web/httpd/html/ html
# ll
합계 0
lrwxrwxrwx 1 root root 21 1월 12 19:51 html -> /home/web/httpd/html/
# systemctl start smb
테스트를 확인하여 접속을 확인한다.
반응형
'교육 > Server' 카테고리의 다른 글
Day 54 (DNS서버 구축) (0) | 2020.02.05 |
---|---|
Day 45 (SSH) (0) | 2020.01.21 |
Day 38 (Web Server + Oracle + Samba) (1) (0) | 2020.01.10 |
Day 24 (NFS & Multi network) (0) | 2019.12.19 |
Day 23 (SAMBA & NAT & Oracle windows) (0) | 2019.12.18 |