Mac+HomeBrew+Nginx+PHP+MariaDB

By admin, 16 十二月, 2022

Nginx

Docroot is: /usr/local/var/www

 

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that

nginx can run without sudo.

 

nginx will load all files in /usr/local/etc/nginx/servers/.

 

To restart nginx after an upgrade:

  brew services restart nginx

Or, if you don't want/need a background service you can just run:

  /usr/local/opt/nginx/bin/nginx -g daemon off;

PHP 8.2

To enable PHP in Apache add the following to httpd.conf and restart Apache:

    LoadModule php_module /usr/local/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:

    /usr/local/etc/php/8.2/

 

To restart php after an upgrade:

  brew services restart php

Or, if you don't want/need a background service you can just run:

  /usr/local/opt/php/sbin/php-fpm --nodaemonize

 MariaDB

如果以前装过不干净的版本,需要卸载:

brew remove mariadb

brew cleanup

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

rm ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

sudo rm -rf /usr/local/var/mysql

rm /usr/local/etc/my.cnf

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink bin/mysql

Target /usr/local/bin/mysql

already exists. You may want to remove it:

  rm '/usr/local/bin/mysql'

 

To force the link and overwrite all conflicting files:

  brew link --overwrite mariadb

 

To list all files that would be deleted:

  brew link --overwrite --dry-run mariadb

 

Possible conflicting files are:

/usr/local/bin/mysql -> /Applications/MAMP/Library/bin/mysql

/usr/local/bin/mysqldump -> /Applications/MAMP/Library/bin/mysqldump

==> /usr/local/Cellar/mariadb/10.10.2/bin/mysql_install_db --verbose --user=hgneng --basedir=/usr/local/Cellar/mariadb/10.10.2 --datadir=/usr/local/var/mysql --tmpdir=/tmp

Last 15 lines from /Users/hgneng/Library/Logs/Homebrew/mariadb/post_install.01.mysql_install_db:

 

    shell> /usr/local/Cellar/mariadb/10.10.2/bin/mysql -u root mysql

    mysql> show tables;

 

Try 'mysqld --help' if you have problems with paths.  Using

--general-log gives you a log in /usr/local/var/mysql that may be helpful.

 

The latest information about mysql_install_db is available at

https://mariadb.com/kb/en/installing-system-tables-mysql_install_db

You can find the latest source at https://downloads.mariadb.org and

the maria-discuss email list at https://launchpad.net/~maria-discuss

 

Please check all of the above before submitting a bug report

at https://mariadb.org/jira

 

Warning: The post-install step did not complete successfully

You can try again using:

  brew postinstall mariadb

==> Caveats

A "/etc/my.cnf" from another install may interfere with a Homebrew-built

server starting up correctly.

 

MySQL is configured to only allow connections from localhost by default

 

To restart mariadb after an upgrade:

  brew services restart mariadb

Or, if you don't want/need a background service you can just run:

  /usr/local/opt/mariadb/bin/mysqld_safe --datadir=/usr/local/var/mysql

==> Summary

🍺  /usr/local/Cellar/mariadb/10.10.2: 932 files, 220.9MB

==> Running `brew cleanup mariadb`...

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

==> Caveats

==> mariadb

A "/etc/my.cnf" from another install may interfere with a Homebrew-built

server starting up correctly.

 

MySQL is configured to only allow connections from localhost by default

 

To restart mariadb after an upgrade:

  brew services restart mariadb

Or, if you don't want/need a background service you can just run:

  /usr/local/opt/mariadb/bin/mysqld_safe --datadir=/usr/local/var/mysql

在Nginx中配置PHP (/usr/local/etc/nginx/nginx.conf)

(注意路径/usr/local/var/www/$fastcgi_script_name;)

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php[?]* {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /usr/local/var/www/$fastcgi_script_name;

            include        fastcgi_params;

        }

 

        location ~ ^/drupal10/ {

                try_files $uri $uri/ /drupal10/index.php?$query_string;

        }

启动服务

 

brew services start nginx

brew services start php-fpm

brew services start mariadb

 

 

标签

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"

最新评论