[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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 5276 | 2년 전 | 1331 | |||
| 5275 | 2년 전 | 1401 | |||
| 5274 | 기타 | 2년 전 | 815 | ||
| 5273 | JavaScript |
swallow
|
2년 전 | 1045 | |
| 5272 | node.js |
swallow
|
2년 전 | 742 | |
| 5271 | JavaScript |
swallow
|
2년 전 | 1495 | |
| 5270 | PHP |
swallow
|
2년 전 | 844 | |
| 5269 | node.js |
swallow
|
2년 전 | 680 | |
| 5268 | node.js |
swallow
|
2년 전 | 1209 | |
| 5267 | PHP |
swallow
|
2년 전 | 1591 | |
| 5266 | MySQL |
swallow
|
2년 전 | 1088 | |
| 5265 | PHP |
swallow
|
2년 전 | 2029 | |
| 5264 | JavaScript |
swallow
|
2년 전 | 858 | |
| 5263 | 기타 |
swallow
|
2년 전 | 2980 | |
| 5262 | 기타 |
swallow
|
2년 전 | 667 | |
| 5261 | node.js |
swallow
|
2년 전 | 1059 | |
| 5260 | JavaScript |
swallow
|
2년 전 | 1508 | |
| 5259 | node.js |
swallow
|
2년 전 | 729 | |
| 5258 | node.js |
swallow
|
2년 전 | 1741 | |
| 5257 | node.js |
swallow
|
2년 전 | 1292 | |
| 5256 | PHP |
swallow
|
2년 전 | 1938 | |
| 5255 | node.js |
swallow
|
2년 전 | 684 | |
| 5254 | PHP |
swallow
|
2년 전 | 3011 | |
| 5253 | node.js |
swallow
|
2년 전 | 675 | |
| 5252 | 정규표현식 |
swallow
|
2년 전 | 622 | |
| 5251 | node.js |
swallow
|
2년 전 | 876 | |
| 5250 | PHP |
swallow
|
2년 전 | 1110 | |
| 5249 | node.js |
swallow
|
2년 전 | 1059 | |
| 5248 | PHP |
swallow
|
2년 전 | 1409 | |
| 5247 | node.js |
swallow
|
2년 전 | 1014 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기