rdate -s time.bora.net
서버 이동 후, 테스트 코드를 실행해봤는데 로그 파일에 소스코드가 그대로 출력되었다.
php 설치 확인
php -v
5.4 버전이 설치되어있다😅
phpinfo() 확인
먼저 phpinfo를 확인하였다. 쉘에서 php 실행 시 timezone 에러 발생
서버시간 동기화
rdate -s time.bora.net
혹시나해서 실행해봤는데 역시 php.ini를 확인해봐야겠다..
php.ini 수정
date.timezone을 찾아서 주석을 해제하고, Asia/Seoul 추가
date.timezone = Asia/Seoul
오류 없이 phpinfo 출력이 완료되었다.
하지만 여전히 소스코드가 그대로 출력되는 문제가 발생 중임.ㅋ 💀💀💀💀💀
apache와 연동 확인하기
그래..먼저 프로세스가 실행 중 인지 확인했다. (ps ax)
실행하고 있지않다..
프로세스를 실행해주었는데도 안된다 💀
httpd.conf 파일을 확인해보니 수정이 안되어있다.
httpd.conf 수정
vi /etc/httpd/conf/httpd.conf
httpd.conf파일을 열어서 아래와 같이 수정한다.
(기존) DirectoryIndex index.html
(변경) DirectoryIndex index.html index.html.var index.php index.php3
AddType application/x-gzip .gz .tgz 아래에 두 줄을 추가한다.
(기존) AddType application/x-gzip .gz .tgz
(추가) AddType application/x-httpd-php .php .html .htm .inc
(추가) AddType application/x-httpd-php-source .phps
DirectoryIndex index.html
DirectoryIndex index.html index.html.var index.php index.php3
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .html .htm .inc
AddType application/x-httpd-php-source .phps
아파치 재실행
service httpd restart
실행 완료
아래는 넘기셔도 됩니다 b
라이브러리 연동 오류
이번엔 라이브러리 연동 오류가 난다. (db connect)
확인해보니 mysql이 실행안되어 있다.💀💀💀💀💀💀💀💀💀
systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
,,,ㅎ
로그 확인해보려고 했는데 로그 파일도 없음
/var/run 아래에 mysqld 디렉토리가 없어서 폴더를 생성했다
mysqld 디렉토리 생성
/var/run에 디렉토리가 있는지 확인 후 없으면 생성
cd /var/run
mkdir mysqld
다시 시작해보지만 여전히 x
service mysqld start
디렉토리에 권한 부여(mysql)
chown mysql.mysql /var/run/mysqld/
이번엔 pid에러가 난다.. (파도파도 끝이없네)
참고
Job for mysqld.service failed See "systemctl status mysqld.service"
Console says [root@ip-172-31-18-2 mysql]# service mysqld start Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with an error code. See "syste...
stackoverflow.com
음..확인해보니 mariadb로 잡혀있는 것 같다.
삭제하고 다시 설치할까 고민중
my.cnf파일도 다시 확인해보니 mariadb로 적혀있고 로그도 mariadb.log만 보인다
#20230117
mysql 관련 파일 및 폴더를 전체 삭제한 후, 다시 설치했다.
https://dev-wisdom.tistory.com/120
mariaDB 삭제 후 mySQL 설치하기
mysql 설치 버전확인해보니 mariaDB가 설치되어있는 것 같다. [root@localhost ~]# mysql --version mysql Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1 --작성중
dev-wisdom.tistory.com
mysql 설치하기는 아래 링크 참고
https://dev-wisdom.tistory.com/123
MySQL 설치하기
centOS7 부터는 데이터베이스가 MariaDB로 바뀌었다. 그래서 MySQL 을 yum 으로 바로 설치가 불가능하다고 한다. 의존성있는 관련 패키지 설치 # yum -y install gcc g++ libncurses5-dev libxml2-dev openssl libssl-dev curl
dev-wisdom.tistory.com
mysql 연결 확인 예제
<?php
$mysql_hostname = 'localhost';
$mysql_username = 'root';
$mysql_password = '비밀번호';
$mysql_database = '데이터베이스';
$mysql_table = '테이블명';
// 1. DB 연결
$connect = mysql_connect($mysql_hostname, $mysql_username, $mysql_password, $mysql_table) or die("MySQL 서버에 연결할 수 없습니다.");
if ($connect) {
echo "[연결성공]<br/>";
} else {
echo "[연결실패]<br/>";
}
mysql_close($connect);
?>
php.ini 확인하기
php.ini 파일에서 short_open_tag 가 꺼져있으면 켜준다. (short_open_tag = On)
(1) short_open_tag = Off일 경우
<?php
?>
(2) short_open_tag = On일 경우
<?
?>
짧은 태그를 사용하게 되는 경우가 많으므로, 옵션을 켜준다.
httpd.conf 수정
<IfModule dir_module> 사이에 DirectoryIndex index.html index.html.var index.php index.php3 를 추가하고,
<IfModule dir_module>
DirectoryIndex index.html index.html.var index.php index.php3
</IfModule>
<IfModule mime_module> 사이에 추가한다.
<IfModule mime_module>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .html .htm .inc
AddType application/x-httpd-php-source .phps
</IfModule>
아파치 재시작
systemctl restart httpd
'Development > PHP' 카테고리의 다른 글
mysql_connect(): No such file or directory (0) | 2023.01.16 |
---|---|
익명 함수(Anonymous functions) (0) | 2023.01.13 |
PHP 로그에 소스코드가 출력될 때 (0) | 2023.01.11 |
[PHP] cURL로 자동 로그인하기 (0) | 2022.12.20 |
php timestamp 13자리 변환하기 (0) | 2022.12.16 |