◇ [설치환경]

■ 릴리즈 설치 테스트 갱신 : 2017년 2월 19일


■ CentOS 7 64bit [제가포스팅한 설치이후 환경에서 작업]

■ kernel 4.9 [저는 최신 커널에서 작업합니다. 기존커널에서 작업하셔도 됩니다]

■ 일부 설정이나 경로가 다를수 있습니다. 실서버가 아닌 VMware 환경에서 작업이 이루어집니다.

 이전에 포스팅한 내용과 비슷하지만 이번에는 Apache2.4(유지), PHP7, MariaDB 10 최신버전으로 진행합니다.


웹서버 구축을 하기위해 APM [Apache, Mysql(Maria), PHP] 3개의 패키지가 설치가 되야합니다.

웹을 개발할려는 환경에따라 버전에 맞게 RPM(소스파일로 설치)하는게 좋지만 크게 영향을 받지 않는다면 일반적으로 YUM(자동설치)으로 쉽게 설치할수 있습니다. (Source 으로 설치하는건 나중에 따로 포스팅하도록 하겠습니다.)


시작합니다.


■ [APM] Apache, PHP7, MariaDB 10.1 Install(설치) Guide


1. 의존성 라이브러리 설치


□ 아래는 라이브러리가 설치되어있는지 확인해보는 부분이며 APM에 꼭 필요한 패키지가 있습니다.

BASH

[root@localhost ~]# rpm -qa libjpeg* libpng* freetype* gd-* gcc gcc-c++ gdbm-devel libtermcap-devel


libpng-1.5.13-7.el7_2.x86_64 gcc-c++-4.8.5-11.el7.x86_64 freetype-2.4.11-12.el7.x86_64 libjpeg-turbo-1.2.90-5.el7.x86_64 libpng12-1.2.50-10.el7.x86_64 gcc-4.8.5-11.el7.x86_64

□ Yum 으로 아래의 필요한 라이브러리를 한번에 전부 설치합니다. (한번에 관련된 의존성도 같이 설치가 됩니다.)

BASH

[root@localhost ~]# yum install libjpeg* libpng* freetype* gd-* gcc gcc-c++ gdbm-devel libtermcap-devel


.

.

======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: freetype-demos x86_64 2.4.11-12.el7 base 183 k freetype-devel x86_64 2.4.11-12.el7 base 356 k gd x86_64 2.0.35-26.el7 base 146 k gd-devel x86_64 2.0.35-26.el7 base 79 k gd-progs x86_64 2.0.35-26.el7 base 36 k gdbm-devel x86_64 1.10-8.el7 base 47 k libjpeg-turbo-devel x86_64 1.2.90-5.el7 base 98 k libjpeg-turbo-static x86_64 1.2.90-5.el7 base 120 k libjpeg-turbo-utils x86_64 1.2.90-5.el7 base 76 k libpng-devel x86_64 2:1.5.13-7.el7_2 base 122 k libpng-static x86_64 2:1.5.13-7.el7_2 base 92 k libpng12-devel x86_64 1.2.50-10.el7 base 111 k ncurses-devel x86_64 5.9-13.20130511.el7 base 713 k Installing for dependencies: expat-devel x86_64 2.1.0-10.el7_3 updates 57 k fontconfig-devel x86_64 2.10.95-10.el7 base 128 k libICE x86_64 1.0.9-2.el7 base 65 k libSM x86_64 1.2.2-2.el7 base 39 k libX11-devel x86_64 1.6.3-3.el7 base 980 k libXau-devel x86_64 1.0.8-2.1.el7 base 14 k libXpm x86_64 3.5.11-3.el7 base 54 k libXpm-devel x86_64 3.5.11-3.el7 base 36 k libXt x86_64 1.1.4-6.1.el7 base 173 k libxcb-devel x86_64 1.11-4.el7 base 1.1 M xorg-x11-proto-devel noarch 7.7-13.el7 base 281 k zlib-devel x86_64 1.2.7-17.el7 base 50 k Transaction Summary ======================================================================================================== Install 13 Packages (+12 Dependent packages) Total download size: 5.0 M Installed size: 14 M Is this ok [y/d/N]:y


.

.


