메뉴 건너뛰기

조회 수 11979 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

/*---------------------------------------------------------------------------------------*/

이제 깔아보자..php 이것만 깔면 웹서버 구색이 갖춰지는군..

요점은 맨밑에 ...

/*---------------------------------------------------------------------------------------*/ 

[root@localhost ~]# yum groupinstall php <-(php관련 그룹을 모두 인스톨한다)
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
base                                                     | 3.6 kB     00:00    
extras                                                   | 3.4 kB     00:00    
mysql-connectors-community                               | 2.5 kB     00:00    
mysql-tools-community                                    | 2.5 kB     00:00    
mysql56-community                                        | 2.5 kB     00:00    
updates                                                  | 3.4 kB     00:00    
mysql56-community/x86_64/primary_db                        |  92 kB   00:00    
Loading mirror speeds from cached hostfile
 * base: data.nicehosting.co.kr
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.4.16-23.el7_0.3 will be installed
--생략--
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch          Version                     Repository   Size
================================================================================
Installing for group install "PHP 吏?:
 php                x86_64        5.4.16-23.el7_0.3           base        1.3 M
 php-gd             x86_64        5.4.16-23.el7_0.3           base        124 k
 php-pdo            x86_64        5.4.16-23.el7_0.3           base         95 k
 php-pear           noarch        1:1.9.4-21.el7              base        357 k
 php-xml            x86_64        5.4.16-23.el7_0.3           base        122 k
Installing for dependencies:
 libXpm             x86_64        3.5.10-5.1.el7              base         52 k
 libxslt            x86_64        1.1.28-5.el7                base        242 k
 libzip             x86_64        0.10.1-8.el7                base         48 k
 php-cli            x86_64        5.4.16-23.el7_0.3           base        2.7 M
 php-common         x86_64        5.4.16-23.el7_0.3           base        561 k
 php-process        x86_64        5.4.16-23.el7_0.3           base         52 k
 t1lib              x86_64        5.1.2-14.el7                base        166 k

Transaction Summary
================================================================================
Install  5 Packages (+7 Dependent packages)

Total download size: 5.9 M
Installed size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
(1/12): libXpm-3.5.10-5.1.el7.x86_64.rpm                   |  52 kB   00:00     
--생략-- 
(12/12): php-5.4.16-23.el7_0.3.x86_64.rpm                  | 1.3 MB   00:01    
--------------------------------------------------------------------------------
Total                                              4.4 MB/s | 5.9 MB  00:01    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libzip-0.10.1-8.el7.x86_64                                  1/12 
  --생략--
  Installing : php-pdo-5.4.16-23.el7_0.3.x86_64                       12/12
  Verifying  : php-common-5.4.16-23.el7_0.3.x86_64                  1/12 
  --생략--
  Verifying  : 1:php-pear-1.9.4-21.el7.noarch                           12/12

Installed:
  php.x86_64 0:5.4.16-23.el7_0.3          php-gd.x86_64 0:5.4.16-23.el7_0.3    
  php-pdo.x86_64 0:5.4.16-23.el7_0.3      php-pear.noarch 1:1.9.4-21.el7       
  php-xml.x86_64 0:5.4.16-23.el7_0.3    

Dependency Installed:
  libXpm.x86_64 0:3.5.10-5.1.el7         libxslt.x86_64 0:1.1.28-5.el7         
  libzip.x86_64 0:0.10.1-8.el7           php-cli.x86_64 0:5.4.16-23.el7_0.3    
  php-common.x86_64 0:5.4.16-23.el7_0.3  php-process.x86_64 0:5.4.16-23.el7_0.3
  t1lib.x86_64 0:5.1.2-14.el7          

Complete!
[root@localhost ~]#  

/*---------------------------------------------------------------------------------------*/

작동하는지 php명령어를 입력하고 접속해보자

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# vi /var/www/html/test.php <-(경로잘 봐.. 다음부턴 툴을 사용하고 지금은 간단히
<?php
phpinfo();
?>
~
"/var/www/html/test.php" [New] 3L, 17C written
[root@localhost ~]#  

/*---------------------------------------------------------------------------------------*/

어라??? 왜 안되지?? 아항 아파치를 재구동 해야하나.. 그럼 해보지 뭐~!

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# systemctl restart httpd <-(아파치 재구동)

/*---------------------------------------------------------------------------------------*/

재구동도 안되네.. 그럼 네이버검색해보자 어케 하는건지.. 구글링중~~~

아하.. 아파치설정을 해야하는구나.. 그럼 httpd.conf의 내용을 수정하자..

수정할 내용은

AddType application/x-httpd-php .php .php3 .html .htm

AddType application/x-httpd-php .php-source .phps 요거(2줄)라네요

설정파일을 찾아보자~~

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# find / -name httpd.conf <-(파일찾는명령 자주쓰는 명령이지...ㅋ)
/etc/httpd/conf/httpd.conf
/usr/lib/tmpfiles.d/httpd.conf
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf <-(vi 편집기 알아야될 명령어 i / esc키 :(콜론) w / q)

# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.

--생략--

ServerRoot "/etc/httpd"

#Listen 12.34.56.78:80
Listen 80

--생략--

Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

--생략--

#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

--생략--

 # 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

    AddType application/x-httpd-php .php .php3 .html .htm 

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

(2줄입력하고 esc키 누르고 :(콜론)누르고 wq입력하고 enter 하면 저장후 종료된다)
</IfModule>

[root@localhost ~]# systemctl restart httpd <-(아파치 재구동)

/*---------------------------------------------------------------------------------------*/

오 된다... 그런데 한가지 의문점.. php 구문은<? ?> 요런식으로 한다. <?php ?> 요렇게도 하고

근데 <? ?>요렇게 했더니 안나온다.. 뭔가 설정이 있는듯.. 찾아보자.. 구글링중~~!!

찾았다...

short_open_tag = On “<?php” 와 “<?” 를 사용 할 수 있도록 한다. 요거다..

이설정은 php.ini에서 한다.. 그럼 시작

/*---------------------------------------------------------------------------------------*/ 

[root@localhost ~]# find / -name php.ini
/etc/php.ini

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

[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
--생략-- 

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;

; Enable the PHP scripting language engine under Apache.
; http://php.net/engine
engine = On

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = Off <-(요거를 on으로 바꿔주자) 

--생략--

"/etc/php.ini" 1797L, 64944C written
[root@localhost ~]#

/*---------------------------------------------------------------------------------------*/

그럼 소스를 <?php phpinfo(); ?> --> <? phpinfo(); ?> 요렇게 바꿔보고 해보자..

/*---------------------------------------------------------------------------------------*/

[root@localhost ~]# vi /var/www/html/test.php
<?
phpinfo();
?>
~
"/var/www/html/test.php" 3L, 17C written
[root@localhost ~]# systemctl restart httpd <-(아파치서버 재시작)

/*---------------------------------------------------------------------------------------*/

되는거 확인 되었다.. 예~~

요점정리

1. [root@localhost ~]# yum groupinstall php <-(php관련 그룹을 모두 인스톨한다)

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

   AddType application/x-httpd-php .php .php3 .html .htm

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

   위 두줄 입력하고 저장

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

   short_open_tag = Off <-(요거를 on으로 바꿔주자)-->short_open_tag = On 

4. [root@localhost ~]# systemctl restart httpd <-(아파치 재구동)

이렇게 간단히 끝났다.. 휴.. 정말 끝이네 이로써 그릇이 완성돼었다..

문제는 하면서 php.ini 설정과 httpd.conf 설정 파일을 만지게 될 것이다..

그때 그때 맞추서 하자. 지금 막 고쳐봐야 생각도 안나고 우선은 서버가 돌아가는데 집중하자.

/*---------------------------------------------------------------------------------------*/
 


List of Articles
번호 제목 날짜 조회 수
117 mysql root 비밀번호 설정 2015.07.16 7858
116 mod_expires 모듈 추가 및 이미지 캐싱 설정방법 2014.02.27 7862
115 Linux 시스템 백업과 복원 2014.03.26 7862
114 iptables GEOIP 모듈 설치. (국가별 IP 차단) 2014.02.27 7864
113 아파치 설치 2015.07.16 7864
112 아파치 로그(Apache Log) 관리법 2017.02.02 7871
111 Snort란 2014.02.27 7873
110 LILO, GRUB root 패스워드 리셋 2014.02.27 7895
109 리눅스 기본보안설정(12) file 2014.05.15 7900
108 솔라리스 - 간단 vi 명령어 2017.04.12 7905
107 ncftp 설치및 스크립트 백업 방법 file 2014.02.27 7928
106 ethtool을 이용한 랜카드 설정 2014.02.27 7929
105 LINUX - 특정 파일이 속한 RPM 패키지 확인 및 설정 파일 경로 2014.02.27 7940
104 웹호스팅용 리눅스 서버 셋팅 file 2014.03.26 7940
103 리눅스... 디스크 가득 찼을 때 2016.09.12 7941
102 sulinux2.0 NFS 설정 & 공유 2015.06.10 7943
101 외부 링크 제한하기 2014.02.27 7952
100 DHCP IP 자동 할당 2017.03.11 7964
99 apache + mysql 자동 실행 방법 (소스설치) 2014.02.27 7966
98 도메인 포워딩 설정 2014.02.27 7970
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next
/ 12

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved