Skip to content

Instantly share code, notes, and snippets.

@joemackay
Forked from kitloong/mac-homebrew-lamp.md
Created October 7, 2022 12:50
Show Gist options
  • Select an option

  • Save joemackay/474dc2c4e58d01b0ee62e3655acb7c57 to your computer and use it in GitHub Desktop.

Select an option

Save joemackay/474dc2c4e58d01b0ee62e3655acb7c57 to your computer and use it in GitHub Desktop.

Revisions

  1. @kitloong kitloong revised this gist Sep 17, 2022. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -236,6 +236,11 @@ vi /opt/homebrew/etc/httpd/httpd.conf
    # Append at the end of the conf
    # Load phpMyAdmin configuration
    Include /opt/homebrew/etc/httpd/extra/phpmyadmin.conf
    ```

    Restart httpd

    ```
    brew services restart httpd
    ```

  2. @kitloong kitloong revised this gist Jul 23, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # !!! This guide was created with Macbook Pro M1. Path may vary for different or even same machine.

    # Install Homebrew

    ```
  3. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -88,10 +88,10 @@ Server version: Apache/2.4.52 (Unix)
    Server built: Dec 20 2021 13:35:09
    ```

    ## Create localhost.conf
    ## Create httpd-php.conf

    ```
    vi /opt/homebrew/etc/httpd/extra/localhost.conf
    vi /opt/homebrew/etc/httpd/extra/httpd-php.conf
    # Insert following
    DirectoryIndex index.php index.html # Add index.php
    @@ -116,8 +116,8 @@ LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
    LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
    # Append at the end of the conf
    # Load custom localhost configuration
    Include /opt/homebrew/etc/httpd/extra/localhost.conf
    # Load php fcgi configuration
    Include /opt/homebrew/etc/httpd/extra/httpd-php.conf
    brew services start httpd
    ```

    @@ -210,7 +210,7 @@ $cfg['LoginCookieValidity'] = 7*24*60*60;
    ## Create phpMyAdmin.conf

    ```
    vi /opt/homebrew/etc/httpd/extra/httpd-phpmyadmin.conf
    vi /opt/homebrew/etc/httpd/extra/phpmyadmin.conf
    # Insert following
    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    @@ -240,8 +240,7 @@ brew services restart httpd
    ## Validate

    ```
    # Open and check in browser
    http://localhost:8080/phpmyadmin
    curl -I http://localhost:8080/phpmyadmin
    ```

    ## Multi Hosts
  4. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -233,7 +233,7 @@ Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    vi /opt/homebrew/etc/httpd/httpd.conf
    # Append at the end of the conf
    # Load phpMyAdmin configuration
    Include /opt/homebrew/etc/httpd/extra/localhost.conf
    Include /opt/homebrew/etc/httpd/extra/phpmyadmin.conf
    brew services restart httpd
    ```

  5. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -233,7 +233,7 @@ Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    vi /opt/homebrew/etc/httpd/httpd.conf
    # Append at the end of the conf
    # Load phpMyAdmin configuration
    Include /usr/local/etc/httpd/extra/localhost.conf
    Include /opt/homebrew/etc/httpd/extra/localhost.conf
    brew services restart httpd
    ```

    @@ -247,7 +247,7 @@ http://localhost:8080/phpmyadmin
    ## Multi Hosts

    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    vi /opt/homebrew/etc/phpmyadmin/config.inc.php
    # Add
    $i++;
    @@ -264,7 +264,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
    ## Prefix credential in config (use at own risk!)

    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    vi /opt/homebrew/etc/phpmyadmin/config.inc.php
    $cfg['Servers'][$i]['auth_type'] = 'config'; # Use config
  6. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -93,7 +93,7 @@ Server built: Dec 20 2021 13:35:09
    ```
    vi /opt/homebrew/etc/httpd/extra/localhost.conf
    # Update config
    # Insert following
    DirectoryIndex index.php index.html # Add index.php
    # php-fpm default port
    @@ -115,8 +115,8 @@ LoadModule proxy_module lib/httpd/modules/mod_proxy.so
    LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
    LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
    # Add to bottom of the file
    # Load localhost conf
    # Append at the end of the conf
    # Load custom localhost configuration
    Include /opt/homebrew/etc/httpd/extra/localhost.conf
    brew services start httpd
    ```
    @@ -201,7 +201,7 @@ The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php
    ## Update config

    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    vi /opt/homebrew/etc/phpmyadmin.config.inc.php
    # Extend cookies lifetime
    $cfg['LoginCookieValidity'] = 7*24*60*60;
    @@ -210,11 +210,11 @@ $cfg['LoginCookieValidity'] = 7*24*60*60;
    ## Create phpMyAdmin.conf

    ```
    vi /usr/local/etc/httpd/extra/httpd-phpmyadmin.conf
    vi /opt/homebrew/etc/httpd/extra/httpd-phpmyadmin.conf
    # Add following
    Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
    # Insert following
    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    <Directory /opt/homebrew/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    @@ -225,14 +225,14 @@ Alias /phpmyadmin /usr/local/share/phpmyadmin
    Allow from all
    </IfModule>
    </Directory>
    vi /usr/local/etc/httpd/httpd.conf
    ```

    ## Load phpMyAdmin.conf in Apache

    ```
    # Add at file bottom
    # Load phpMyAdmin conf
    vi /opt/homebrew/etc/httpd/httpd.conf
    # Append at the end of the conf
    # Load phpMyAdmin configuration
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services restart httpd
    ```
  7. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -124,10 +124,9 @@ brew services start httpd
    ## Test

    ```
    echo "<?php echo phpinfo();" > /usr/local/var/www/phpinfo.php
    echo "<?php echo phpinfo();" > /opt/homebrew/var/www/info.php
    # Open and check in browser
    http://localhost:8080/phpinfo.php
    curl -I http://localhost:8080/info.php
    ```

    # Install [email protected]
  8. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -96,8 +96,8 @@ vi /opt/homebrew/etc/httpd/extra/localhost.conf
    # Update config
    DirectoryIndex index.php index.html # Add index.php
    # php-fpm default port
    <FilesMatch \.php$>
    # php-fpm default port
    SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
    ```
  9. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,8 @@ vi /opt/homebrew/etc/httpd/extra/localhost.conf
    DirectoryIndex index.php index.html # Add index.php
    <FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000" # php-fpm default port
    # php-fpm default port
    SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
    ```

  10. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -91,7 +91,7 @@ Server built: Dec 20 2021 13:35:09
    ## Create localhost.conf

    ```
    vi /usr/local/etc/httpd/extra/localhost.conf
    vi /opt/homebrew/etc/httpd/extra/localhost.conf
    # Update config
    DirectoryIndex index.php index.html # Add index.php
    @@ -104,10 +104,10 @@ DirectoryIndex index.php index.html # Add index.php
    ## Update Apache config

    ```
    vi /usr/local/etc/httpd/httpd.conf
    vi /opt/homebrew/etc/httpd/httpd.conf
    # Default listen to port 80
    Listen 80 # Port 80 common used by apps like Skype or Teams, change to other port such as 8080 for convenience.
    # Change listen to port 8080
    Listen 8080 # Port 80 common used by apps like Skype or Teams, change to other port such as 8080 for convenience.
    # Enable following modules by uncomment
    LoadModule proxy_module lib/httpd/modules/mod_proxy.so
    @@ -116,7 +116,7 @@ LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
    # Add to bottom of the file
    # Load localhost conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    Include /opt/homebrew/etc/httpd/extra/localhost.conf
    brew services start httpd
    ```

  11. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 12 additions and 9 deletions.
    21 changes: 12 additions & 9 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -42,22 +42,25 @@ Zend Engine v4.1.2, Copyright (c) Zend Technologies
    ## Update config

    ```
    php -i | grep "additional .ini"
    Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
    php -i | grep "additional .ini"
    Scan this dir for additional .ini files => /opt/homebrew/etc/php/8.1/conf.d
    # Instead of modify setting in default .ini file, /usr/local/etc/php/7.3/php.ini
    # You can vi new .ini file to /usr/local/etc/php/7.3/conf.d
    # Instead of modify setting in default .ini file, /opt/homebrew/etc/php/8.1/php.ini
    # You should vi new .ini file to /opt/homebrew/etc/php/8.1/conf.d
    # All .ini files in conf.d will be scanned and loaded
    # Example
    echo "memory_limit = 512M" > /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    echo "memory_limit = 512M" > /opt/homebrew/etc/php/8.1/conf.d/memory-limit.ini
    php -i | grep "Additional .ini files parsed"
    Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/memory_limit.ini # Loaded
    php --ini
    Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.1
    Loaded Configuration File: /opt/homebrew/etc/php/8.1/php.ini
    Scan for additional .ini files in: /opt/homebrew/etc/php/8.1/conf.d
    Additional .ini files parsed: /opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini,
    /opt/homebrew/etc/php/8.1/conf.d/memory-limit.ini
    php -i | grep "memory_limit"
    /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    memory_limit => 1024M => 1024M
    memory_limit => 512M => 512M
    ```

    # Install Apache
  12. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 212 additions and 166 deletions.
    378 changes: 212 additions & 166 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -1,180 +1,186 @@
    # Install Homebrew

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

    # Install PHP

    brew install php
    To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
    SetHandler application/x-httpd-php
    </FilesMatch>

    Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

    The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/

    To restart php after an upgrade:
    brew services restart php
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

    brew services restart php
    php --version
    PHP 8.1.2 (cli) (built: Jan 21 2022 04:34:01) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies
    ```
    brew install php
    ```
    ```
    To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
    <FilesMatch \.php$>
    SetHandler application/x-httpd-php
    </FilesMatch>
    Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html
    The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/
    To restart php after an upgrade:
    brew services restart php
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
    ```
    ```
    brew services restart php
    ```
    ```
    php --version
    PHP 8.1.2 (cli) (built: Jan 21 2022 04:34:01) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies
    ```

    ## Update config

    php -i | grep "additional .ini"
    Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d

    # Instead of modify setting in default .ini file, /usr/local/etc/php/7.3/php.ini
    # You can vi new .ini file to /usr/local/etc/php/7.3/conf.d
    # All .ini files in conf.d will be scanned and loaded
    # Example
    echo "memory_limit = 512M" > /usr/local/etc/php/7.3/conf.d/memory_limit.ini

    php -i | grep "Additional .ini files parsed"
    Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/memory_limit.ini # Loaded
    ```
    php -i | grep "additional .ini"
    Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
    # Instead of modify setting in default .ini file, /usr/local/etc/php/7.3/php.ini
    # You can vi new .ini file to /usr/local/etc/php/7.3/conf.d
    # All .ini files in conf.d will be scanned and loaded
    # Example
    echo "memory_limit = 512M" > /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    php -i | grep "memory_limit"
    /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    memory_limit => 1024M => 1024M
    php -i | grep "Additional .ini files parsed"
    Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/memory_limit.ini # Loaded
    php -i | grep "memory_limit"
    /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    memory_limit => 1024M => 1024M
    ```

    # Install Apache

    brew install httpd
    DocumentRoot is /opt/homebrew/var/www.

    The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
    /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

    To restart httpd after an upgrade:
    brew services restart httpd
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
    brew services restart httpd
    httpd -v
    Server version: Apache/2.4.52 (Unix)
    Server built: Dec 20 2021 13:35:09
    ```
    brew install httpd
    ```
    ```
    DocumentRoot is /opt/homebrew/var/www.
    The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
    /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
    To restart httpd after an upgrade:
    brew services restart httpd
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
    ```
    ```
    brew services restart httpd
    ```
    ```
    httpd -v
    Server version: Apache/2.4.52 (Unix)
    Server built: Dec 20 2021 13:35:09
    ```

    ## Create localhost.conf

    vi /usr/local/etc/httpd/extra/localhost.conf

    # Update config
    DirectoryIndex index.php index.html # Add index.php

    <FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000" # php-fpm default port
    </FilesMatch>
    ```
    vi /usr/local/etc/httpd/extra/localhost.conf
    # Update config
    DirectoryIndex index.php index.html # Add index.php
    <FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000" # php-fpm default port
    </FilesMatch>
    ```

    ## Update Apache config

    vi /usr/local/etc/httpd/httpd.conf

    # Default listen to port 80
    Listen 80 # Port 80 common used by apps like Skype or Teams, change to other port such as 8080 for convenience.

    # Enable following modules by uncomment
    LoadModule proxy_module lib/httpd/modules/mod_proxy.so
    LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
    LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

    # Add to bottom of the file
    # Load localhost conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services start httpd
    ```
    vi /usr/local/etc/httpd/httpd.conf
    # Default listen to port 80
    Listen 80 # Port 80 common used by apps like Skype or Teams, change to other port such as 8080 for convenience.
    # Enable following modules by uncomment
    LoadModule proxy_module lib/httpd/modules/mod_proxy.so
    LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
    LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
    # Add to bottom of the file
    # Load localhost conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services start httpd
    ```

    ## Test

    echo "<?php echo phpinfo();" > /usr/local/var/www/phpinfo.php

    # Open and check in browser
    http://localhost:8080/phpinfo.php
    ```
    echo "<?php echo phpinfo();" > /usr/local/var/www/phpinfo.php
    # Open and check in browser
    http://localhost:8080/phpinfo.php
    ```

    # Install [email protected]

    brew install [email protected]
    We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

    MySQL is configured to only allow connections from localhost by default
    ```
    brew install [email protected]
    ```
    ```
    We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation
    To connect run:
    mysql -uroot
    MySQL is configured to only allow connections from localhost by default
    [email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
    because this is an alternate version of another formula.
    To connect run:
    mysql -uroot
    If you need to have [email protected] first in your PATH, run:
    echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
    [email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
    because this is an alternate version of another formula.
    For compilers to find [email protected] you may need to set:
    export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
    If you need to have [email protected] first in your PATH, run:
    echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
    For compilers to find [email protected] you may need to set:
    export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
    To restart [email protected] after an upgrade:
    brew services restart [email protected]
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/[email protected]/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

    # Backup existing mysql localtion if needed
    ls -la $(which mysql)
    lrwxr-xr-x 1 liow.kitloong admin 36 Mar 11 2019 /usr/local/bin/mysql -> ../Cellar/[email protected]/5.7.25/bin/mysql
    # Link mysql to [email protected]
    brew link [email protected] --force

    brew services restart [email protected]

    mysql -V
    mysql Ver 14.14 Distrib 5.7.37, for osx10.16 (x86_64) using EditLine wrapper
    # Install phpMyAdmin
    To restart [email protected] after an upgrade:
    brew services restart [email protected]
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/[email protected]/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
    brew install phpmyadmin
    To enable phpMyAdmin in Apache, add the following to httpd.conf and
    restart Apache:
    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    <Directory /opt/homebrew/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
    Order allow,deny
    Allow from all
    </IfModule>
    </Directory>
    Then open http://localhost/phpmyadmin
    The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php
    # Backup existing mysql localtion if needed
    ls -la $(which mysql)
    lrwxr-xr-x 1 liow.kitloong admin 36 Mar 11 2019 /usr/local/bin/mysql -> ../Cellar/[email protected]/5.7.25/bin/mysql
    ```
    ```
    # Link mysql to [email protected]
    brew link [email protected] --force
    ## Update config
    brew services restart [email protected]
    ```
    ```
    mysql -V
    mysql Ver 14.14 Distrib 5.7.37, for osx10.16 (x86_64) using EditLine wrapper
    ```

    vi /usr/local/share/phpmyadmin/config.inc.php

    # Extend cookies lifetime
    $cfg['LoginCookieValidity'] = 7*24*60*60;
    # Install phpMyAdmin

    ## Create phpMyAdmin.conf

    vi /usr/local/etc/httpd/extra/httpd-phpmyadmin.conf

    # Add following
    Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
    ```
    brew install phpmyadmin
    ```
    ```
    To enable phpMyAdmin in Apache, add the following to httpd.conf and
    restart Apache:
    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    <Directory /opt/homebrew/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    @@ -185,40 +191,80 @@
    Allow from all
    </IfModule>
    </Directory>
    vi /usr/local/etc/httpd/httpd.conf
    Then open http://localhost/phpmyadmin
    The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php
    ```

    ## Update config

    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    # Extend cookies lifetime
    $cfg['LoginCookieValidity'] = 7*24*60*60;
    ```

    ## Create phpMyAdmin.conf

    ```
    vi /usr/local/etc/httpd/extra/httpd-phpmyadmin.conf
    # Add following
    Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
    Order allow,deny
    Allow from all
    </IfModule>
    </Directory>
    vi /usr/local/etc/httpd/httpd.conf
    ```

    ## Load phpMyAdmin.conf in Apache

    # Add at file bottom
    # Load phpMyAdmin conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services restart httpd
    ```
    # Add at file bottom
    # Load phpMyAdmin conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services restart httpd
    ```

    ## Validate

    # Open and check in browser
    http://localhost:8080/phpmyadmin
    ```
    # Open and check in browser
    http://localhost:8080/phpmyadmin
    ```

    ## Multi Hosts

    vi /usr/local/share/phpmyadmin/config.inc.php

    # Add
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'Server Name';
    $cfg['Servers'][$i]['host'] = '128.0.0.2'; // New host
    $cfg['Servers'][$i]['port'] = 3306;
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['AllowNoPassword'] = false;
    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    # Add
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'Server Name';
    $cfg['Servers'][$i]['host'] = '128.0.0.2'; // New host
    $cfg['Servers'][$i]['port'] = 3306;
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['AllowNoPassword'] = false;
    ```

    ## Prefix credential in config (use at own risk!)

    vi /usr/local/share/phpmyadmin/config.inc.php

    $cfg['Servers'][$i]['auth_type'] = 'config'; # Use config
    ```
    vi /usr/local/share/phpmyadmin/config.inc.php
    $cfg['Servers'][$i]['auth_type'] = 'config'; # Use config
    $cfg['Servers'][$i]['user'] = 'username';
    $cfg['Servers'][$i]['password'] = 'password';
    $cfg['Servers'][$i]['user'] = 'username';
    $cfg['Servers'][$i]['password'] = 'password';
    ```
  13. @kitloong kitloong revised this gist Feb 7, 2022. 1 changed file with 78 additions and 8 deletions.
    86 changes: 78 additions & 8 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -5,13 +5,30 @@
    # Install PHP

    brew install php
    brew services start php
    To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
    SetHandler application/x-httpd-php
    </FilesMatch>

    Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

    The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/

    To restart php after an upgrade:
    brew services restart php
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

    brew services restart php
    php --version

    PHP 7.3.5 (cli) (built: May 2 2019 12:42:24) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.5, Copyright (c) 1999-2018, by Zend Technologies
    PHP 8.1.2 (cli) (built: Jan 21 2022 04:34:01) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

    ## Update config

    @@ -35,6 +52,20 @@
    # Install Apache

    brew install httpd
    DocumentRoot is /opt/homebrew/var/www.

    The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
    /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

    To restart httpd after an upgrade:
    brew services restart httpd
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
    brew services restart httpd
    httpd -v
    Server version: Apache/2.4.52 (Unix)
    Server built: Dec 20 2021 13:35:09

    ## Create localhost.conf

    @@ -74,6 +105,29 @@
    # Install [email protected]

    brew install [email protected]
    We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

    MySQL is configured to only allow connections from localhost by default

    To connect run:
    mysql -uroot

    [email protected] is keg-only, which means it was not symlinked into /opt/homebrew,
    because this is an alternate version of another formula.

    If you need to have [email protected] first in your PATH, run:
    echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

    For compilers to find [email protected] you may need to set:
    export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"


    To restart [email protected] after an upgrade:
    brew services restart [email protected]
    Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/[email protected]/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

    # Backup existing mysql localtion if needed
    ls -la $(which mysql)
    @@ -82,14 +136,30 @@
    # Link mysql to [email protected]
    brew link [email protected] --force

    brew services start mysql
    brew services restart mysql@5.7

    mysql -V
    mysql Ver 14.14 Distrib 5.7.25, for osx10.13 (x86_64) using EditLine wrapper
    mysql Ver 14.14 Distrib 5.7.37, for osx10.16 (x86_64) using EditLine wrapper

    # Install phpMyAdmin

    brew install phpmyadmin
    To enable phpMyAdmin in Apache, add the following to httpd.conf and
    restart Apache:
    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    <Directory /opt/homebrew/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
    Order allow,deny
    Allow from all
    </IfModule>
    </Directory>
    Then open http://localhost/phpmyadmin
    The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php

    ## Update config

  14. @kitloong kitloong revised this gist Mar 4, 2020. 1 changed file with 152 additions and 1 deletion.
    153 changes: 152 additions & 1 deletion mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,154 @@
    # Install Homebrew

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

    # Install PHP

    brew install php
    brew services start php
    php --version

    PHP 7.3.5 (cli) (built: May 2 2019 12:42:24) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.5, Copyright (c) 1999-2018, by Zend Technologies

    ## Update config

    php -i | grep "additional .ini"
    Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d

    # Instead of modify setting in default .ini file, /usr/local/etc/php/7.3/php.ini
    # You can vi new .ini file to /usr/local/etc/php/7.3/conf.d
    # All .ini files in conf.d will be scanned and loaded
    # Example
    echo "memory_limit = 512M" > /usr/local/etc/php/7.3/conf.d/memory_limit.ini

    php -i | grep "Additional .ini files parsed"
    Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/memory_limit.ini # Loaded

    php -i | grep "memory_limit"
    /usr/local/etc/php/7.3/conf.d/memory_limit.ini
    memory_limit => 1024M => 1024M

    # Install Apache

    brew install httpd

    ## Create localhost.conf

    vi /usr/local/etc/httpd/extra/localhost.conf

    # Update config
    DirectoryIndex index.php index.html # Add index.php

    <FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000" # php-fpm default port
    </FilesMatch>

    ## Update Apache config

    vi /usr/local/etc/httpd/httpd.conf

    # Default listen to port 80
    Listen 80 # Port 80 common used by apps like Skype or Teams, change to other port such as 8080 for convenience.

    # Enable following modules by uncomment
    LoadModule proxy_module lib/httpd/modules/mod_proxy.so
    LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
    LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

    # Add to bottom of the file
    # Load localhost conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services start httpd

    ## Test

    echo "<?php echo phpinfo();" > /usr/local/var/www/phpinfo.php

    # Open and check in browser
    http://localhost:8080/phpinfo.php

    # Install [email protected]

    brew install [email protected]

    # Backup existing mysql localtion if needed
    ls -la $(which mysql)
    lrwxr-xr-x 1 liow.kitloong admin 36 Mar 11 2019 /usr/local/bin/mysql -> ../Cellar/[email protected]/5.7.25/bin/mysql
    # Link mysql to [email protected]
    brew link [email protected] --force

    brew services start mysql

    mysql -V
    mysql Ver 14.14 Distrib 5.7.25, for osx10.13 (x86_64) using EditLine wrapper

    # Install phpMyAdmin

    brew install phpmyadmin

    ## Update config

    vi /usr/local/share/phpmyadmin/config.inc.php

    # Extend cookies lifetime
    $cfg['LoginCookieValidity'] = 7*24*60*60;

    ## Create phpMyAdmin.conf

    vi /usr/local/etc/httpd/extra/httpd-phpmyadmin.conf

    # Add following
    Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
    Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
    Order allow,deny
    Allow from all
    </IfModule>
    </Directory>
    vi /usr/local/etc/httpd/httpd.conf

    ## Load phpMyAdmin.conf in Apache

    # Add at file bottom
    # Load phpMyAdmin conf
    Include /usr/local/etc/httpd/extra/localhost.conf
    brew services restart httpd

    ## Validate

    # Open and check in browser
    http://localhost:8080/phpmyadmin

    ## Multi Hosts

    vi /usr/local/share/phpmyadmin/config.inc.php

    # Add
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'Server Name';
    $cfg['Servers'][$i]['host'] = '128.0.0.2'; // New host
    $cfg['Servers'][$i]['port'] = 3306;
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['AllowNoPassword'] = false;

    ## Prefix credential in config (use at own risk!)

    vi /usr/local/share/phpmyadmin/config.inc.php

    $cfg['Servers'][$i]['auth_type'] = 'config'; # Use config

    $cfg['Servers'][$i]['user'] = 'username';
    $cfg['Servers'][$i]['password'] = 'password';
  15. @kitloong kitloong created this gist Mar 4, 2020.
    3 changes: 3 additions & 0 deletions mac-homebrew-lamp.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # Install Homebrew

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