가. test.com 으로 접속한 것을 www.test.com 으로 리다이렉션하기


1. test.com 도메인 루트에 .htaccess 파일 생성하기


[root@localhost www.test.com]# vi .htaccess


파일 내용은 아래와 같다.


RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.kimhae.com$ [NC]

RewriteRule ^(.*)$ http://www.kimhae.com/$1 [L,R=301]

~                                                       



저장하고 빠져나온다.



2. httpd.conf 설정


 아래 부분에서 AllowOverride None 으로 되어 있는 것을 All 로 변경해 준다.


<Directory "/home/*">

    #

    # Possible values for the Options directive are "None", "All",

    # or any combination of:

    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

    #

    # Note that "MultiViews" must be named *explicitly* --- "Options All"

    # doesn't give it to you.

    #

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/2.2/mod/core.html#options

    # for more information.

    #

    Options Indexes FollowSymLinks


    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #

    AllowOverride All


    #

    # Controls who can get stuff from this server.

    #

    Order allow,deny

    Allow from all


</Directory>



저장하고 나온다.


아파치 재시작


test.com 으로 접속하면 url이 즉시 www.test.com 으로 바뀌는 것을 확인할 수 있다.





나. 반대로 www.test.com 을 test.com 으로 리다이렉션 시킬 경우는 아래와 같이


RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.test\.com$

RewriteRule ^/?$ "http\:\/\/test\.com\/" [R=301,L]

~                                                       




다. 특정 경로로 리다이렉션 하기


test.com 으로 접속하면 www.test.com/test.php 로 접속하기


RewriteEngine On

RewriteCond %{HTTP_HOST} ^test.com$

RewriteRule ^$ "http://www.test.com/test.php [L,R=301]

~                                                       





라. 다른 도메인으로 리다이렉션하기


test.com 을 www.test2.net 으로


RewriteEngine On

RewriteCond %{HTTP_HOST} !test.com$ [NC]

RewriteRule ^(.*)$ http://www.test2.net/$1 [L,R=301]

~                                                       






끝.








'Linux' 카테고리의 다른 글

top load average  (0) 2016.02.15
CentOS 7 SVN iptables  (0) 2016.01.29
Linux NFS iptables  (0) 2016.01.19
CentOS 7 아파치 2.4.6 한글깨짐 AddDefaultCharset  (0) 2016.01.15
CentOS 7 apache virtualhost  (2) 2016.01.15
블로그 이미지

엘로드넷

,

Linux NFS iptables

Linux 2016. 1. 19. 19:07

NFS Server : 192.168.0.1

NFS Client : 192.168.0.2

NFS Folder : /home/user/session






1. Server (192.168.0.1)


/etc/sysconfig/nfs 파일 수정


#vi /etc/sysconfig/nfs


LOCKD_TCPPORT=32803

# UDP port rpc.lockd should listen on.

LOCKD_UDPPORT=32769


MOUNTD_PORT=892




Server 공유폴더 지정


# vi /etc/exports 


/home/user/session 192.168.0.2(rw,sync,no_root_squash)



nfs시작


# service rpcbind start

# service nfs start




iptables



iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0.0/24 -p udp -m multiport --dport 10053,111,2049,32769,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT


iptables -A INPUT -s 192.168.0 0/24 -d 192.168.0 0/24 -p tcp -m multiport --dport 10053,111,2049,32803,875,892 -m state --state NEW,ESTABLISHED -j ACCEPT









2. Client (192.168.0.2)


/etc/sysconfig/nfs파일 수정


vi /etc/sysconfig/nfs


LOCKD_TCPPORT=32803

# UDP port rpc.lockd should listen on.

LOCKD_UDPPORT=32769


MOUNTD_PORT=892



iptables


iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0 0/24 -p udp -m multiport --sport 10053,111,2049,32769,875,892,32769 -m state --state NEW,ESTABLISHED -j ACCEPT


iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0 0/24 -p tcp -m multiport --sport 10053,111,2049,32803,875,892,32803 -m state --state NEW,ESTABLISHED -j ACCEPT




nfs시작


# service rpcbind start

# service nfs strt





NFS폴더 마움트


# mount -t nfs 192.168.0.1:/home/user/session /home/user/session





NFS 마운트 해제

# umount /home/user/session



NFS 마운트 강제 해제


# umount -f -l /home/user/session








블로그 이미지

엘로드넷

,

httpd 2.4.6 에서 기본 문자셋이 UTF-8 이어서 euc_kr 로 제작된 html에서 한글이 깨진다.


1. httpd.conf 에서 기본을 EUC-KR 으로 변경하고 utf8을 추가해 주기로 한다.



아래와 같이 


AddDefaultCharset EUC-KR

AddCharset UTF-8 .utf8






2. 아파치를 재시작한다.



[root@localhost httpd]# systemctl restart httpd.service





끝.

'Linux' 카테고리의 다른 글

아파치 리다이렉션 apache url redirection www .htaccess rewrite httpd.conf  (0) 2016.01.25
Linux NFS iptables  (0) 2016.01.19
CentOS 7 apache virtualhost  (2) 2016.01.15
CentOS 7 iptables 설정  (1) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
블로그 이미지

엘로드넷

,

CentOS 7 apache virtualhost

Linux 2016. 1. 15. 20:03


1. 가상호스트 설정파일을 만든다


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



파일 내용은 아래와 같다.



<VirtualHost *:80>


        DocumentRoot /home/testuser/a.test.com

        ServerName a.test.com

        ServerAlias a.test.com

        ErrorLog /var/log/httpd/a.test.com_error.log

        CustomLog /var/log/httpd/a.test.com_access.log combined


</VirtualHost>




2. userdir.conf 에서 testuser 폴더 권한을 지정해 준다.


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



내용 끝에 아래와 같이 추가해 준다.


#

# UserDir: The name of the directory that is appended onto a user's home

# directory if a ~user request is received.

#

# The path to the end user account 'public_html' directory must be

# accessible to the webserver userid.  This usually means that ~userid

# must have permissions of 711, ~userid/public_html must have permissions

# of 755, and documents contained therein must be world-readable.

# Otherwise, the client will only receive a "403 Forbidden" message.

#

<IfModule mod_userdir.c>

    #

    # UserDir is disabled by default since it can confirm the presence

    # of a username on the system (depending on home directory

    # permissions).

    #

    UserDir disabled


    #

    # To enable requests to /~user/ to serve the user's public_html

    # directory, remove the "UserDir disabled" line above, and uncomment

    # the following line instead:

    #

    #UserDir public_html

</IfModule>


#

# Control access to UserDir directories.  The following is an example

# for a site where these directories are restricted to read-only.

#

<Directory "/home/*/public_html">

    AllowOverride FileInfo AuthConfig Limit Indexes

    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

    Require method GET POST OPTIONS

</Directory>


<Directory "/home/testuser/*">

        Require all granted

</Directory>

"/etc/httpd/conf.d/userdir.conf" 38L, 1307C




3. 아파치를 재시작한다.


[root@localhost conf.d]# systemctl restart httpd.service





끝.




'Linux' 카테고리의 다른 글

Linux NFS iptables  (0) 2016.01.19
CentOS 7 아파치 2.4.6 한글깨짐 AddDefaultCharset  (0) 2016.01.15
CentOS 7 iptables 설정  (1) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
CentOS 7 MySQL-5.7.10 설치 boost  (0) 2016.01.11
블로그 이미지

엘로드넷

,

CentOS 7 iptables 설정

Linux 2016. 1. 15. 13:00

우선 방화벽을 중지한다.

[root@localhost log]# systemctl stop firewalld     

[root@localhost log]# systemctl mask firewalld       



iptables관련 패키지를 설치(업데이트)한다.

[root@localhost log]# yum install iptables-service    



부팅시 시작되도록 한다.

[root@localhost log]# systemctl enable iptables     



iptables 설정파일은 /etc/sysconfig/iptables 이다.


해당 파일을 편집한다.


1. 특정 IP 또는 IP블럭을 거부하고자 할 때,


-A INPUT -s 177.91.82.23 -j DROP

-A INPUT -s 177.91.82.0/24 -j DROP


와 같은 형태로 추가해 준다.



2. 특정 포는 특정 IP 또는 IP블럭에게만 허가하기


-A INPUT -s 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT





iptables 상태확인


[root@localhost log]# systemctl status iptables

iptables.service - IPv4 firewall with iptables

   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)

   Active: active (exited) since 수 2016-01-13 11:31:40 KST; 1 day 23h ago

  Process: 31836 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)

  Process: 31903 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)

 Main PID: 31903 (code=exited, status=0/SUCCESS)

   CGroup: /system.slice/iptables.service


 1월 13 11:31:40 localhost.localdomain systemd[1]: Starting IPv4 firewall with iptables...

 1월 13 11:31:40 localhost.localdomain iptables.init[31903]: iptables: Applying firewall rules: [  OK  ]

 1월 13 11:31:40 localhost.localdomain systemd[1]: Started IPv4 firewall with iptables.



iptables 재시작


[root@localhost log]# systemctl restart iptables











'Linux' 카테고리의 다른 글

CentOS 7 아파치 2.4.6 한글깨짐 AddDefaultCharset  (0) 2016.01.15
CentOS 7 apache virtualhost  (2) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
CentOS 7 MySQL-5.7.10 설치 boost  (0) 2016.01.11
CentOS 7 network prefix  (0) 2015.12.04
블로그 이미지

엘로드넷

,

php5.6.x대로 올라가면서 소스컴파일시 libmysqlclient_r 관련 에러가 나고 설치가 잘 되지 않는다.

이유인즉 더 이상 번들로 제공되지 않는다는 것인데...


php7로도 시도해 봤지만 결과는 마찬가지다.



결론적으로 yum 을 이용한 설치로 진행하고자 한다.



설치순서는 MySQL5(MariaDB5) > Apache > PHP 이다.


yum으로 MySQL대신에 MariaDB를 설치하기로 한다. MySQL과 명령어는 동일하니깐..



1. mariadb


설치되는 버전은 5.5.44 이다.


[root@Cent7_64B ~]# yum -y install mariadb-server mariadb

[root@Cent7_64B ~]# systemctl start mariadb.service

[root@Cent7_64B ~]# systemctl enable mariadb.service


설치가 되었고 데몬도 시작하였다.


기본 디비와 루트비번을 설정한다.


[root@Cent7_64B ~]# mysql_secure_installation



root 비번 설정 후, 모두 엔터키로 넘어간다.


mariadb 설치 끝


root로 접속되는지 확인해 본다.


[root@Cent7_64B ~]# mysql -u root -p mysql

Enter password: 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 5.5.44-MariaDB MariaDB Server


Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [mysql]> 



접속이 된다.




2. Httpd (Apache) 


설치되는 버전은 2.4.6 이다.



[root@Cent7_64B ~]# yum -y install httpd

[root@Cent7_64B ~]# systemctl start httpd.service

[root@Cent7_64B ~]# systemctl enable httpd.service


방화벽 등록

[root@Cent7_64B ~]# firewall-cmd --permanent --zone=public --add-service=http

[root@Cent7_64B ~]# firewall-cmd --permanent --zone=public --add-service=https



직접 zone파일을 수정해도 된다.

[root@Cent7_64B zones]# vi /etc/firewalld/zones/public.xml



등록되어 있는지 확인해 보자.


아래는 public.xml 내용이다.


<?xml version="1.0" encoding="utf-8"?>

<zone>

  <short>Public</short>

  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>

  <service name="dhcpv6-client"/>

  <service name="http"/>

  <service name="ssh"/>

  <service name="https"/>

  <port protocol="tcp" port="3306"/>

</zone>



service에 http와 https가 등록되어 있다.


방화벽을 재시작하여 적용한다.


[root@Cent7_64B zones]# firewall-cmd --reload



브라우저에서 접속해 본다.


아래와 같은 화면이 뜨면 된다.






Document Root 는 /var/www/html 이다.

httpd.conf 파일 위치는 /etc/httpd/conf/httpd.conf 이다.





3. PHP설치


설치되는 버전은 5.4.16 이다.


[root@Cent7_64B conf.d]# yum -y install php



설치 후 아파치를 재시작하면 적용된다.


[root@Cent7_64B conf.d]# systemctl restart httpd.service



phpinfo();  로 확인해 본다.







밑으로 쭉 내려서 모듈들이 설치되었는지 확인해 본다.


iconv, json, libxml, mbstring, mysql, openssl 등등



참고로 설치할 수 있는 php관련 모듈을 검색해 본다.

[root@Cent7_64B conf.d]# yum search php                                                                        

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.daumkakao.com

 * epel: mirror.premi.st

 * extras: ftp.daumkakao.com

 * updates: ftp.daumkakao.com

 * webtatic: sp.repo.webtatic.com

================================================================================= N/S matched: php ==================================================================================

geos-php.x86_64 : PHP modules for GEOS

graphviz-php.x86_64 : PHP extension for graphviz

nntpgrab-php.x86_64 : PHP module which allows PHP scripts to communicate with NNTPGrab

php.x86_64 : PHP scripting language for creating dynamic web sites

php-Assetic.noarch : Asset Management for PHP

php-EasyRdf.noarch : A PHP library designed to make it easy to consume and produce RDF

php-EasyRdf-doc.noarch : Documentation for php-EasyRdf

php-Faker.noarch : A PHP library that generates fake data

php-JsonSchema.noarch : PHP implementation of JSON schema

php-Metadata.noarch : A library for class/method/property metadata management in PHP

php-PHPMailer.noarch : PHP email transport class with a lot of features

php-PHPParser.noarch : A PHP parser written in PHP


엄청 많다..



필요한 것들이 설치가 안되어 있으므로 한꺼번에 설치한다.


[root@Cent7_64B conf.d]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel



설치 후 아파치를 재시작한뒤 phpinfo를 확인해 보면 관련 모듈들이 설치되어 있을 것이다.




그동안 소스 설치로 많은 시간이 들었다면 이제는 yum으로 간편하게 설치하자.



끝.


'Linux' 카테고리의 다른 글

CentOS 7 apache virtualhost  (2) 2016.01.15
CentOS 7 iptables 설정  (1) 2016.01.15
CentOS 7 MySQL-5.7.10 설치 boost  (0) 2016.01.11
CentOS 7 network prefix  (0) 2015.12.04
리눅스 NFS설정  (0) 2015.09.25
블로그 이미지

엘로드넷

,




MySQL-5.7.10 설치


1. cmake  가 필요하므로 설치한다



[root@localhost src]# yum -y install cmake






2. boot가 필요하므로 설치한다.


[root@localhost src]# wget http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz




압축을 푼다


[root@localhost src]# tar xvfz boost_1_60_0.tar.gz




소스디렉토리로 가서 


bootstrap.sh을 실행한다


[root@localhost boost_1_60_0]#./bootstrap.sh




boost가 설치된 경로를 확인해 본다.


[root@localhost boost_1_60_0]#whereis boost

/usr/include/boost







3. MySQL5.7.10 을 다운받는다.

다운받을 파일 mysql-5.7.10.tar.gz


압축을 푼다.


[root@localhost src]# tar xvfz mysql-5.7.10.tar.gz





4. 소스 디렉토리로 간다.


[root@localhost src]# cd mysql-5.7.10