Installed: freetype-demos.x86_64 0:2.4.11-12.el7 freetype-devel.x86_64 0:2.4.11-12.el7 gd.x86_64 0:2.0.35-26.el7 gd-devel.x86_64 0:2.0.35-26.el7 gd-progs.x86_64 0:2.0.35-26.el7 gdbm-devel.x86_64 0:1.10-8.el7 libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 libjpeg-turbo-static.x86_64 0:1.2.90-5.el7 libjpeg-turbo-utils.x86_64 0:1.2.90-5.el7 libpng-devel.x86_64 2:1.5.13-7.el7_2 libpng-static.x86_64 2:1.5.13-7.el7_2 libpng12-devel.x86_64 0:1.2.50-10.el7 ncurses-devel.x86_64 0:5.9-13.20130511.el7 Dependency Installed: expat-devel.x86_64 0:2.1.0-10.el7_3 fontconfig-devel.x86_64 0:2.10.95-10.el7 libICE.x86_64 0:1.0.9-2.el7 libSM.x86_64 0:1.2.2-2.el7 libX11-devel.x86_64 0:1.6.3-3.el7 libXau-devel.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.11-3.el7 libXpm-devel.x86_64 0:3.5.11-3.el7 libXt.x86_64 0:1.1.4-6.1.el7 libxcb-devel.x86_64 0:1.11-4.el7 xorg-x11-proto-devel.noarch 0:7.7-13.el7 zlib-devel.x86_64 0:1.2.7-17.el7 Complete!


2. [APM] Apache, PHP, MariaDB 설치 [순서는 : Apache, Maria, PHP 진행]



□ 아파치(Apache 2.4) 설치

BASH

[root@localhost ~]# yum install httpd


.

.

======================================================================================================= Package Arch Version Repository Size ======================================================================================================== Installing: httpd x86_64 2.4.6-45.el7.centos base 2.7 M Installing for dependencies: httpd-tools x86_64 2.4.6-45.el7.centos base 84 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary ======================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 2.8 M Installed size: 9.6 M Is this ok [y/d/N]: y

.

.

Installed: httpd.x86_64 0:2.4.6-45.el7.centos Dependency Installed: httpd-tools.x86_64 0:2.4.6-45.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete!


□ 마리아(Maria DB 10.1) 설치


기존의 Yum 으로 설치할경우는 Maria DB 5.5 버전이 설치가 됩니다. 

최신버전으로 설치할경우 Yum 미러경로를 직접지정해야 합니다.


배포사이트 : http://mariadb.org/

버전별 셋팅방법 : http://downloads.mariadb.org/mariadb/repositories/


먼저 Yum 저장소 생성

BASH

[root@localhost ~]# vi /etc/yum.repos.d/MariaDB.repo


# MariaDB 10.1 CentOS repository list # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1


:wq (저장)

이후 설치 진행

BASH

[root@localhost ~]# yum install MariaDB-server MariaDB-client


.

.

======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: MariaDB-client x86_64 10.1.21-1.el7.centos mariadb 39 M MariaDB-server x86_64 10.1.21-1.el7.centos mariadb 101 M MariaDB-shared x86_64 10.1.21-1.el7.centos mariadb 1.3 M replacing mariadb-libs.x86_64 1:5.5.52-1.el7 Installing for dependencies: MariaDB-common x86_64 10.1.21-1.el7.centos mariadb 43 k boost-program-options x86_64 1.53.0-26.el7 base 156 k galera x86_64 25.3.19-1.rhel7.el7.centos mariadb 8.0 M jemalloc x86_64 3.6.0-1.el7 mariadb 104 k lsof x86_64 4.87-4.el7 base 331 k perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k perl-DBI x86_64 1.627-4.el7 base 802 k perl-IO-Compress noarch 2.061-2.el7 base 260 k perl-Net-Daemon noarch 0.48-5.el7 base 51 k perl-PlRPC noarch 0.2020-14.el7 base 36 k Transaction Summary ======================================================================================================================== Install 3 Packages (+11 Dependent packages) Total download size: 151 M Is this ok [y/d/N]: y


.

.


Total 1.7 MB/s | 151 MB 00:01:28 Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Importing GPG key 0x1BB943DB: Userid : "MariaDB Package Signing Key <package-signing-key@mariadb.org>" Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Is this ok [y/N]: y


.

.


Installed: MariaDB-client.x86_64 0:10.1.21-1.el7.centos MariaDB-server.x86_64 0:10.1.21-1.el7.centos MariaDB-shared.x86_64 0:10.1.21-1.el7.centos Dependency Installed: MariaDB-common.x86_64 0:10.1.21-1.el7.centos boost-program-options.x86_64 0:1.53.0-26.el7 galera.x86_64 0:25.3.19-1.rhel7.el7.centos jemalloc.x86_64 0:3.6.0-1.el7 lsof.x86_64 0:4.87-4.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced: mariadb-libs.x86_64 1:5.5.52-1.el7 Complete!


□ PHP 7 설치


PHP 역시 기존의 Yum 으로 설치할경우는 PHP 5.4 버전이 설치가 됩니다. 

최신버전으로 설치하기위해 Webtatic EL 저장소를 추가합니다.


버전별 참고사이트  : https://webtatic.com/projects/yum-repository/


먼저 Yum 저장소 생성

BASH

[root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm


이후 설치

BASH

[root@localhost ~]# yum install php70w


.

.

======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: php70w x86_64 7.0.15-1.w7 webtatic 2.8 M Installing for dependencies: php70w-cli x86_64 7.0.15-1.w7 webtatic 2.9 M php70w-common x86_64 7.0.15-1.w7 webtatic 1.2 M Transaction Summary ======================================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 6.9 M Installed size: 27 M Is this ok [y/d/N]: y


.

.

Total 1.2 MB/s | 6.9 MB 00:00:05 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7 Importing GPG key 0x62E74CA5: Userid : "Webtatic EL7 <rpms@webtatic.com>" Fingerprint: 830d b159 6d9b 9b01 99dc 24a3 e87f d236 62e7 4ca5 Package : webtatic-release-7-3.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7

Is this ok [y/N]: y


.

.

Installed: php70w.x86_64 0:7.0.15-1.w7 Dependency Installed: php70w-cli.x86_64 0:7.0.15-1.w7 php70w-common.x86_64 0:7.0.15-1.w7 Complete!

관련 PHP7 패키지 설치 (자주 쓰이는것을 골라봤습니다.)

BASH

[root@localhost ~]# yum install php70w-mysql php70w-pdo php70w-pgsql php70w-odbc php70w-mbstring php70w-mcrypt php70w-gd [root@localhost ~]# yum install php70w-pear php70w-pdo_dblib php70w-pecl-imagick php70w-pecl-imagick-devel php70w-xml php70w-xmlrpc


.

.

======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: php70w-gd x86_64 7.0.15-1.w7 webtatic 136 k php70w-mbstring x86_64 7.0.15-1.w7 webtatic 542 k php70w-mcrypt x86_64 7.0.15-1.w7 webtatic 26 k php70w-mysql x86_64 7.0.15-1.w7 webtatic 83 k php70w-odbc x86_64 7.0.15-1.w7 webtatic 51 k php70w-pdo x86_64 7.0.15-1.w7 webtatic 91 k php70w-pdo_dblib x86_64 7.0.15-1.w7 webtatic 20 k php70w-pear noarch 1:1.10.1-1.w7 webtatic 337 k php70w-pecl-imagick x86_64 3.4.2-0.1.w7 webtatic 128 k php70w-pecl-imagick-devel x86_64 3.4.2-0.1.w7 webtatic 5.0 k php70w-pgsql x86_64 7.0.15-1.w7 webtatic 89 k php70w-xml x86_64 7.0.15-1.w7 webtatic 129 k php70w-xmlrpc x86_64 7.0.15-1.w7 webtatic 48 k Installing for dependencies: ImageMagick x86_64 6.7.8.9-15.el7_2 base 2.1 M OpenEXR-libs x86_64 1.7.1-7.el7 base 217 k freetds x86_64 0.95.81-1.el7 epel 635 k ghostscript x86_64 9.07-20.el7_3.1 updates 4.3 M ghostscript-fonts noarch 5.50-32.el7 base 324 k ilmbase x86_64 1.0.3-7.el7 base 100 k lcms2 x86_64 2.6-3.el7 base 150 k libXfont x86_64 1.5.1-2.el7 base 150 k libfontenc x86_64 1.1.2-3.el7 base 30 k libmcrypt x86_64 2.5.8-13.el7 epel 99 k librsvg2 x86_64 2.39.0-1.el7 base 123 k libtool-ltdl x86_64 2.4.2-21.el7_2 base 49 k libwmf-lite x86_64 0.2.8.4-41.el7_1 base 66 k libxslt x86_64 1.1.28-5.el7 base 242 k pcre-devel x86_64 8.32-15.el7_2.1 base 479 k php70w-devel x86_64 7.0.15-1.w7 webtatic 2.5 M php70w-process x86_64 7.0.15-1.w7 webtatic 41 k poppler-data noarch 0.4.6-3.el7 base 2.2 M postgresql-libs x86_64 9.2.18-1.el7 base 232 k unixODBC x86_64 2.3.1-11.el7 base 413 k urw-fonts noarch 2.4-16.el7 base 3.0 M xorg-x11-font-utils x86_64 1:7.5-20.el7 base 87 k Transaction Summary ======================================================================================================================== Install 13 Packages (+22 Dependent packages) Total download size: 19 M Installed size: 73 M Is this ok [y/d/N]: y


.

.

Total 3.8 MB/s | 19 MB 00:00:05 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Importing GPG key 0x352C64E5: Userid : "Fedora EPEL (7) <epel@fedoraproject.org>" Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5 Package : epel-release-7-9.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Is this ok [y/N]: y


.

.

Installed: php70w-gd.x86_64 0:7.0.15-1.w7 php70w-mbstring.x86_64 0:7.0.15-1.w7 php70w-mcrypt.x86_64 0:7.0.15-1.w7 php70w-mysql.x86_64 0:7.0.15-1.w7 php70w-odbc.x86_64 0:7.0.15-1.w7 php70w-pdo.x86_64 0:7.0.15-1.w7 php70w-pdo_dblib.x86_64 0:7.0.15-1.w7 php70w-pear.noarch 1:1.10.1-1.w7 php70w-pecl-imagick.x86_64 0:3.4.2-0.1.w7 php70w-pecl-imagick-devel.x86_64 0:3.4.2-0.1.w7 php70w-pgsql.x86_64 0:7.0.15-1.w7 php70w-xml.x86_64 0:7.0.15-1.w7 php70w-xmlrpc.x86_64 0:7.0.15-1.w7 Dependency Installed: ImageMagick.x86_64 0:6.7.8.9-15.el7_2 OpenEXR-libs.x86_64 0:1.7.1-7.el7 freetds.x86_64 0:0.95.81-1.el7 ghostscript.x86_64 0:9.07-20.el7_3.1 ghostscript-fonts.noarch 0:5.50-32.el7 ilmbase.x86_64 0:1.0.3-7.el7 lcms2.x86_64 0:2.6-3.el7 libXfont.x86_64 0:1.5.1-2.el7 libfontenc.x86_64 0:1.1.2-3.el7 libmcrypt.x86_64 0:2.5.8-13.el7 librsvg2.x86_64 0:2.39.0-1.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2 libwmf-lite.x86_64 0:0.2.8.4-41.el7_1 libxslt.x86_64 0:1.1.28-5.el7 pcre-devel.x86_64 0:8.32-15.el7_2.1 php70w-devel.x86_64 0:7.0.15-1.w7 php70w-process.x86_64 0:7.0.15-1.w7 poppler-data.noarch 0:0.4.6-3.el7 postgresql-libs.x86_64 0:9.2.18-1.el7 unixODBC.x86_64 0:2.3.1-11.el7 urw-fonts.noarch 0:2.4-16.el7 xorg-x11-font-utils.x86_64 1:7.5-20.el7 Complete!

[참고사항]

다음 명령어로 php7 관련 패키지 설치할수 있는 리스트들을 확인할수 있습니다. 

위 설치외에 필요한 패키지가 있다면 추가로 설치하면 됩니다.

BASH

[root@localhost ~]# yum search php70w


.

.

================================================= N/S matched: php70w ================================================== php70w.x86_64 : PHP scripting language for creating dynamic web sites php70w-bcmath.x86_64 : A module for PHP applications for using the bcmath library php70w-cli.x86_64 : Command-line interface for PHP php70w-common.x86_64 : Common files for PHP php70w-dba.x86_64 : A database abstraction layer module for PHP applications

.

.

php70w-tidy.x86_64 : Standard PHP module provides tidy library support php70w-xml.x86_64 : A module for PHP applications which use XML php70w-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol Name and summary matches only, use "search all" for everything.


□ 설치 확인 및 버전확인

BASH

root@localhost ~]# httpd -v


