PHP-5.2.17 소스설치
에러시 참고 사이트
https://narusika.tistory.com/entry/php-%EC%BB%A8%ED%94%BC%EA%B7%B8-%EC%97%90%EB%9F%AC
https://idchowto.com/?p=16998
기본 개발tool 설치
yum -y install gcc gcc-c++ termcap libtermcap libtermcap-devel gdbm-devel zlib* libxml* freetype* libpng* libjpeg* curl-devel gd gd-devel libmcrypt libmcrypt-devel mhash mhash-devel libxml2 iconv unixODBC qpixman qpixman-devel dialog xorg-x11-devel mysql-devel
PHP-5.2.17 소스설치
mkdir -p /usr/local/src/APM_Setup/
cd /usr/local/src/APM_Setup/
wget https://museum.php.net/php5/php-5.2.17.tar.gz
tar zxvf php-5.2.17.tar.gz
cd /usr/local/src/APM_Setup/php-5.2.17/
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-exec-dir=/usr/local/apache/bin --with-mysql=/usr/local/mysql --enable-sigchild --disable-debug
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-exec-dir=/usr/local/apache/bin --with-config-file-scan-dir=/usr/local/php/etc/php.d --enable-bcmath --enable-calendar --with-freetype-dir --enable-gd-native-ttf --with-ttf --with-bz2 --with-gd --enable-mbstring --with-openssl --with-mcrypt --enable-ftp --enable-zip --with-curl --with-zlib --enable-soap --enable-sockets --with-mysql=/usr/local/mysql_config --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-dba --enable-exif --with-gettext --with-iconv --enable-sigchild --with-jpeg-dir --with-xpm-dir --with-libdir=lib64 --enable-fastcgi --enable-force-cgi-redirect --with-pcre-regex
make -j 8
make install
.
make 오류시
64Bit OS 상에서 PHP 컴파일시 아래와 같이 메세지가 나오는 경우 조치방법
에러메세지)
configure: error: libjpeg.(a|so) not found
보통은 아래 처럼 libjpeg 관련 패키지를 설치하면 되지만
# yum install libjpeg-devel
해결이 되지 않을 경우 아래와 같이 수정을 해보세요
# ln -s /usr/lib64/libjpeg.so /usr/lib/
# ln -s /usr/lib64/libpng.so /usr/lib/
configure: error: Kerberos libraries not found.
Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )
========================================================================
선행으로 깔린 MySQL, MariaDB 버전에 따라 다르다.
configure: error: wrong mysql library version or lib not found.
만약 파란색부분을 입력시 안되고 위에 처럼 오류 메시지 구문이 나온다면 아래것으로 바꿔라
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql \
MySQL, MariaDB 버전에 따라서 다르다 확인할 것
--with-mysqli \
--with-pdo-mysql \
========================================================================
PHP-5.2.17 패치
cd /usr/local/src/APM_Setup/php-5.2.17
wget -O php.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
patch -p0 -b < php.patch
patching file ext/dom/node.c
Hunk #1 succeeded at 1950 (offset 55 lines).
patching file ext/dom/documenttype.c
Hunk #1 succeeded at 215 (offset 10 lines).
patching file ext/simplexml/simplexml.c
Hunk #1 succeeded at 1343 (offset -74 lines).
=========================================================================
PHP-5.2.17 설치를 위한 apache설정
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-exec-dir=/usr/local/apache/bin --with-config-file-scan-dir=/usr/local/php/etc/php.d --enable-bcmath --enable-calendar --with-freetype-dir --enable-gd-native-ttf --with-ttf --with-bz2 --with-gd --enable-mbstring --with-openssl --with-mcrypt --enable-ftp --enable-zip --with-curl --with-zlib --enable-soap --enable-sockets --with-mysql=/usr/local/mysql_config --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-dba --enable-exif --with-gettext --with-iconv --enable-sigchild --with-jpeg-dir --with-xpm-dir --with-libdir=lib64 --enable-fastcgi --enable-force-cgi-redirect --with-pcre-regex
cp -arp /usr/local/src/APM_Setup/php-5.2.17/php.ini-dist /usr/local/apache/conf/php.ini
httpd.conf 파일 수정
vi /usr/local/apache/conf/httpd.conf
->PHP 설치 시 자동으로 설정
LoadModule php5_module modules/libcd php5.so:
아래 내용 추가
AddType application/x-httpd-php .php .php3 .html .htm
AddType application/x-httpd-php-source .phps
=========================================================================
만약(apache 2.4, php5.2 일때만 일어나는 오류이다.)
/usr/local/apache/bin/apachectl -t
httpd: Syntax error on line 168 of /usr/local/apache/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: undefined symbol: unixd_config
vi /usr/local/src/APM_Setup/php-5.2.17/sapi/apache2handler/php_functions.c
>line 386
#if !defined(WIN32) && !defined(WINNT) && !defined(NETWARE)
AP_DECLARE_DATA extern unixd_config_rec ap_unixd_config;
#endif
>line 417
#if !defined(WIN32) && !defined(WINNT) && !defined(NETWARE)
snprintf(tmp, sizeof(tmp), "%s(%d)/%d", ap_unixd_config.user_name, ap_unixd_config.user_id, ap_unixd_config.group_id);
php_info_print_table_row(2, "User/Group", tmp);
#endif
=================================================================================
cd /usr/local/src/APM_Setup/php-5.2.17/
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-exec-dir=/usr/local/apache/bin --with-mysql=/usr/local/mysql --enable-sigchild --disable-debug
make -j 8
make install
.
cp /usr/local/src/APM_Setup/php-5.2.17/php.ini-recommended /usr/local/apache/conf/php.ini
=================================================================================
ZendOptimizer 설치
cd /usr/local/src/APM_Setup/
wget http://mirror.hostway.co.kr/Zend/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
cd /usr/local/src/APM_Setup/ZendOptimizer-3.3.3-linux-glibc23-x86_64/
./install sh
OK
EXIT
OK
OK
OK (거의 OK,Yes)
OK
OK
YES
OK
cp -arp /usr/local/src/APM_Setup/ZendOptimizer-3.3.3-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/php/lib
그러면 /usr/local/Zend라는 디렉토리가 생성된다.
vi /usr/local/Zend/etc/php.ini
마지막에
[Zend]
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
zend_optimizer.version=3.3.3
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
cp -arp /usr/local/Zend/etc/php.ini /usr/local/apache/conf/php.ini
설치 확인
/usr/local/php/bin/php -v
PHP 5.2.17 (cli) (built: Sep 28 2020 20:30:02)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
다시 php컴파일 후 Syntax 테스트
=================================================================================
PHP 경로 설정
vi /etc/profile
PATH=$PATH:$HOME/bin:/usr/local/php/bin:
(빨강색 부분을 뒤에다 추가해준다)
source /etc/profile
=================================================================================
/AddType 검색하면 <IfModule mime_module>
AddType application/x-httpd-php .php .html .htm .inc .pia
AddType application/x-httpd-php-source .phps
vi /usr/local/apache/htdocs/phpinfo.php
<?php
phpinfo();
?>
=================================================================================
Apache MySQL PHP 연동확인
vi /usr/local/nginx/html/mysqldbtest.php
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>MySql-PHP 연결 테스트</title>
</head>
<body>
<?php
echo "MySql 연결 테스트<br>";
$db = mysqli_connect("localhost", "root", "1234", "mysql");
if($db){
echo "connect : 성공<br>";
}
else{
echo "disconnect : 실패<br>";
}
$result = mysqli_query($db, 'SELECT VERSION() as VERSION');
$data = mysqli_fetch_assoc($result);
echo $data['VERSION'];
if(!$db) {
die('연결실패: '.mysqli_connect_error().'<br>');
exit;
}
?>
</body>
</html>
========================================================================
연동확인했을때 오류날시
보통 mysql 8.0 이상버전에서 나온다.
확인했을때 이런문구가 나온다면
The server requested authentication method unknown to the client
mysql -u root -p
mysql>use mysql;
mysq>alter user 'root'@'localhost' identified with mysql_native_password by 'password';
mysql>select user,host,authentication_string from user;
========================================================================
아파치 재시작 시 오류 발생하면 참고 URL
https://idchowto.com/?p=29938
추가 설명
http://bban2.tistory.com/149
'WEB&WAS > PHP' 카테고리의 다른 글
php-5.4.45 소스설치 (0) | 2020.09.28 |
---|---|
php-5.3.29 소스설치 (0) | 2020.09.28 |
mysqlphp 연동테스트 파일 vi mysqlphptest.php (0) | 2020.09.18 |
PHP 소스 tree 옵션 및 툴 설명(5.3,5.5,7.0) (0) | 2020.08.27 |
PHP 확장모듈 설치하기 (0) | 2020.08.26 |