cmake configure시 아까 확인한 boost경로를 아래와 같이 설정해 준다.


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 -DMYSQL_TCP_PORT=3306 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/include/boost


컴파일 한다.


[root@localhost mysql-5.7.10]# make


중략



[ 34%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/trx/trx0rseg.cc.o

[ 34%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/trx/trx0sys.cc.o

[ 34%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/trx/trx0trx.cc.o

[ 34%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/trx/trx0undo.cc.o



중략







[root@localhost mysql-5.7.10]# make install




초기 데이타베이스 설치 



[root@localhost client]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data




데몬 구동


[root@localhost client]# /usr/local/mysql/bin/mysqld_safe --user=mysql &




끝.









'Linux' 카테고리의 다른 글

CentOS 7 iptables 설정  (1) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
CentOS 7 network prefix  (0) 2015.12.04
리눅스 NFS설정  (0) 2015.09.25
CentOS 7 apm 소스설치, 방화벽 적용  (4) 2015.07.23
블로그 이미지

엘로드넷

,

CentOS 7 network prefix

Linux 2015. 12. 4. 18:44

network 설정방법이 좀 달라졌음


[root@localhost network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-enp6s0



랜카드명이 eth0 에서 enp6s0 처럼 변경되었음. 



고정ip설정시 netmask 설정은 NETMASK, PREFIX 중에 하나만 사용해야 함. 

두 개 다 지정해 놓을 경우 PREFIX가 우선함


NETMASK = 255.255.255.224

PREFIX = 27


와 


PREFIX = 27

NETMASK = 255.255.255.224


는 동일하게 PREFIX값이 우선함


PREFIX 값을 주석처리하거나 삭제함



-----



서브넷 클래스에 따른 NETMASK / PREFIX 값 (둘 중 하나만 사용)


NETMASK = 255.255.255.0

PREFIX = 24

호스트범위 : 1~254



NETMASK = 255.255.255.128

PREFIX = 25

호스트범위 : 1~126



NETMASK = 255.255.255.192

PREFIX = 26

호스트범위 : 1~62



NETMASK = 255.255.255.224

PREFIX = 27

호스트범위 : 33~62



NETMASK = 255.255.255.240

PREFIX = 28

호스트범위 : 49~62



NETMASK = 255.255.255.248

PREFIX = 29

호스트범위 : 49~54



NETMASK = 255.255.255.252

PREFIX = 30

호스트범위 : 53~54











블로그 이미지

엘로드넷

,

리눅스 NFS설정

Linux 2015. 9. 25. 18:02

서버1 : 192.168.0.1 (공유해 주는 서버)

서버2 : 192.168.0.2 (공유 받을 서버)



1. 서버1에서 설정


공유해줄 폴더명 : /home/userid/testfolder


# vi /etc/exports 


/home/userid/testfolder/ 192.168.0.2(rw,sync,no_root_squash)

 


공유해줄 폴더가 여러개인 경우 밑에 줄에 같은 방식으로 입력해 주면 된다.


저장하고 빠져나온다.



NFS 을 재시작한다.

#/etc/init.d/nfs restart



2. 서버2에서 설정


공유폴더 만들기 :

# mkdir /home/userid/testfolder



마운트 하기

# mount -t nfs 192.168.0.1:/home/userid/testfolder /home/userid/testfolder




끝.




블로그 이미지

엘로드넷

,

설치할 것들 :


httpd-2.4.16

php-5.6.11

mysql-5.6.25




[아파치 설치]

1. 아파치 파일을 다운 받는다.

#cd /usr/local/src

#wget http://mirror.apache-kr.org/httpd/httpd-2.4.16.tar.gz



2. 압축을 푼다.

#tar xvfz httpd-2.4.16.tar.gz


3. /usr/local/apache2 에 설치를 할 것이다.

#cd httpd-2.4.16

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


아래와 같은 에러가 발생함.


checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure: 

configure: Configuring Apache Portable Runtime library...

configure: 

checking for APR... no

configure: error: APR not found.  Please read the documentation.


APR이 없다고 하므로 설치한다.


4. apr 설치 (apr : apache portable runtime)

#wget http://mirror.apache-kr.org/apr/apr-1.5.2.tar.gz

#tar xvfz apr-1.5.2.tar.gz

#cd apr-1.5.2

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


아래와 같은 에러가 발생함


rm: cannot remove 'libtoolT': No such file or directory


#cp -arp libtool libtoolT


로 해결


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


#make

#make install



5. apr-util 설치


#wget http://mirror.apache-kr.org/apr/apr-util-1.5.4.tar.gz

#tar xvfz 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



6. 다시 아파치 설치

#cd /usr/local/src/httpd-2.4.16

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


아래와 같은 에러가 남


configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/



pcre설치


#yum -y install pcre-devel



다시 시도


prefork 설정

#vi /server/mpm/prefork/prefork.c


DEFAULT_SERVER_LIMIT = 1024



worker  설정

#vi server/mpm/worker/worker.c


DEFAULT_SERVER_LIMIT = 64






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



openssl 에러가 날 경우


#yum install opelssl*




#make

#make install

 

프로세스 확인


[root@cent7_64 /]# ps -ef | grep httpd

root      1508     1  0 17:24 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1635  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1636  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1642  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1719  1508  0 17:35 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

root      1754  2391  0 17:43 pts/0    00:00:00 grep --color=auto httpd

[root@cent7_64 /]# 





끝.



[MySQL 설치]


1. mysql.com 에서 5.6.25 버전을 다운받아 /usr/local/src에 올려준다.

/usr/local/src  에서 작업한다.


#tar xvfz mysql-5.6.25.tar.gz

#cd mysql-5.6.25


mysql은 cmake로 설치해야 하므로 cmake를 설치한다.

#yum -y install cmake


#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 -DMYSQL_TCP_PORT=3306 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci 


아래와 같은 에러가 날 경우

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 



#yum install ncurses-devel

#rm -rf CMakeCache.txt


후에

#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 -DMYSQL_TCP_PORT=3306 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci 



data폴더는 /usr/local/mysql/data이고

my.cnf폴더는 /etc 이다.


#make

#make install


#cp ./support-files/my-default.cnf /etc/my.cnf

#vi /etc/my.cnf

character-set-server = euckr



mysql사용자 등록

#useradd -M -s /bin/false mysql



초기 디비 설치

#chmod 700 ./scripts/mysql_install_db

#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data



데몬 시작

#/usr/local/mysql/bin/mysqld_safe --user=mysql &


mysql root 비번 설정

#/usr/local/mysql/bin/mysqladmin -u root password '비밀번호'

(비밀번호는 작은 따옴표로 두른다.)


#mysql root 암호를 잊어버린 경우
#killall mysqld
#/usr/local/mysql/bin/mysqld_safe --skip-grant-table &
#/usr/local/mysql/bin/mysql -u root mysql

mysql>update user set password=password('새로운 비번') where user='root';
mysql>flush privileges;
mysql>quit;

#killall mysqld
#/usr/local/mysql/bin/mysqld_safe --user=mysql &



부팅후에 자동시작하려면

#vi /etc/rc.d/rc.local 

아래와 같이 추가해 준다.


!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.


touch /var/lock/subsys/local


/usr/local/mysql/bin/mysqld_safe --user=mysql &




프로세스 확인


[root@cent7_64 /]# ps -ef | grep mysqld

root      1792  2391  0 18:21 pts/0    00:00:00 grep --color=auto mysqld

root     15085  2391  0 15:38 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe -user=mysql

mysql    15288 15085  0 15:38 pts/0    00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql -user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/tmp/mysql.sock

[root@cent7_64 /]# 



MySQL 접속


[root@cent7_64 /]# mysql -u root -p mysql

Enter password: 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.25 Source distribution


Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> 



모든 곳에서 mysql을 실행하려면 (root인 경우)

#vi /root/.bash_profile

아래와 같이 수정


# .bash_profile


# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi


# User specific environment and startup programs


PATH=$PATH:$HOME/bin:/usr/local/mysql/bin


export PATH

~             



특정 사용자의 경우에는 

#vi /home/계정명/.bash_profile 

을 수정해 주면 된다.


끝.





[PHP 설치]


1. php.net 에 가서 php파일을 다운 받는다. /usr/local/src 에 올려둔다. 5.6.11 버전을 설치할 것이다.

작업 위치는 /usr/local/src이다.


PHP컴파일을 위해 필요한 라이브러리들을 설치한다.


#yum install libxml*

#yum install bzip2-devel

#yum install curl-devel

#yum install gdbm-devel

#yum install libjpeg-devel

#yum install libpng*


아래와 같은 에러가 난다.


Error: libpng12-devel conflicts with 2:libpng-devel-1.5.13-5.el7.x86_64

 You could try using --skip-broken to work around the problem

 You could try running: rpm -Va --nofiles --nodigest


안내된 대로 아래와 같이 다시 설치한다.

#yum install libpng* --skip-broken


#yum install freetype-devel




mhash 설치

#wget  http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

#tar xvfz mhsah-0.9.9.9.tar.gz

#cd mhash-0.9.9.9

#./configure

#make

#make install



libmcrypt 설치

#wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/Production/libmcrypt-2.5.7.tar.gz

#tar xvfz libmcrypt-2.5.7.tar.gz

#cd libmcrypt-2.5.7

#./configure

#make

#mkae install



#vi /etc/ld.so.conf

아래와 같이


include ld.so.conf.d/*.conf

/usr/local/lib


저장하고 빠져나온다.


#ldconfig



mcrypt 설치

#wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

#tar xvfz mcrypt-2.6.8.tar.gz

#cd mcrypt-2.6.8

#./configure

#make

#make install



libjpeg를 설치했는데도 아래와 같은 에러가 날 경우

configure: error: libjpeg.(a|so) not found.


#yum -y install libjpeg-devel 

#yum -y install libpng-devel



#ln -s /usr/lib64/libjpeg.so /usr/lib

#ln -s /usr/lib64/libpng.so /usr/lib


로 해 줌





이제 PHP를 설치한다.


/usr/local/src에 php-5.6.11.tar.gz를 올려두었었다.


#tar xvfz php-5.6.11.tar.gz

#cd php-5.6.11

#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --enable-mod-charset --with-charset=utf8 --with-config-file-path=/etc --enable-sigchild --with-libxml-dir --with-openssl --with-zlib --with-zlib-dir --with-bz2 --enable-calendar --with-curl --enable-dba --with-gdbm --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext --with-imap-ssl --with-kerberos --enable-mbstring --with-mhash --with-mcrypt --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-sockets --with-regex=php --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-soap --enable-wddx




#make

#make install



#cp php.ini-development /etc/php.ini



php를 사용할 수 있도록 아파치 설정 수정

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


ServerName 주석 해제

ServerName 192.168.0.252:80



php사용 확장자 등록 : php, php3 등등

<IfModule mime_module>

    #

    # TypesConfig points to the file containing the list of mappings from

    # filename extension to MIME-type.

    #

    TypesConfig conf/mime.types


    #

    # AddType allows you to add to or override the MIME configuration

    # file specified in TypesConfig for specific file types.

    #

    #AddType application/x-gzip .tgz

    #

    # AddEncoding allows you to have certain browsers uncompress

    # information on the fly. Note: Not all browsers support this.

    #

    #AddEncoding x-compress .Z

    #AddEncoding x-gzip .gz .tgz

    #

    # If the AddEncoding directives above are commented-out, then you

    # probably should define those extensions to indicate media types:

    #

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

    AddType application/x-httpd-php .html .php .php3 .php4 .php5 .phtml .cgi .inc

    AddType application/x-httpd-php-source .phps


    #

    # AddHandler allows you to map certain file extensions to "handlers":

    # actions unrelated to filetype. These can be either built into the server

    # or added with the Action directive (see below)

    #

    # To use CGI scripts outside of ScriptAliased directories:

    # (You will also need to add "ExecCGI" to the "Options" directive.)

    #

    #AddHandler cgi-script .cgi


    # For type maps (negotiated resources):

    #AddHandler type-map var


    #

    # Filters allow you to process content before it is sent to the client.

    #

    # To parse .shtml files for server-side includes (SSI):

    # (You will also need to add "Includes" to the "Options" directive.)

    #

    #AddType text/html .shtml

    #AddOutputFilter INCLUDES .shtml

</IfModule>




php모듈에 아래와 같이 주석이 해제되었는지 확인

LoadModule php5_module        modules/libphp5.so








아파치 설정파일 에러 체크

#/usr/local/apache2/bin/apachectl -t


[root@cent7_64 php-5.6.11]# /usr/local/apache2/bin/apachectl -t

Syntax OK


문제가 없다.


아파치 시작

#/usr/local/apache2/bin/apachectl start



프로세스 확인


[root@cent7_64 php-5.6.11]# ps -ef | grep httpd

root      1508     1  0 17:24 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1635  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1636  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1642  1508  0 17:34 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

daemon    1719  1508  0 17:35 ?        00:00:00 /usr/local/apache2/bin/httpd -k start

root      1838  1810  0 18:30 pts/0    00:00:00 grep --color=auto httpd




브라우저 확인





프로세스는 정상인데 브라우저로 접속이 안된다면 방화벽을 아래와 같이 확인한다.


[root@cent7_64 zones]# systemctl status firewalld

firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)

   Active: active (running) since 화 2008-01-01 14:38:16 KST; 14min ago

 Main PID: 601 (firewalld)

   CGroup: /system.slice/firewalld.service

           └─601 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid


 1월 01 14:38:15 cent7_64.localdomain systemd[1]: Starting firewalld - dynamic firewall.....

 1월 01 14:38:16 cent7_64.localdomain systemd[1]: Started firewalld - dynamic firewall ...n.

Hint: Some lines were ellipsized, use -l to show in full.

[root@cent7_64 zones]# 


방화벽이 돌고 있는 중이다.


방화벽에 80, 3306 포트를 추가하자.


#vi /etc/firewalld/zones/public.xml


<?xml version="1.0" encoding="utf-8"?>

<zone>

  <short>Public</short>

  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>

  <service name="dhcpv6-client"/>

  <service name="ssh"/>

  <port protocol="tcp" port="3306"/>

  <port protocol="tcp" port="80"/>

</zone>



아래와 같이 방화벽을 적용한다.

[root@cent7_64 zones]# firewall-cmd --reload

success

[root@cent7_64 zones]# 





phpinfo 확인





phpinfo.php 화면이 공백일 경우 디폴트 php.ini 에서 short tag 가 Off로 되어 있기 때문이므로 php.ini를 수정한다.


#vi /etc/php.ini


short_open_tag = Off 로 되어 있는 것을 찾아 On으로 변경한다.


short_open_tag = On



아파치를 재시작한다.


phpinfo 에서 date 부분에 아래와 같이 경고가 보인다. 타임존을 필수적으로 세팅해야한다는 말이다.






다시 php.ini 파일을 수정한다.


아래와 같이 수정한다.


[Date]

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

date.timezone = "Asia/Seoul"



저장하고 아파치를 재시작한다.


date부분이 아래와 같이 바꼈다.





디폴트 타임존이 Asia/Seoul 로 변경되었다.


참고로 사용할 수 있는 타임존 리스트는 아래 경로에서 확인 가능하다.

http://us.php.net/manual/en/timezones.php






끝.






블로그 이미지

엘로드넷

,