Server version: Apache/2.4.6 (CentOS) Server built: Nov 14 2016 18:04:44

BASH

[root@localhost ~]# php -v


PHP 7.0.15 (cli) (built: Jan 19 2017 21:35:05) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

BASH

root@localhost ~]# mysql -V


mysql Ver 15.1 Distrib 10.1.21-MariaDB, for Linux (x86_64) using readline 5.1


아래부터는 설정 동일합니다.

■ [APM] Apache, PHP, MariaDB config(설정) 및 구동

1. 아파치(Apache) 설정 및 구동


□ 기본설정

BASH

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf


.

.

62 # User/Group: The name (or #number) of the user/group to run httpd as. 63 # It is usually good practice to create a dedicated user and group for 64 # running httpd, as with most system services. 65 # 66 User nobody (apache → nobody 변경) 67 Group nobody (apache → nobody 변경)

.

.

93 # If your host doesn't have a registered DNS name, enter its IP address here. 94 # 95 #ServerName www.example.com:80

96 ServerName 192.168.122.128:80 (도메인 또는 해당서버 IP 입력 추가)

.

.


:wq (저장)

[참고]


■ apache → nobody 변경

ROOT 권한으로 실행된 아파치의 하위 프로세스를 이곳에서 지정한 사용자로 실행한다는 의미, 

