-
Docker
-
Git
# Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Install git
brew install git
- SSH Key
# create an ssh key of you don't have one already
ssh-keygen
eval "$(ssh-agent -s)"
- add your ~/.ssh/id_rsa.pub key to your github account
# backup old localhost
[ -d ~/localhost ] && mv ~/localhost ~/localhost-bkp
# clone localhost repo
mkdir ~/localhost && cd ~/localhost && git clone [email protected]:makehappen/localhost.git repo
sh ~/localhost/repo/src/install.sh
Up and running: http://localhost/
~/localhost/www/my-site
- loads at http://my-site.localhost
- from ~/localhost/www/my-site/public
~/localhost/www/my-site/www
- loads at http://www.my-site.localhost
- from ~/localhost/www/my-site/www/public
~/localhost/www/my-site/subdomain
- loads at http://subdomain.my-site.localhost
- from ~/localhost/www/my-site/subdomain/public
Add your websites to ~/localhost/hosts
file, mapped to 127.0.0.1
, and apply hosts file updates:
sh ~/localhost/repo/src/hosts.sh
Example:
127.0.0.1 www.topleveldomain.localhost
NOTE: this will overwrite your /etc/hosts file after creating a backup. If your /etc/hosts file contains websites you don't want to loose, copy your data before running the command above:
sudo cp /etc/hosts ~/localhost/hosts
# start servers
sh ~/localhost/repo/src/start.sh
# stop servers
sh ~/localhost/repo/src/stop.sh
# restarts servers
sh ~/localhost/repo/src/restart.sh
# re-build local images
sh ~/localhost/repo/src/build.sh
# update all servers
sh ~/localhost/repo/src/update.sh
sh ~/localhost/repo/src/hosts.sh
- Host: mysql_container
- Port: 3306
- Host: 0.0.0.0
- Port: 6603
- User: root
- Password: mypassword
- DB Files: ~/localhost/lib/mysql
- Host: redis_container
- Host: 0.0.0.0
- Port: 6379
# SSH into web server
docker exec -i -t server_container /bin/bash
# Exit web server
exit
- Websites folder: ~/localhost/www
- web server /var/www folder mounts it
- Logs: ~/localhost/log/apache2
- Ubuntu
- PHP
- Apache2
- MySql 5.7
- Redis (latest)
- Composer
- NodeJs
# create docker images (if not built already)
sh ~/localhost/repo/src/build.sh
# start servers (if not started)
sh ~/localhost/repo/src/start.sh
# Use PHP 7.1
sh ~/localhost/repo/src/start-web.sh web-server-php7.1
# Use PHP 7.4
sh ~/localhost/repo/src/start-web.sh web-server-php7.4
# Use PHP 8.1
sh ~/localhost/repo/src/start-web.sh web-server-php8.1
# temp fix: 1. ssh into docker container 2. run `service php8.1-fpm start`
# 1. ssh in
docker exec -i -t server_container /bin/bash
# 2. add your package (may need `apt-get update` before intalling)
# 3. add install command to Dockerfile with RUN and do a PR to be considered for the public repo
.bash_profile
export PATH=/usr/local/php5/bin:$PATH
alias docker-start='sh ~/localhost/repo/src/start.sh'
alias docker-stop='sh ~/localhost/repo/src/stop.sh'
alias docker-update='sh ~/localhost/repo/src/update.sh'
alias docker-sshin='docker exec -i -t server_container /bin/bash'
alias docker-php7.1='sh ~/localhost/repo/src/start-web.sh web-server-php7.1'
alias docker-php7.4='sh ~/localhost/repo/src/start-web.sh web-server-php7.4'
alias docker-php8.1='sh ~/localhost/repo/src/start-web.sh web-server-php8.1'