LoginSignup
3
2

More than 1 year has passed since last update.

M1の環境構築

Posted at

はじめに

今回はM1Macで以下の開発を行うことを前提として環境構築を行います。

  • Laravel
  • Reactnative

インストール一覧
Intel時代はプリインストールされているものが多かったのですが、M1からは非搭載のものも多いので並べると多く感じますね。

  • Homebrew
  • git(Homebrewをインストールすると同時にインストールされます)
  • Visual Studio Code
  • Google Chrome
    ↑こちら2つは公式サイトからダウンロードしてインストールでもかまいません。
  • PHP
  • MySQL
  • Composer
  • Node.js
  • cocoapods
  • watchman

Macのスペック

MacBook Pro 13inch
OS: macOS Monterey12.4
チップ: Apple M1
メモリ: 8 GB
ストレージ:500GB

Homebrewのインストール

公式サイトトップページの記載のコマンドを実行

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrewのインストール完了後に指示が書いてあるので指示通りパス(path)を通します。

 echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/***/.zprofile
 eval "$(/opt/homebrew/bin/brew shellenv)"

インストール出来ているか確認①:Homebrew

 brew --version
Homebrew 3.4.11Homebrew/homebrew-core (git revision dbfa69dfe50; last commit 2022-05-17)

インストール出来ているか確認②:git
gitも一緒にインストールされるのでバージョン確認

 git --version
git version 2.32.1 (Apple Git-133)

Visual Studio Codeのインストール

brew install --cask visual-studio-code

Google Chromeのインストール

brew install --cask google-chrome

PHPのインストール

brew install php

インストール出来ているか確認

php -v
PHP 8.1.6 (cli) (built: May 12 2022 23:30:39) (NTS)Copyright (c) The PHP GroupZend Engine v4.1.6, Copyright (c) Zend Technologieswith Zend OPcache v8.1.6, Copyright (c), by Zend Technologies

MySQLのインストール

brew install mysql

SQLを起動(※Macの再起動後は自動で起動するので不要)

 brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

rootユーザーでログイン

 mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29 Homebrew

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL サーバーの接続を終了

mysql> quit
Bye

MySQL が動いているか確認

brew services list
Name Status User File
mysql started *** ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist php none

mysql の自動再起動の接続をストップ

brew services stop mysql
Stopping `mysql`... (might take a while) ==> Successfully stopped `mysql`
(label: homebrew.mxcl.mysql)

apache の場所とバージョン確認

 which apachectl
/usr/sbin/apachectl
 httpd -v
Server version: Apache/2.4.53 (Unix)
Server built:   Apr 19 2022 20:01:13  
apachectl -v
Server version: Apache/2.4.53 (Unix)
Server built:   Apr 19 2022 20:01:13

Laravel環境構築

Composerのインストール

brew install composer

インストール出来ているか確認

composer -v
Composer version 2.3.5 2022-04-13 16:43:00

Node.jsをHomebrewでインストール

brew install nodebrew

nodeのLTSをダウンロードしてインストール

nodeは公式のLTSバージョンをインストール

インストール出来ているか確認

npm -v
8.5.5

ios,androidアプリ作成の環境構築

React Native を作成

npx react-native init MyTestApp
Need to install the following packages:
react-native
Ok to proceed? (y) y
Welcome to React Native!
Learn once, write anywhere

cocoapods のインストールをするか聞かれるので yes

✔ CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary for the iOS project to run correctly. Do you want to install it? › Yes, with gem (may require sudo)
✖ Installing CocoaPods
error
✖ Installing CocoaPods
error Error: An error occured while trying to install CocoaPods, which is required by this template.
Please try again manually: sudo gem install cocoapods.

cocoapods のインストール(reactnative と同時インストールは失敗したため手動でインストール)

  sudo gem install cocoapods

  34 gems installed

watchmanのインストール

brew install watchman
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2