설치할 것들 :


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






끝.






블로그 이미지

엘로드넷

,