PLDaily / blog

✨My Notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mac下如何搭建php环境

PLDaily opened this issue · comments

加班近一个星期,回学校写一个星期的论文,又俩个星期没有更新博客了。最近新入手一台mac,记录一下搭建php环境的过程。mac自带apache与php,但由于mac系统更新时会更新apache与PHP,导致php环境需要重新配置,故选择使用xampp。

mysql无法开启

  • 首先使用改命令
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
  • 不起作用则使用
  1. sudo killall mysqld

  2. manager-osx > start mysql

更改vhost

  • 启动httpd.conf中的
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include etc/extra/httpd-vhosts.conf
  • 更改httpd-vhost.conf
    示例:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/laravel/public"
    ServerName www.shop123.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
    <Directory "/Applications/XAMPP/xamppfiles/htdocs/laravel/public">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
  • 更改httpd.conf中的user
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User pengchangdong
Group daemon
</IfModule>