web server, was server, db server를 Azure Public Cloud를 이용해 빠르고 쉽게 구축과 부하분산을 하려고 한다.
$ yum install -y httpd
$ firewall-cmd --permanent --add-service=http
$ firewall-cmd --reload
$ systemctl enable httpd
$ systemctl start httpd
포트번호는 nsg에도 동일하게 적용
/var/www/html 에 문서를 작성
ex) locathost/test.html
$ yum install -y tomcat*
http://www.oracle.com/technetwork/java/javase/downloads/index.html
PC로 오라클 웹사이트 접속 후 jdk rpm 다운로드 링크 주소 복사
was 서버에 jdk 다운로드
$ wget -c 다운로드링크주소
.rpm으로 끝나게 파일명 수정
$ mv jdk-8u131-linux-x64.rpm\?AuthParam\=1495957368_916432334b6dc573 jdk-8u131-linux-x64.rpm
rpm 명령어로 설치 진행
i : 설치, v : 정보뷰, h : hash 표기
$ rpm -ivh jdk-8u131-linux-x64.rpm
자바 선택
$ alternatives --config java
ajp 프로토콜의 포트번호 : 8009
$ firewall-cmd --permanent --add-port=8009/tcp
$ firewall-cmd --reload
$ systemctl enable tomcat
$ systemctl start tomcat
포트번호는 nsg에도 동일하게 적용
$ curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
$ yum install -y MariaDB-server
방화벽 설정 및 시작
$ firewall-cmd --permanent --add-port=3306/tcp
$ firewall-cmd --reload
$ systemctl enable mariadb
$ systemctl start mariadb
$ mysql_secure_installation
포트번호는 nsg에도 동일하게 적용
$ mysqladmin -u root password '1234'
$ mysql -u root -p
grant select, insert, update, delete, create on test.* to 'testuser'@'localhost' identified by '1234';
grant select, insert, update, delete, create on test.* to 'testuser'@'%' identified by '1234';
flush privileges;
quit;
$ mysql -u testuser -p
connect test;
create table test(name varchar(30));
insert into test values('MariaDB Database');
insert into test values('sunguru');
commit;
quit;
$ yum install gcc gcc-c++ httpd-devel
http://tomcat.apache.org/download-connectors.cgi
PC로 접속 후 JK 1.2.46 Source Release tar.gz 다운로드 링크 주소 복사
apache 서버에 jk 다운로드
$ wget -c 다운로드링크주소
$ tar zxvf tomcat-connector*
$ cd tomcat-connector*/native
$ ./configure --with-apxs=/usr/bin/apxs
$ make
$ make install
$ chcon -u system_u -r object_r -t httpd_modules_t /etc/httpd/modules/mod_jk.so
$ vi /etc/httpd/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkShmFile run/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%y %m %d %H:%M:%S] "
JkMount /* ajp13
$ vi /etc/httpd/conf/workers.properties
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host={hostIP}
worker.ajp13.type=ajp13
$ yum install -y mysql-connector-java
$ cp /usr/share/java/mysql-connector-java.jar /usr/share/tomcat/lib
$ systemctl restart tomcat
$ cd /usr/share/tomcat/webapps/ROOT/
$ vi test.jsp
<html> <body> <%@ page contentType="text/html" language="java" %> <%@ page import="java.sql.*" %> <% Connection con = null; PreparedStatement PS = null; ResultSet RS = null; try { String MARIADB_SERVER = "10.1.2.4:3306"; String MARIADB_SERVER_USERNAME = "testuser"; String MARIADB_SERVER_PASSWORD = "1234"; String MARIADB_DATABASE = "test"; String URL = "jdbc:mysql://" + MARIADB_SERVER + "/" + MARIADB_DATABASE; Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(URL, MARIADB_SERVER_USERNAME, MARIADB_SERVER_PASSWORD); %> <% String query = "select * from test"; PS = con.prepareStatement(query); RS = PS.executeQuery(); int count=0; while(RS.next()) { String name = RS.getString("name"); %> <p>Name : <%=name%></p> <% count++; } } catch(Exception ErrMsg) { ErrMsg.printStackTrace(); out.println("Unfortunately, Database connection failed"); } %> </body> </html>
vi /etc/sysconfig/selinux
https://wikidocs.net/16274
http://blog.naver.com/PostView.nhn?blogId=sunguru&logNo=220935388261