mac安装php8和apache

如果自己在mac安装php,会涉及证书问题,而用brew方法安装,即可自动关联,省心省力 

删除mac自带的apache

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

安装php最新版和apache 

brew install php
brew install httpd

# 网站根目录:/usr/local/var/www

# http配置文件:/usr/local/etc/httpd/httpd.conf,默认端口8080

# https配置文件:/usr/local/etc/httpd/extra/httpd-ssl.conf,端口443

 在httpd.conf最后添加,激活php

LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

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

常用命令

查看服务器列表
brew services list

brew services start httpd  # 启动

brew services restart httpd  # 重启服务
上述为通用重启命令,即:brew services restart xxxxxxxx

brew services stop httpd  # 停止服务

卸载
brew uninstall httpd
重新安装
brew reinstall httpd

httpd安装后的信息

DocumentRoot is /usr/local/var/www.

The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/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:
  /usr/local/opt/httpd/bin/httpd -D FOREGROUND
==> Summary
🍺  /usr/local/Cellar/httpd/2.4.57: 1,663 files, 31.7MB
==> Running `brew cleanup httpd`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

php安装后信息

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
==> Summary
🍺  /usr/local/Cellar/php/8.2.5: 520 files, 81.6MB
==> Running `brew cleanup php`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> php
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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Apache和MySQL的步骤如下: 1. 首先,创建一个名为wamp的文件夹(可以使用其他名称,但不要包含中文字符),将ApachePHP和MySQL安装文件下载到该文件夹中,并解压缩它们。 2. 找到Apache的配置文件httpd.conf(一般位于Apache安装目录的conf文件夹下),打开该文件。 3. 在httpd.conf文件中,找到LoadModule语句,确保以下模块已启用: - mod_so.so(用于动态加载其他模块) - mod_rewrite.so(用于URL重写) - mod_alias.so(用于定义别名) - mod_authz_core.so(用于授权控制) - mod_authz_host.so(用于主机授权) 4. 找到DocumentRoot语句,将其设置为你想要作为Web服务器根目录的文件夹路径。 5. 找到<Directory>语句,将其设置为你想要作为Web服务器根目录的文件夹路径,并确保在该语句下允许访问权限。 6. 保存并关闭httpd.conf文件。 7. 打开MySQL的安装文件夹,找到my.ini文件(或my.cnf文件),打开该文件。 8. 在my.ini文件中,找到[mysqld]部分,设置以下参数: - basedir:MySQL的安装路径 - datadir:MySQL的数据存储路径 9. 保存并关闭my.ini文件。 10. 打开命令提示符或终端窗口,进入到wamp文件夹。 11. 启动Apache服务器,使用命令`httpd.exe -k start`(Windows)或`sudo apachectl start`(Mac/Linux)。 12. 启动MySQL服务器,使用命令`mysql.exe`(Windows)或`sudo mysqld`(Mac/Linux)。 13. 确保Apache和MySQL都已成功启动,可以通过在浏览器中输入`http://localhost`来验证Apache是否正常工作,可以使用MySQL客户端连接到MySQL服务器来验证MySQL是否正常工作。 这样,你就成功安装Apache和MySQL。请确保按照上述步骤进行操作,并根据个人需求进行相应的配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [apachephp、mysql安装和配置(有图有真相)](https://blog.csdn.net/zyz1431/article/details/52717141)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值