mac os13上安装apache\php\mysql

发布时间 2023-11-07 18:09:53作者: eason07
macos13上安装
1,下载并安装brew,brew是macos上的软件安装工具;
2,安装apache2
brew install 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.
apache2 httpd启动命令:以后使用这个命令进行操作(mac os默认安装的apache不能用,加载php时各种问题)
To start httpd now and restart at login:
  brew services start httpd
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/httpd/bin/httpd -D FOREGROUND
3,安装php
brew install php
vi 进到 /usr/local/etc/httpd/httpd.conf 文件,添加和修改一下内容
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>
DirectoryIndex index.php index.html
 
修改完成后重启apache
brew services restart httpd
访问http://localhost:8080
 
 4,安装mysql
brew install mysql 
启动 brew services start mysql
为root用户重设密码 mysql_secure_installation  
重启 brew services restart mysql
连接mysql :
mysql -u root -p