| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
- 부트스트랩 프로그레스바
- 애니메이션프로그레스바
- node-sass #dart-sass
- #push() 함수 #Object.keys()함수 #Object.values()함수 #Object.entries()함수
- 이미지유무체크
- animation progressbar
- JSON.stringify()
- PHP에서데이터로그
- 자바스크립트객체를문자열로
- 바닐라자바스크립트 텍스트 바꾸기
- 체크박스
- nginx루트경로변경
- git remote: Permission to .. denied to error: 403 에러
- node-sass #sass #사스
- CSS버튼애니메이션 #버튼클릭하면
- 버튼클릭하면박스나타남 #버튼클릭시박스노출 #버튼클릭시아래버튼밀어내림
- 빗버킷ssh
- PHP설치
- 바닐라자바스크립트
- JSON.parse()
- CSS버튼효과
- nginx와php연동
- nginx설치
- 자바스크립트객체배열로
- 클릭display:none #클릭하면버튼노출
- vanillajs
- Today
- Total
●▲■ 개발일기
[리눅스] M1맥북에서 NGINX + PHP 설치, 연동하기 본문
맥북 M1에서 웹서버 NGINX, PHP를 설치하고 연동을 해본다.
phpinfo까지 출력해보기.
패키지 관리자는 homebrew을 사용함.
먼저 nginx를 먼저 설치해본다. 보통 인텔맥은 brew install nginx라고 명령하면 설치되는데 M1에서는 에러가 날 수도 있음.
(로제타를 사용해서 열기 체크)
arch -arm64 brew install nginx
nginx가 설치되었다면 다음 php를 설치한다. (2022년 5월 9일 현재 8.0 버젼 설치됨)
arch -arm64 brew install php
둘다 설치가 되었다면 nginx -v, php -v를 명령하여 설치를 확인한다.
아래 그림처럼 나왔다면 제대로 설치된거임.

설치 이후에는 nginx, php를 구동시켜줘야함.
brew services 명령하면 아래 그림처럼 초록색 started가 나오면 제대로 둘다 작동중인거임.
brew services start nginx
brew services start php
// 서비스 시작 이후 제대로 실행되고 있는지 확인
brew services

nginx는 설치 이후 기본 8080포트로 페이지를 확인할 수 있음.
아래 명령으로 'It works!'페이지가 뜨는것을 확인한다.
localhost:8080
페이지가 위치하는 경로는
opt/homebrew/var/www 에 위치하고 있었다.
위 경로로 들어가보면 index.html이 생성되어 있다.
이제 nginx와 php를 연동해줘야함.
nginx.conf 파일을 수정해줘야함. 파일 경로는 opt/homebrew/etc/nginx에 있다.
두가지 영역을 변경해줘야 하는데
첫번째는 location / 부분에 index의 php확장자 추가.
두번째는 location ~ \.php$ 부분의 fastcgi_param SCRIPT_FILENAME 의 경로 수정. ($document_root$...)
요렇게 해주고 brew services restart nginx, brew services restart php@8.0 해주고 브라우저에서 PHP가 제대로
뜨는지 확인한다. <?php phpinfo(); ?>
//root경로를 변경해주려면 45줄을 변경해주면된다.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php; //index.php 추가
}
#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 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
#
// 아래 부분 주석 다 풀어줌. 그리고 73번줄에 SCRIPT_FILENAME 뒤에
// /scripts를 $document_root로 바꿔준다
#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;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}'👉 Linux' 카테고리의 다른 글
| systemd가 뭔가요? 도커에서는 왜 systemd를 지원하지 않나요? (0) | 2025.04.04 |
|---|---|
| 리눅스 우분투 apt install 이 안될때 (0) | 2025.04.04 |
| Crontab을 사용하여 MySQL 데이터를 안전하게 업데이트하는 방법 (0) | 2024.07.05 |
| [Atlassian] bitbucket 빗버킷 SSH키 등록하기. (0) | 2022.08.03 |
| [리눅스] PHP설치 후 html확장자 파일도 사용하기 (0) | 2022.05.11 |