[Linux] php 7.x 컴파일 설치하기
리자님께서 yum을 통한 방법을 올려주셔서 잠깐 머리 식힐 겸 글을 남겨드립니다.
* 컴파일 설치는 패키지 관리자로 설치하는 것보다 위험합니다.
* 사전에 지식을 습득하시고 사용하셔야하며, 설정이 제대로 이루어지지 않을 경우 사이트 내 모든 PHP 코드가 유출 될 수 있습니다.
1. PHP 다운로드 페이지로 이동합니다.
- https://www.php.net/releases/

2. 원하는 버전의 tar.gz 파일로 다운로드 받습니다.
- wget <압축파일 링크> -O php.tar.gz
3. 압축파일을 해제합니다.
- tar -xvzpf php.tar.gz
4. 압축이 풀린 PHP 폴더에 들어갑니다.
- cd <압축 풀린 폴더명>
5. 다음 명령어를 실행합니다.
* 단, 필요한 라이브러리 등이 있는 경우 직접 설치하셔야합니다.
| 명령어 |
|---|
| ./configure \ --prefix=/usr/local/php \ --with-apxs2=/usr/bin/apxs \ --with-zlib-dir \ --with-freetype \ --enable-mbstring \ --enable-soap \ --enable-calendar \ --with-curl \ --with-zlib \ --enable-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --with-zip \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-jpeg=/usr/lib/x86_64-linux-gnu/ \ --with-openssl \ --with-fpm-user=www-data \ --with-fpm-group=www-data \ --enable-ftp \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-opcache \ --with-libdir=/usr/lib/x86_64-linux-gnu/ \ --with-freetype-dir=/usr/include/freetype2 \ --enable-gd-native-ttf |
* 위 명령어는 제 서버 기준으로 PHP 7.x 설치에 사용한 것으로 서버별 설정에 따라 다소 상이할 수 있습니다.
6. 다음 명령어를 입력합니다.
* 아래에 있는 숫자 4는 서버 환경에 따라 조절하시기 바랍니다.
* 조절 방법 : https://m.blog.naver.com/invain/80094907942
- make -j 4
7. 다음 명령어를 입력합니다.
- make install -j 4
8. 아파치와 연동하기 위해 아파치 모듈 폴더에 다음과 같은 파일을 생성합니다.
* 파일이 이미 존재하는 경우, 넘어갑니다.
- 파일명 : php7.load
- 파일 내용 : LoadModule php7_module /usr/lib/apache2/modules/libphp7.so
9. 아파치 설정 중 아무 곳에나 이 설정을 넣습니다.
| 설정 |
|---|
| <FilesMatch "\.php$"> AddType application/x-httpd-php .php </FilesMatch> |
이외의 설정은 php 폴더에 들어가셔서 직접 처리하시면 됩니다.
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4946 | node.js | 6년 전 | 2608 | ||
| 4945 | node.js | 6년 전 | 2379 | ||
| 4944 | node.js | 6년 전 | 2519 | ||
| 4943 | node.js | 6년 전 | 2269 | ||
| 4942 | node.js | 6년 전 | 2245 | ||
| 4941 | node.js | 6년 전 | 2717 | ||
| 4940 | node.js | 6년 전 | 1867 | ||
| 4939 | node.js | 6년 전 | 1995 | ||
| 4938 | node.js | 6년 전 | 2459 | ||
| 4937 | node.js | 6년 전 | 2248 | ||
| 4936 | node.js | 6년 전 | 2318 | ||
| 4935 | node.js | 6년 전 | 2136 | ||
| 4934 | node.js | 6년 전 | 2440 | ||
| 4933 | node.js | 6년 전 | 2245 | ||
| 4932 | node.js | 6년 전 | 2686 | ||
| 4931 | node.js | 6년 전 | 2070 | ||
| 4930 | node.js | 6년 전 | 1998 | ||
| 4929 | node.js | 6년 전 | 8630 | ||
| 4928 | node.js | 6년 전 | 3749 | ||
| 4927 | node.js | 6년 전 | 2392 | ||
| 4926 | node.js | 6년 전 | 2504 | ||
| 4925 | node.js | 6년 전 | 2081 | ||
| 4924 | node.js | 6년 전 | 3373 | ||
| 4923 | node.js | 6년 전 | 2220 | ||
| 4922 | node.js | 6년 전 | 1989 | ||
| 4921 | node.js | 6년 전 | 2046 | ||
| 4920 | node.js | 6년 전 | 1764 | ||
| 4919 | node.js | 6년 전 | 2030 | ||
| 4918 | node.js | 6년 전 | 2176 | ||
| 4917 | node.js | 6년 전 | 2393 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기