-
-
Save pxdsgnco/1f32a52c54173039a83870688f5245ef to your computer and use it in GitHub Desktop.
Install valet-plus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#styles | |
VP_NONE='\033[00m' | |
VP_RED='\033[01;31m' | |
VP_GREEN='\033[01;32m' | |
VP_YELLOW='\033[01;33m' | |
VP_PURPLE='\033[01;35m' | |
VP_CYAN='\033[01;36m' | |
VP_WHITE='\033[01;37m' | |
VP_BOLD='\033[1m' | |
VP_UNDERLINE='\033[4m' | |
#check for any running services that need to be killed before running | |
ds=`ps aux | grep DesktopServer.app | grep -v grep| head -1` | |
flywheel=`ps aux | grep "Local by Flywheel.app" | grep -v grep| head -1` | |
xamp=`ps aux | grep -i "xamp" | grep -v grep| head -1` | |
mamp=`ps aux | grep -i "mamp" | grep -v grep| head -1` | |
dnsmasq=`ps aux | grep dnsmasq | grep -v grep| head -1` | |
nginx=`ps aux | grep nginx | grep -v grep| head -1` | |
php=`ps aux | grep php | grep -v grep| head -1` | |
mysql=`ps aux | grep mysql | grep -v grep| head -1` | |
msg="" | |
msg2="" | |
clear | |
# cache sudo password so it will only need to be entered once. | |
echo -e "${VP_RED}${VP_BOLD}You may be asked to enter your password twice….${VP_NONE}" | |
sudo -v | |
# if any services are found running, exit and print messages | |
if [[ $ds ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found ${VP_PURPLE}DesktopServer.app${VP_NONE} running"$'\n' | |
fi | |
if [[ $flywheel ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found ${VP_PURPLE}Local by Flywheel.app${VP_NONE} running"$'\n' | |
fi | |
if [[ $xamp ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found ${VP_PURPLE}XAMPP${VP_NONE} running"$'\n' | |
fi | |
if [[ $mamp ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found ${VP_PURPLE}MAMP${VP_NONE} running"$'\n' | |
fi | |
if [[ $dnsmasq ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found dnsmasq running"$'\n' | |
fi | |
if [[ $nginx ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found nginx running"$'\n' | |
fi | |
if [[ $php ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found php running"$'\n' | |
fi | |
if [[ $mysql ]]; then | |
msg+="${VP_RED}ERROR:${VP_NONE} found mysql running"$'\n' | |
fi | |
if [[ $msg ]]; then | |
echo -e "$msg" | |
msg2+="You need to stop the running services before you can install."$'\n' | |
if [[ $ds ]]; then | |
msg2+=" ${VP_RED}stop Desktop Server now${VP_NONE}"$'\n' | |
elif [[ $flywheel ]]; then | |
msg2+=" ${VP_RED}stop Flywheel Local now${VP_NONE}"$'\n' | |
elif [[ $xamp ]]; then | |
msg2+=" ${VP_RED}stop XAMP now${VP_NONE}"$'\n' | |
elif [[ $mamp ]]; then | |
msg2+=" ${VP_RED}stop MAMP now${VP_NONE}"$'\n' | |
else | |
msg2+=" run: ${VP_GREEN}brew stop${VP_NONE}"$'\n' | |
msg2+=" run: ${VP_GREEN}sudo launchctl unload homebrew.mxcl.dnsmasq.plist${VP_NONE}"$'\n' | |
msg2+="Or run: ${VP_CYAN}valet-plus-destroy${VP_NONE}"$'\n' | |
fi | |
echo -e "$msg2"$'\n' | |
echo " " | |
echo -e "${VP_GREEN}${VP_BOLD}user brew services list to see if any services are running${VP_NONE}" | |
brew services list | |
exit; | |
fi | |
# update Homebrew if present, otherwise install | |
which -s brew | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
echo -e "${VP_GREEN}Installing brew${VP_NONE}" | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
else | |
# upgrade homebrew formulas | |
echo -e "${VP_GREEN}Updating brew${VP_NONE}" | |
brew update | |
brew upgrade | |
# cleanup mess | |
brew doctor | |
brew cleanup | |
brew prune | |
fi | |
# install PHP 7.1 | |
brew install homebrew/php/php71 | |
# install Composer | |
brew install homebrew/php/composer | |
# install Valet+ with Composer | |
composer global require weprovide/valet-plus | |
echo $'\n\nexport PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile | |
export PATH="$HOME/.composer/vendor/bin:$PATH" | |
# install valet | |
valet install | |
# give time to process sleep 10 seconds | |
sleep 10 | |
# hard code php to use .user.ini in home directory | |
before='upload_max_filesize = 2M' | |
after='upload_max_filesize = 128M"; changed by dgs' | |
sed -i "s/${before}/${after}/g" /usr/local/etc/php/7.1/php.ini | |
# hard code php to use .user.ini in home directory | |
before='post_max_size = 8M' | |
after='post_max_size = 128M"; changed by dgs' | |
sed -i "s/${before}/${after}/g" /usr/local/etc/php/7.1/php.ini | |
# hard code php to use .user.ini in home directory | |
before=';user_ini.filename = ".user.ini"' | |
after='user_ini.filename = ".user.ini"; changed by dgs' | |
sed -i "s/${before}/${after}/g" /usr/local/etc/php/7.1/php.ini | |
# change the curl timeout | |
before='default_socket_timeout = 60' | |
after='default_socket_timeout = 300' | |
sed -i "s/${before}/${after}/g" /usr/local/etc/php/7.1/php.ini | |
# after makeing changes you must restart | |
valet restart | |
# if Valet+ is installed correctly you should see this domain responding on 127.0.0.1. | |
ping -c10 frodo-baggins.dev | |
# navigate to ~/Sites folder | |
cd ~/Sites | |
# park this folder i.e., register the current working directory as projects root | |
valet park | |
# create example folder | |
mkdir ~/Sites/example | |
#navigate to ~/Sites/example | |
cd ~/Sites/example | |
# create index.php with a sentence | |
echo "<?php echo 'Valet+ at your service';" > index.php | |
# serve the site over encrypted TLS using HTTP/2 | |
valet secure example | |
# launch the site in default browser | |
valet open example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment