혹시 편리님 centos7+nginx+php7 블로그 보고 설치해 보신분 계신가요? 정보
혹시 편리님 centos7+nginx+php7 블로그 보고 설치해 보신분 계신가요?본문
편리님 블로그에 보면 centos7에 nginx에 php7 설치 하는 방법이 나와 있는데
희안하게 php 파일을 실행 하면 404 not found가 뜨더라고요
즉 php가 연동이 안되는거 같은데
이 자료를 보고 하면 잘 되는데 편리님 자료를 보고 하면 연동이 안되던데 혹시 해보신분 계신가요 ?
공감
0
0
댓글 6개
제 블로그에 댓글을 남기면 제가 답변을 안해준다는 소문이 났나 보군요.. ㅠㅠ
404 에러는 경로에 파일이 없을 때 표시되는 에러입니다. /var/log/nginx 디렉토리에
있는 error.log 파일을 확인해보시면 오류 내용을 확인하실 수 있습니다.
404 에러는 경로에 파일이 없을 때 표시되는 에러입니다. /var/log/nginx 디렉토리에
있는 error.log 파일을 확인해보시면 오류 내용을 확인하실 수 있습니다.
안녕하세요 편리님 직접 대글 감사 드립니다.
희안하게 에러기록가 기록 되지 않네요
404에러가 난다는건 파일이 없어서 나는건데 파일이 있는데 이 에러가 납니다.
sudo vi /usr/share/nginx/html/info.php
파일을 써주고 이 파일 안에 <?php phpinfo(); ?> 라고 적고 저장한 후
디지털오션에서 받은 아이피/info.php 하면 404가 뜹니다.
또 재미 있는건 html에 있는 index.html이라는 파일을 임의로 확장자를 index.php로만 바꿔도 404 에러가 뜹니다.
혹시 php-fpm 연동을 위한 nginx 설정 이부분에 설정 위치가
vi /etc/nginx/conf.d/default.conf
php-fpm pool 설정 위치가
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이부분이 맞나요 ? 디지털 오션측에서 기재해 놓은 대로 진행을 하면 php파일이 뜨는데
편리님이 블로그에 포스팅 해놓으신 순서대로 빠짐없이 그대로 몇번을 순서대로 해도
php -v해도 -bash: php: command not found 라고만 뜨는데 블로그 포스팅에서 뭔가 빠진거 같은 느낌이 드는데 몇번을 해도 결과는 같더라고요
php7이 나온지 얼마 안되서 그런지 해당 관련 셋팅과정과 질문과 답변도 해당 관련 포스팅도 거의 찾아 볼 수 없어서 여기에 질문좀 남겼습니다. 혹시 해보신분 계신가 해서요 ^^;
희안하게 에러기록가 기록 되지 않네요
404에러가 난다는건 파일이 없어서 나는건데 파일이 있는데 이 에러가 납니다.
sudo vi /usr/share/nginx/html/info.php
파일을 써주고 이 파일 안에 <?php phpinfo(); ?> 라고 적고 저장한 후
디지털오션에서 받은 아이피/info.php 하면 404가 뜹니다.
또 재미 있는건 html에 있는 index.html이라는 파일을 임의로 확장자를 index.php로만 바꿔도 404 에러가 뜹니다.
혹시 php-fpm 연동을 위한 nginx 설정 이부분에 설정 위치가
vi /etc/nginx/conf.d/default.conf
php-fpm pool 설정 위치가
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이부분이 맞나요 ? 디지털 오션측에서 기재해 놓은 대로 진행을 하면 php파일이 뜨는데
편리님이 블로그에 포스팅 해놓으신 순서대로 빠짐없이 그대로 몇번을 순서대로 해도
php -v해도 -bash: php: command not found 라고만 뜨는데 블로그 포스팅에서 뭔가 빠진거 같은 느낌이 드는데 몇번을 해도 결과는 같더라고요
php7이 나온지 얼마 안되서 그런지 해당 관련 셋팅과정과 질문과 답변도 해당 관련 포스팅도 거의 찾아 볼 수 없어서 여기에 질문좀 남겼습니다. 혹시 해보신분 계신가 해서요 ^^;
설정 파일의 위치는 맞습니다.
php cli 파일들은 /opt/remi/php70/root 디렉토리 안에 있습니다.
/opt/remi/php70/root/bin/php -v 라고 하면 PHP 버전이 표시됩니다.
/opt/remi/php70/root/bin/ 디렉토리가 PATH 에 추가되지 않아서
-bash: php: command not found 라는 오류가 표시되는 것입니다.
실제 설정하신 nginx.conf, default.conf, www.conf 의 내용을 전체
다 올려주시면 확인하기가 수월할 겁니다.
php cli 파일들은 /opt/remi/php70/root 디렉토리 안에 있습니다.
/opt/remi/php70/root/bin/php -v 라고 하면 PHP 버전이 표시됩니다.
/opt/remi/php70/root/bin/ 디렉토리가 PATH 에 추가되지 않아서
-bash: php: command not found 라는 오류가 표시되는 것입니다.
실제 설정하신 nginx.conf, default.conf, www.conf 의 내용을 전체
다 올려주시면 확인하기가 수월할 겁니다.
답변 감사 드립니다.
다시한번 서버를 재 발급 받아 편리님의 블로그에 씌여져 그 순서 그대로 하나도 빠짐 없이 복사 붙여 넣기 수준으로 있는 절차 대로 진행하니 똑같은 증상이 나오네요
vi /etc/nginx/conf.d/default.conf
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이부분은 블로그에서 어디다가 기재를 해야 하는지 몰라서 파일 검색을 해보니 저 위치더라고요
해당 부분은 별다른 설정 한것이 없고 그냥 이렇게만 설정을 하였습니다.
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_cache off;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
include mime.types;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이 부분은 해당 부분만 찾아서 변경해 놓았습니다.
해당 부분만 변경해서 전체 소스를 올리기에는 너무 기네요
/etc/nginx/nginx.conf
이부분은 이렇게 설정 되어 있습니다.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
혹시 몰라 쪽지를 좀 보내 드리겠습니다.
다시한번 서버를 재 발급 받아 편리님의 블로그에 씌여져 그 순서 그대로 하나도 빠짐 없이 복사 붙여 넣기 수준으로 있는 절차 대로 진행하니 똑같은 증상이 나오네요
vi /etc/nginx/conf.d/default.conf
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이부분은 블로그에서 어디다가 기재를 해야 하는지 몰라서 파일 검색을 해보니 저 위치더라고요
해당 부분은 별다른 설정 한것이 없고 그냥 이렇게만 설정을 하였습니다.
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_cache off;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
include mime.types;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
vi /etc/opt/remi/php70/php-fpm.d/www.conf
이 부분은 해당 부분만 찾아서 변경해 놓았습니다.
해당 부분만 변경해서 전체 소스를 올리기에는 너무 기네요
/etc/nginx/nginx.conf
이부분은 이렇게 설정 되어 있습니다.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
혹시 몰라 쪽지를 좀 보내 드리겠습니다.
#location / {
# root /usr/share/nginx/html;
# index index.php index.html index.htm;
#}
root /usr/share/nginx/html;
index index.php index.html;
/etc/nginx/conf.d/default.conf 파일에서 위와 같이 수정하셔야 합니다.
아니면 아래처럼 document root 를 직접 지정해주셔야 합니다.
location ~ \.php$ {
root /usr/share/nginx/html;
try_files $uri =404;
fastcgi_cache off;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
include mime.types;
}
root 지정하는 설정을 변경하는 것은 일반적인 nginx 설정에 대부분 기술되어 있습니다. DO 쪽 문서에도 바꾸라고 기재되어 있는데 이 부분은 못 보신 것 같네요.
# root /usr/share/nginx/html;
# index index.php index.html index.htm;
#}
root /usr/share/nginx/html;
index index.php index.html;
/etc/nginx/conf.d/default.conf 파일에서 위와 같이 수정하셔야 합니다.
아니면 아래처럼 document root 를 직접 지정해주셔야 합니다.
location ~ \.php$ {
root /usr/share/nginx/html;
try_files $uri =404;
fastcgi_cache off;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
include mime.types;
}
root 지정하는 설정을 변경하는 것은 일반적인 nginx 설정에 대부분 기술되어 있습니다. DO 쪽 문서에도 바꾸라고 기재되어 있는데 이 부분은 못 보신 것 같네요.
바쁘신 와중에도 이렇게 소중한 답변 감사 드립니다.
아 그부분을 못봤네요 우분투와 아파치만 사용하다가 centos nginx 를 처음 사용하다 보니 이해를 못했나 봅니다 그냥 명시되어 있는 부부만 따라 하면 되는줄 알고 계속 해당 부분에 있어서 명시 되어 있는 부분만 강조해서 보면서 왜 안되지 왜 안돼지 ? 라고 몇일동안 바보같은 짓을 몇일 동안 했네요 죄송합니다. ^^;
편리님 블로그를 즐겨 찾기 해놓고 항상 좋은 정보 잘 보고 공부 하고 있습니다.
이렇게 시간 내서 봐주신것에 대해서 마음 깊이 감사의 말씀을 드립니다.
좋은 저녁 되세요 ^^
아 그부분을 못봤네요 우분투와 아파치만 사용하다가 centos nginx 를 처음 사용하다 보니 이해를 못했나 봅니다 그냥 명시되어 있는 부부만 따라 하면 되는줄 알고 계속 해당 부분에 있어서 명시 되어 있는 부분만 강조해서 보면서 왜 안되지 왜 안돼지 ? 라고 몇일동안 바보같은 짓을 몇일 동안 했네요 죄송합니다. ^^;
편리님 블로그를 즐겨 찾기 해놓고 항상 좋은 정보 잘 보고 공부 하고 있습니다.
이렇게 시간 내서 봐주신것에 대해서 마음 깊이 감사의 말씀을 드립니다.
좋은 저녁 되세요 ^^