Forked from jfernandes-dtm/gist:319f9d9233e1783dc41ccb836a0c5d47
Created
June 16, 2021 06:13
-
-
Save unkray/48ef509e6bb78372b246c5f7cada42aa to your computer and use it in GitHub Desktop.
Revisions
-
johnantoni revised this gist
Jun 12, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ We will need to add some extra php formulas to `brew` so that we can install PHP brew tap homebrew/dupes brew tap josegonzalez/homebrew-php **tip**: to uninstall a tap do brew untap xyz -
johnantoni revised this gist
Jun 12, 2016 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,10 @@ We will need to add some extra php formulas to `brew` so that we can install PHP brew tap homebrew/dupes brew tap josegonzalez/homebrew-php tip: to uninstall a tap do brew untap xyz We can now install php: brew install --without-apache --with-fpm --with-mysql php56 -
johnantoni revised this gist
Jun 8, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,12 +41,12 @@ This will compile PHP on your machine and may take a few minutes. Make sure you use the version number that got installed previously: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ Start PHP-FPM: launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist Check that PHP-FPM is listening on port 9000: lsof -Pni4 | grep LISTEN | grep php -
johnantoni revised this gist
Jun 8, 2016 . No changes.There are no files selected for viewing
-
johnantoni revised this gist
Jun 8, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ This will compile PHP on your machine and may take a few minutes. Make sure you use the version number that got installed previously: mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/php56/5.6.22/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ Start PHP-FPM: -
johnantoni revised this gist
Jun 8, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,11 +41,11 @@ This will compile PHP on your machine and may take a few minutes. Make sure you use the version number that got installed previously: mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/php55/5.5.18/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ Start PHP-FPM: launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist Check that PHP-FPM is listening on port 9000: -
johnantoni revised this gist
Jun 8, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ We will need to add some extra php formulas to `brew` so that we can install PHP We can now install php: brew install --without-apache --with-fpm --with-mysql php56 This will compile PHP on your machine and may take a few minutes. -
mgmilcher revised this gist
Oct 26, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -196,13 +196,13 @@ Start Nginx again: Thats it, everything should be up and running. Click on the links below to ensure that: - [http://localhost](http://localhost) → “Nginx works” page - [http://localhost/info](http://localhost/info) → phpinfo() - [http://localhost/nope](http://localhost/nope) → ” Not Found” page - [https://localhost:443](https://localhost:443) → “Nginx works” page (SSL) - [https://localhost:443/info](https://localhost:443/info) → phpinfo() (SSL) - [https://localhost:443/nope](https://localhost:443/nope) → “Not Found” page (SSL) - [https://localhost:306](https://localhost:306) → phpMyAdmin (SSL) ## Control your services like a boss -
mgmilcher revised this gist
Oct 26, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -196,13 +196,13 @@ Start Nginx again: Thats it, everything should be up and running. Click on the links below to ensure that: -[http://localhost](http://localhost) → “Nginx works” page -[http://localhost/info](http://localhost/info) → phpinfo() -[http://localhost/nope](http://localhost/nope) → ” Not Found” page -[https://localhost:443](https://localhost:443) → “Nginx works” page (SSL) -[https://localhost:443/info](https://localhost:443/info) → phpinfo() (SSL) -[https://localhost:443/nope](https://localhost:443/nope) → “Not Found” page (SSL) -[https://localhost:306](https://localhost:306) → phpMyAdmin (SSL) ## Control your services like a boss -
mgmilcher revised this gist
Oct 26, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -196,13 +196,13 @@ Start Nginx again: Thats it, everything should be up and running. Click on the links below to ensure that: [http://localhost](http://localhost) → “Nginx works” page [http://localhost/info](http://localhost/info) → phpinfo() [http://localhost/nope](http://localhost/nope) → ” Not Found” page [https://localhost:443](https://localhost:443) → “Nginx works” page (SSL) [https://localhost:443/info](https://localhost:443/info) → phpinfo() (SSL) [https://localhost:443/nope](https://localhost:443/nope) → “Not Found” page (SSL) [https://localhost:306](https://localhost:306) → phpMyAdmin (SSL) ## Control your services like a boss -
mgmilcher created this gist
Oct 26, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,256 @@ This is my take on how to get up and running with NGINX, PHP-FPM, MySQL and phpMyAdmin on OSX Yosemite. This article is adapted from the [original by Jonas Friedmann](http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/). Who I just discovered is from Würzburg in Germany. A stonesthrow from where I was born ;) ## Xcode Make sure you have the latest version of XCode installed. [Available from the Mac App Store](https://itunes.apple.com/gb/app/xcode/id497799835?mt=12). Install the Xcode Command Line Tools: xcode-select --install ## Homebrew [Homebrew](http://brew.sh/) is the missing package manager for OSX. Download and install using the following command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Check for any problems or conflicts: brew doctor Update and Upgrade `brew` formulas: brew update && brew upgrade ## PHP-FPM We will need to add some extra php formulas to `brew` so that we can install PHP and PHP-FPM: brew tap homebrew/dupes brew tap josegonzalez/homebrew-php We can now install php: brew install --without-apache --with-fpm --with-mysql php55 This will compile PHP on your machine and may take a few minutes. #### Setup auto start Make sure you use the version number that got installed previously: mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/php55/5.5.18/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/ Start PHP-FPM: launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist Check that PHP-FPM is listening on port 9000: lsof -Pni4 | grep LISTEN | grep php ## MySQL brew install mysql #### Setup auto start ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents And start the database server: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist #### Secure the installation mysql_secure_installation #### Test the connection mysql -uroot -p ## phpMyAdmin brew install phpmyadmin ## NGINX brew install nginx #### Setup auto start Since we want to use port 80 have to start the Nginx process as root: sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/ sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist #### Test web server Start Nginx for the first time: sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist The default configuration is set that it will listen on port 8080 instead of the HTTP standard 80. Ignore that for now: curl -IL http://localhost:8080 The output should look like: ``` HTTP/1.1 200 OK Server: nginx/1.6.0 Date: Tue, 08 Jul 2014 21:40:38 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 08 Jul 2014 21:35:25 GMT Connection: keep-alive ETag: "53bc641d-264" Accept-Ranges: bytes ``` Stop Nginx again: sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist ## Configurations #### nginx.conf Create some folders which we are going to use in the configuration files: ``` mkdir -p /usr/local/etc/nginx/logs mkdir -p /usr/local/etc/nginx/sites-available mkdir -p /usr/local/etc/nginx/sites-enabled mkdir -p /usr/local/etc/nginx/conf.d mkdir -p /usr/local/etc/nginx/ssl sudo mkdir -p /var/www sudo chown :staff /var/www sudo chmod 775 /var/www ``` Remove the current default nginx.conf (also available as `/usr/local/etc/nginx/nginx.conf.default` in case you want to take a look) and download this custom one via curl from GitHub: rm /usr/local/etc/nginx/nginx.conf curl -L https://gist.github.com/frdmn/7853158/raw/nginx.conf -o /usr/local/etc/nginx/nginx.conf Download the following PHP-FPM configuration from GitHub: curl -L https://gist.github.com/frdmn/7853158/raw/php-fpm -o /usr/local/etc/nginx/conf.d/php-fpm #### Create default virtual hosts ``` curl -L https://gist.github.com/frdmn/7853158/raw/sites-available_default -o /usr/local/etc/nginx/sites-available/default curl -L https://gist.github.com/frdmn/7853158/raw/sites-available_default-ssl -o /usr/local/etc/nginx/sites-available/default-ssl curl -L https://gist.github.com/frdmn/7853158/raw/sites-available_phpmyadmin -o /usr/local/etc/nginx/sites-available/phpmyadmin ``` Clone my example virtual host (including 404, 403, and phpinfo() rewrite) using git ``` git clone https://github.com/gil0mendes/nginx-virtual-host.git /var/www rm -rf /var/www/.git ``` #### Setup SSL Create folder for our SSL certificates and private keys: mkdir -p /usr/local/etc/nginx/ssl Generate 4096bit RSA keys and the self-sign the certificates in one command: ``` openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj '/C=US/ST=State/L=Town/O=Office/CN=localhost' -keyout /usr/local/etc/nginx/ssl/localhost.key -out /usr/local/etc/nginx/ssl/localhost.crt openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj '/C=US/ST=State/L=Town/O=Office/CN=phpmyadmin' -keyout /usr/local/etc/nginx/ssl/phpmyadmin.key -out /usr/local/etc/nginx/ssl/phpmyadmin.crt ``` #### Enable virtual hosts Now we need to symlink the virtual hosts that we want to enable into the sites-enabled folder: ``` ln -sfv /usr/local/etc/nginx/sites-available/default /usr/local/etc/nginx/sites-enabled/default ln -sfv /usr/local/etc/nginx/sites-available/default-ssl /usr/local/etc/nginx/sites-enabled/default-ssl ln -sfv /usr/local/etc/nginx/sites-available/phpmyadmin /usr/local/etc/nginx/sites-enabled/phpmyadmin ``` Start Nginx again: sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist #### Final tests Thats it, everything should be up and running. Click on the links below to ensure that: http://localhost → “Nginx works” page http://localhost/info → phpinfo() http://localhost/nope → ” Not Found” page https://localhost:443 → “Nginx works” page (SSL) https://localhost:443/info → phpinfo() (SSL) https://localhost:443/nope → “Not Found” page (SSL) https://localhost:306 → phpMyAdmin (SSL) ## Control your services like a boss Because you probably need to restart the one or other service sooner or later, you probably want to set up some alias. Download aliases: ``` curl -L https://gist.github.com/mgmilcher/c3a1d0138dde3eb0f429/raw/ed04e90d7770dbb62c60e1e4a912f75adc46cb5e/osx-server-aliases -o /tmp/.aliases ``` For bash: cat /tmp/.aliases >> ~/.profile For zsh: cat /tmp/.aliases >> ~/.zshrc Close and open the terminal or type `source ~/.profile` or `source ~/.zshrc` to reload the profile. The following commands are now available #### Nginx ``` nginx.start nginx.stop nginx.restart ``` #### PHP-FPM ``` php-fpm.start php-fpm.stop php-fpm.restart ``` #### MySQL ``` mysql.start mysql.stop mysql.restart ``` #### Nginx Logs ``` nginx.logs.error nginx.logs.access nginx.logs.default.access nginx.logs.default-ssl.access nginx.logs.phpmyadmin.access ```