맥북에서 M1 8GB를 쓰다가 M2 16GB로 넘어왔다.
8GB 메모리로 스톰에 프로젝트 몇 개 띄우고, 크롬 탭도 줄줄이 소시지로 열어놓으면 엄청나게 느려져서 출력 속도가 타이핑 속도를 못 따라오는 지경까지 이르렀다.
무거운 IDE 쓰려면 무조건 16GB로 가소서...
맥북은 새로운 기기를 사면 마이그레이션을 통해 새 기기로 모든 데이터를 옮길 수 있다.
새 맥북 실행시키면 마이그레이션 할지 물어보면서 상세하게 설명해주니 별도로 구글링을 할 필요도 없다.
파일 및 모든 설정이 옮겨져왔으나, 내 기존 M1의 OS는 Big Sur(version 11.1)이고 신규 M2는 Sonoma(version 14.2.1)이다.
Big Sur -> Monterey -> Ventura -> Sonoma까지 메이저 버전이 3번이나 변경되었네.
일단 기본적인 APM(Apache, PHP, MySQL) 먼저 확인했다.
이전에는 php 7.3을 썼는데, 새 기기에는 7.4로 설치했다.
(현재의 php 권장 버전은 8.2이나, 주로 진행하는 프로젝트들이 아직 7버전으로 사용 중이라
여차하면 8버전으로 쓰려고 7.4와 8.2 모두 설치했다.)
새 맥북을 키니 brew list에 아무것도 없어서 brew update를 진행하려다가, (기억은 안 나지만) 무슨 오류가 발생해서 삭제하고 재설치를 했다.
❯ /bin/bash -c "$(curl -fsSl https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" // 삭제
❯ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" // 설치
brew로 httpd와 php도 설치했다.
❯ brew install httpd
❯ brew install shivammathur/php/php@7.4 // brew install php@7.4 로는 설치 불가능
다음 명령어들은 중간중간 상태 및 설정 확인할 때 유용하다.
❯ brew services list // 실행 상태 확인
❯ brew info php@7.4 // httpd.conf 등 추가 설정 항목들 잘 알려줌
❯ httpd -S // vhost, run 설정 확인
❯ httpd -t // config 파일 오류여부 확인
brew info 최고여...
간혹 php.ini나 서버 루트가 어디였더라 기억이 안 날 경우 'brew info'와 'httpd -S' 를 통해 웬만한 경로는 확인할 수 있다.
❯ brew info php@7.4
==> shivammathur/php/php@7.4: stable 7.4.33 (bottled) [keg-only]
General-purpose scripting language
https://www.php.net/
Deprecated because it is a versioned formula!
/opt/homebrew/Cellar/php@7.4/7.4.33_5 (499 files, 72.9MB)
Poured from bottle on 2023-12-28 at 10:32:40
From: https://github.com/shivammathur/homebrew-php/blob/HEAD/Formula/php@7.4.rb
License: PHP-3.01
==> Dependencies
Build: bison ✘, httpd ✔, pkg-config ✘, re2c ✘
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl ✔, freetds ✔, gd ✔, gettext ✔, gmp ✔, icu4c ✔, krb5 ✔, libffi ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔, openssl@3 ✔, pcre2 ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/opt/homebrew/etc/php/7.4/
php@7.4 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have php@7.4 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc
For compilers to find php@7.4 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/php@7.4/lib"
export CPPFLAGS="-I/opt/homebrew/opt/php@7.4/include"
To restart shivammathur/php/php@7.4 after an upgrade:
brew services restart shivammathur/php/php@7.4
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/php@7.4/sbin/php-fpm --nodaemonize
아무것도 안하고 바로 brew httpd를 구동하니(brew services start httpd) list에서 확인 시 httpd status에 error 256이 나온다.
로그도 서버 루트인 homebrew 하위에 안 쌓이고, /var/log 밑에 쌓인다.
브라우저에 localhost는 계속 It Works! 를 보여준다.
범인은 내장 아파치였다...
brew의 httpd를 실행시키기 위해 내장 아파치를 중지시키고 다시 재구동하니 httpd status에 started가 보인다.
❯ sudo apachectl stop
❯ sudo /usr/sbin/apachectl stop // 'apachectl'이 왜인지 path에 없었나보다.. 이렇게 실행함!
그 외에는 httpd.conf랑 vhost, hosts, php.ini 등을 수정했다.
한번 정리해놓은 걸 보고 수정하니 좋더라.
https://shallwestudy.tistory.com/13
Mac M1에서 APM(Apache, PHP, MySQL) 설치하기
애플의 신상 M1에서 php 개발을 해보려고 한다. 신규 모델의 첫 번째 버전이라 시기상조일 순 있겠지만 신상은 언제나 짜릿해_☆ 기본적인 개발환경 구축을 위해 Apach, PHP, MySQL을 하나하나 설치해
shallwestudy.tistory.com
그리고 vhost 설정할 때 꼭 localhost는 상단에 위치하도록 하자.
마지막으로, 나의 사랑 xdebug 까지 설정하고 마무리했다.
M1에서 쓰던 xdebug를 그대로 M2에서는 사용할 수 없다고 하여 재설치했다.
예전에는 SDK를 다운받아 phpize(기억도 안남)로 복잡허게 설치했었는데, 이번에는 간단하게 설치했다.
https://xdebug.org/docs/install
Xdebug: Documentation » Installation
Installation This section describes on how to install Xdebug. How you install Xdebug depends on your system. There are the following possibilities: Installing on Linux # Installing Xdebug with a package manager is often the fastest way. Depending on your d
xdebug.org
❯ pecl install xdebug 17:20:57
pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.3.99), installed version is 7.4.33
No valid packages found
install failed
❯ pecl install xdebug-3.1.6 // 나는 php 7.4여서 예전버전으로 설치
php.ini를 보면 최상단에 zend_extension이 추가되었고, 추가 설정을 조금 더 넣었다.
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.start_with_request=yes
잘 설치됐는지 확인!
❯ php -v 17:30:00
PHP 7.4.33 (cli) (built: Dec 25 2023 15:17:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
❯ php -i | grep xdebug 17:30:08
xdebug
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
Enabled Features (through 'xdebug.mode' setting)
...
PhpStorm 설정과 xdebug.client_port가 동일한지 확인!
(PhpStorm 설정 경로: PHP > Debug > Xdebug)
마지막으로 PhpStorm에 break point 설정하고 잘 멈추는지 확인하면 xdebug 설정도 끝이 난다.
약 하루정도 M2 써본 후기로는, phpstorm 이나 크롬 아무리 많이 띄워도 버벅거림이 없다.
스트레스 받지 말고 메모리나 기기에는 돈을 쓰자는 교훈을 얻었다.
'MAC' 카테고리의 다른 글
Mac M1 - Xdebug 설치하기 (0) | 2021.03.09 |
---|---|
Mac M1에서 APM(Apache, PHP, MySQL) 설치하기 (1) | 2021.02.22 |