기본값으로 apache 또는 daemon 으로 되어있지만 대부분 nobody로 변경하여 이용한다. 약간 보안적인 의미를 포함


■ ServerName

자기 서버가 이 도메인을 사용한다는것을 알리기 위한 수단, 예를 들어

ServerName www.test.com:80 → 홈페이지 접속시 해당 도메인(http://www.test.com)으로 연결

ServerName 192.168.122.128:80 → 홈페이지 접속시 해당 도메인((http://192.168.122.128)으로 연결 (도메인이 없을경우 IP 입력)


■ IP는 자기서버 IP 셋팅

[root@localhost ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.223.129 (이부분)  netmask 255.255.255.0  broadcast 192.168.223.255



□ 방화벽 설정


환경설정이 완료가 되었으니 웹을 열기위해선 방화벽 80번 포트를 오픈해야합니다.

BASH

[root@localhost ~]# vi /etc/sysconfig/iptables


# sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT (추가) -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT



:wq (저장)

[참고]


■ iptables 에서 순서는 매우 중요합니다. 일반적으로 적용되는 순서는 위에서부터 아래로 순차적으로 읽어옵니다.

예를들어 추가한 맨 아래의 라인쪽에 추가를 하게되면 적용이 정상적으로 안됩니다. 이해가 안되실경우는 스크린샷 그대로 따라진행해주세요. 나중에 별도로 iptables 설명을 하도록 하겠습니다.



□ 방화벽 재시작

BASH

[root@localhost ~]# service iptables restart

Redirecting to /bin/systemctl restart iptables.service

□ 적용 확인

BASH

[root@localhost ~]# iptables -nL


Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 (확인완료) REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination

□ 아파치 시작

BASH

[root@localhost ~]# systemctl start httpd


부팅후 자동 실행 설정

[root@localhost ~]# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.


팅후 자동 실행 설정(해제)

[root@localhost ~]# systemctl disable httpd Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.


Service 명령어 이용 가능

[root@localhost ~]# service httpd start(stop)

□ 아파치 구동 확인

BASH

[root@localhost ~]# ps -ef |grep httpd


root 17652 1 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 17654 17652 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 17655 17652 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 17656 17652 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 17657 17652 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 17658 17652 0 13:46 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND root 17715 2983 0 13:51 pts/1 00:00:00 grep --color=auto httpd

□ 실제 웹 구동 테스트 확인



2. PHP 환경설정 및 구동(경로)


□ 기본설정

BASH

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

.

.

161 # DirectoryIndex: sets the file that Apache will serve if a directory 162 # is requested. 163 # 164 <IfModule dir_module> 165 DirectoryIndex index.html index.htm index.php (추가) 166 </IfModule>

.

.

270 # AddType allows you to add to or override the MIME configuration 271 # file specified in TypesConfig for specific file types. 272 # 273 #AddType application/x-gzip .tgz 274 AddType application/x-httpd-php .php .html .htm .inc (추가)

275 AddType application/x-httpd-php-source .phps (추가)


:wq (저장)

[참고]


■ 실제 PHP환경설정을 관리하는 파일은 아래의 경로입니다.

[root@localhost ~]# vi /etc/php.ini


위 httpd.conf 쪽에 셋팅하는건 아파치에 php 관련 처리를 할수 있게 추가를 하는 부분입니다. 

php.ini 파일설정은 사용할려는 웹환경에 맞게튜닝을 해야하지만 현재는 기본셋팅으로 갑니다. 나중에 따로 설명하도록 하겠습니다.



□ PHP 적용


Yum 설치시 html 업로드 기본 디렉토리는 아래와 같습니다.

BASH

[root@localhost ~]# cd /var/www/html/



해당 경로에서 PHP의 정보를 보여주는 함수의 파일을 하나 생성합니다.

BASH

[root@localhost html]# vi /var/www/html/phpinfo.php


<?php phpinfo(); ?> :wq (저장) [root@localhost html]# ls (파일생성 확인) phpinfo.php

PHP 환경설정을 적용하기위해 아파치(Apache)도 한번 재시작을 합니다.

BASH

[root@localhost html]# service httpd restart

Redirecting to /bin/systemctl restart httpd.service

항상 아파치(Apache) 구동이 제대로 되고 있는지 확인합니다.

BASH

[root@localhost html]# ps -ef | grep httpd


root 18135 1 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 18137 18135 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 18138 18135 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 18139 18135 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 18140 18135 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 18141 18135 0 16:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND root 18143 2983 0 16:58 pts/1 00:00:00 grep --color=auto httpd

□ PHP 적용 확인 테스트


개인 PC에서 인터넷창에 접속 테스트를 진행하면 됩니다.

이전 경로에 생성하였던 경로를 입렵합니다. URL : http://192.168.223.129/phpinfo.php



3. Maria DB 구동 및 설정


□ Maria DB 구동 및 구동 확인

BASH

[root@localhost ~]# systemctl start mariadb


[root@localhost ~]# ps -ef | grep mysql mysql 41093 1 1 19:48 ? 00:00:00 /usr/sbin/mysqld root 41130 11663 0 19:49 pts/1 00:00:00 grep --color=auto mysql

□ Maria DB 기본설정 (DB가 구동된 상태에서 진행가능)

BASH

[root@localhost ~]# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): 패스워드가 없기때문에 엔터


OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y (DB ROOT 패스워드 설정) New password: 패스워드입력 Re-enter new password: 재확인 패스워드입력 Password updated successfully! Reloading privilege tables.. ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y (익명의 접근을 막을것인지? 보안을 위해 Y 엔터) ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y (DB ROOT 원격을 막을것인지? 보안을 위해 Y 엔터)

... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y (Test 용으로 생성된 데이터베이스를 삭제할것인가? Y 엔터)

- Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately.


Reload privilege tables now? [Y/n] Y (현재 설정한 값을 적용할것인지? 당연히 Y 엔터)

... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! (끝)

□ Maria DB 최종 접속 확인

BASH

[root@localhost ~]# mysql -u root -p Enter password: 패스워드 입력


Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.1.21-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

[참고]


Maria(Mysql) 환경설정을 관리하는 파일은 아래의 경로입니다.

[root@localhost ~]# vi /etc/my.cnf


my.cnf 파일설정은 사용할려는 DB환경에 맞게 튜닝을 해야하지만 현재는 기본셋팅으로 갑니다. 나중에 따로 설명하도록 하겠습니다.



이상 위에 순서대로 웹구축만하여도 웹서버를 구동하는데에는 크게 문제가 없습니다. 만약 직접 웹홈페이지 개발을 한다면 충분히 연습할수 있는 공간을 만들수 있을것으로 보입니다.



※ 출처 : http://aeac.tistory.com/21


'프로그래밍 > linux' 카테고리의 다른 글

CentOS SELinux 설정 및 해제하기  (0) 2018.03.08
Linux Apache - 가상호스트설정(Apache virtual host)  (1) 2018.03.08
SVN 명령어  (0) 2018.03.02
용량확인  (0) 2018.03.02
netstat 옵션  (0) 2018.03.02

+ Recent posts