Skip to content

Instantly share code, notes, and snippets.

@ozanmora
Last active May 8, 2023 02:18
Show Gist options
  • Save ozanmora/9167151fdeb44ec548d77e270b6660a6 to your computer and use it in GitHub Desktop.
Save ozanmora/9167151fdeb44ec548d77e270b6660a6 to your computer and use it in GitHub Desktop.
MacOS Clean Install Settings & Applications

MacOS Clean Install Settings & Applications

Homebrew, applications, web server, oh my zsh and more..

Applications with Homebrew

xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew --version
#Homebrew 3.1.5
brew doctor
#Your system is ready to brew.
brew update && brew update --cask
brew upgrade && brew upgrade --cask
brew cleanup
brew install wget openssl
brew install --cask alfred the-unarchiver iterm2 termius transmission vlc scroll-reverser zoom
brew install --cask google-chrome firefox opera yandex
brew install --cask visual-studio-code sublime-text sublime-merge phpstorm
brew install --cask dropbox tuxera-ntfs
brew install --cask dbeaver-community
brew install --cask mysqlworkbench
brew install --cask adobe-creative-cloud
brew install git-flow composer nodejs

Applications

Web Server Installation

Mysql Install

brew install mysql
brew services start mysql
brew services list
code /usr/local/etc/my.cnf
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1

# Add mode only if needed
sql_mode = ""
mysql_secure_installation
brew services restart mysql
mysql -u root -ppassword
mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
mysql> exit;

Postgresql Install

brew install postgresql
brew services start postgresql
brew services list
psql postgres
postgres=# \du
postgres=# exit;

Apache Install

sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDeamons/org.apache.httpd.plist 2>/dev/null
brew install httpd
brew services start httpd
brew services list
http://localhost:8080
ps -aef | grep httpd
tail -f /usr/local/var/log/httpd/error_log
code /usr/local/etc/httpd/httpd.conf
Listen 8080 -> Listen 80

DocumentRoot "/usr/local/var/www" -> DocumentRoot "/Users/your_user/Sites"

<Directory "/usr/local/var/www"> --> <Directory "/Users/your_user/Sites">

Options Indexes FollowSymLinks -> Options -Indexes +FollowSymLinks

AllowOverride None -> AllowOverride All

#LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so -> LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

User _www -> User your_user
Group _www -> Group staff

#ServerName www.example.com:8080 -> ServerName localhost
mkdir ~/Sites
echo "<h1>My User Web Root</h1>" > ~/Sites/index.html
brew services restart httpd
rm -Rf /usr/local/var/log/httpd/*

PHP Install

brew tap shivammathur/php
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
code /usr/local/etc/php/5.6/php.ini
code /usr/local/etc/php/7.2/php.ini
code /usr/local/etc/php/7.4/php.ini
code /usr/local/etc/php/8.0/php.ini
brew unlink php && brew link --overwrite --force [email protected]
brew unlink php && brew link --overwrite --force [email protected]
brew unlink php && brew link --overwrite --force [email protected]
brew unlink php && brew link --overwrite --force [email protected]
php -v
code /usr/local/etc/httpd/httpd.conf
#LoadModule php5_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.so
#LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
#LoadModule php_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp.so
#LoadModule php_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp.so

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

->

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
echo "<?php phpinfo();" > ~/Sites/info.php
http://localhost/info.php
curl -L https://gist.github.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

If you don't see this, first try closing your terminal and restarting it. If that doesn't work, check that you have /usr/local/bin before /usr/bin and /usr/local/sbin before /usr/sbin in the path definition of your ~/.zshrc file. You can do it temporarily in the shell by typing:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH
sphp 5.6
sphp 7.2
sphp 7.4
sphp 8.0
brew info [email protected]
php -m | grep pgsql
brew install autoconf
https://gist.github.com/giorgiofellipe/6282df335fd310de4108

Apache Virtual Hosts & Other Things

LoadModule alias_module lib/httpd/modules/mod_alias.so
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
LoadModule setenvif_module lib/httpd/modules/mod_setenvif.so
LoadModule expires_module lib/httpd/modules/mod_expires.so
LoadModule headers_module lib/httpd/modules/mod_headers.so
LoadModule env_module lib/httpd/modules/mod_env.so
LoadModule deflate_module lib/httpd/modules/mod_deflate.so
LoadModule filter_module lib/httpd/modules/mod_filter.so

Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
Include /usr/local/etc/httpd/extra/vhosts/*.conf
mkdir /usr/local/etc/httpd/extra/vhosts
code /usr/local/etc/httpd/extra/vhosts/000-default.conf
<VirtualHost *:80>
    DocumentRoot "/Users/your_user/Sites"
    ServerName localhost
</VirtualHost>
mkdir ~/Sites/your_domain.lan
code /usr/local/etc/httpd/extra/vhosts/your_domain.lan.conf
<VirtualHost *:80>
    DocumentRoot "/Users/your_user/Sites/your_domain.lan"
    ServerName your_domain.lan
</VirtualHost>
brew services restart httpd

Redis Install

brew install redis
sudo brew services start redis

Dnsmasq Install

brew install dnsmasq
echo 'address=/.lan/127.0.0.1' > /usr/local/etc/dnsmasq.conf
sudo brew services start dnsmasq
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/lan'
ping your_domain.lan

PHP-FPM

LoadModule proxy_module libexec/mod_proxy.so 
LoadModule proxy_fcgi_module libexec/mod_proxy_fcgi.so 
LoadModule rewrite_module libexec/mod_rewrite.so
<VirtualHost *:*>
   ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9074/Users/your_user/Sites/$1"
</VirtualHost>

<FilesMatch \.php$>
    # 2.4.10+ can proxy to unix socket
    # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
    # Else we can just use a tcp socket:
    SetHandler "proxy:fcgi://127.0.0.1:9074"
</FilesMatch>
code /usr/local/etc/php/7.4/php-fpm.d/www.conf
listen = 127.0.0.1:9000

listen = 127.0.0.1:9074

---

user = _www
group = _www

user = your_user
group = staff
brew services restart httpd
brew services start [email protected]
brew services restart [email protected]

Check Services

Name       Status  User  Plist
dnsmasq    unknown root  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
httpd      started your_user /Users/your_user/Library/LaunchAgents/homebrew.mxcl.httpd.plist
mysql      started your_user /Users/your_user/Library/LaunchAgents/homebrew.mxcl.mysql.plist
php        error   your_user /Users/your_user/Library/LaunchAgents/homebrew.mxcl.php.plist
[email protected]    started your_user /Users/your_user/Library/LaunchAgents/[email protected]
[email protected]    started your_user /Users/your_user/Library/LaunchAgents/[email protected]
[email protected]    started your_user /Users/your_user/Library/LaunchAgents/[email protected]
[email protected]    started your_user /Users/your_user/Library/LaunchAgents/[email protected]
postgresql started your_user /Users/your_user/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
redis      started your_user /Users/your_user/Library/LaunchAgents/homebrew.mxcl.redis.plist

Oh My Zsh Installation

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
upgrade_oh_my_zsh
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
code ~/.zshrc
ZSH_THEME="powerlevel9k/powerlevel9k"

# Before source $ZSH/oh-my-zsh.sh
ZSH_DISABLE_COMPFIX=true
git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh

iTerm2 > Preferences > Profiles > Text > Change Font FiraCode, check the “Use ligatures”

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/bobthecow/git-flow-completion ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/git-flow-completion
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
code ~/.zshrc
plugins=(
    git
    git-flow-completion
    zsh-syntax-highlighting
    zsh-autosuggestions
    zsh-completions
)
source ~/.zshrc
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
code ~/.zshrc
ZSH_THEME="spaceship"
source ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment