0

0

phpstudy有mac版本吗,如何在Mac系统下使用phpstudy

步履不停

步履不停

发布时间:2019-06-10 13:37:40

|

25611人浏览过

|

来源于php中文网

原创

phpstudy有mac版本吗,如何在Mac系统下使用phpstudy

背景

最近在学习php,由于不想在环境搭建上花费太多功夫,再加上之前在linux和window上使用过phpstudy,这次在mac系统上也想使用phpstudy,可是上网查了一下,发现mac上并没有相关的phpstudy安装包,那可怎么办,刚好之前用过vagrant,virtualbox配合linux版本的phpstudy即可。有了思路,接下来看看我们需要准备什么东西来完成我们上面的想法

前置条件

1. mac os 系统

2. vagrant

立即学习PHP免费学习笔记(深入)”;

3. virtualbox

4. git

5. phpstudy

6. 离线版box

开始处理

首先安装vagrant和virtualbox

下载vagrant mac版本安装包,安装直接拖到Application中即可,安装virtualbox同样的方式,

安装完之后,由于网络环境不是很好,这里就不直接使用vagrant 自己的box商店了,用自己离线下载的Centos 7 box 首先添加到 vagrant 中,命令如下

添加离线box到vagrant中

vagrant box add centos/7 /Users/ylf/Desktop/centos-7.0-x86_64.box

添加之后可以可以用以下命令查看是否正确

vagrant box list

创建Vagrantfile配置文件并运行虚拟机

新建一个目录,在目录中创建Vagrantfile 文件的内容如下

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "centos/7"
#  config.vm.box_version = "1801.02"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  config.ssh.username='root'
  config.ssh.password='vagrant'
  config.ssh.insert_key='true'

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"
   config.vm.network "public_network" , ip: "192.168.3.233" ,bridge: "en1: Wi-Fi (AirPort)"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

然后再对应的目录中打开终端,在终端中输入如下命令

vagrant up && vagrant ssh

稍等片刻,虚拟机应该已经创建好了,这时候系统会让输入密码,vagrant创建的虚拟机默认密码是vagrant 在终端中输入vagrant ,这些终端输入密码时不会显示输入的字符,输入完之后,直接敲回车即可。到这里linux环境已经配置好了。

简单的解释一下上面的配置项是什么意思

百度智能云·曦灵
百度智能云·曦灵

百度旗下的AI数字人平台

下载

设置使用的box为centos/7

 config.vm.box = "centos/7"

设置默认用户为root,不然默认的用户为vagrant

config.ssh.username='root'
config.ssh.password='vagrant'
config.ssh.insert_key='true'

由于与学习用的机子,这里把ip设置为静态ip 这样虚拟机跟自己电脑就是同意局域网,可以直接互通了。

提示: 这里的ip地址大家根据自己的电脑实际的ip来设置,ifconfig 查到具体的ip ,这里的ip设置为与其类似的,bridge 是桥接网卡的,我这里用的无线网卡,如果是用的有线连接,请根据ifconfig查出来的值具体设置
config.vm.network "public_network" , ip: "192.168.3.233" ,bridge: "en1: Wi-Fi (AirPort)"

到这里应该虚拟机已经设置完毕

安装phpstudy

把下载好的phpstudy-all.bin 放到Vagrantfile同级目录中,然后复制phpstudy-all.bin安装包到~目录

cp /vagrant/phpstudy-all.bin ~/

然后执行授权,安装

chmod +x ~/phpstudy-all.bin
~/phpstudy-all.bin

等待安装完毕,根据实际情况每个人的机子安装的时间不太一样,几分钟到几十分钟都有,跟网速,还有磁盘有关系,这时候phpstudy就安装完毕,安装完之后测试一下phpstudy启动是否方便正常

phpstudy restart

这时候可能会出现下面错误,这个原因是因为没有安装psmisc,安装即可

 line 82: killall: command not found

安装psmisc

yum install psmisc

到这里phpstudy已经安装配置完毕,但是如果我们用来开发的话,还是需要设置一些其他的东西,我们需要设置一下mysql可以远程访问

mysql 远程访问

还是在那个虚拟机中运行下面的命令登陆mysql

/phpstudy/mysql/bin/mysql -u root -proot

登陆mysql,调整当前的数据库

use mysql;

给root用户远程访问权限

grant all privileges on *.* to 'root'@'%' identified by 'root';
flush privileges;

关闭防火墙

systemctl stop firewalld

禁止防火墙开机启动

systemctl disabled firewalld

到这里mysql远程连接已经开启,在mac上安装phpstudy到这里已经差不多到此结束,介于篇幅,后面我们会具体讲一下如何利用phpstorm配合phpstudy远程调试,远程部署,自动上传

推荐教程:phpStudy极速入门视频教程

相关文章

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
Java 桌面应用开发(JavaFX 实战)
Java 桌面应用开发(JavaFX 实战)

本专题系统讲解 Java 在桌面应用开发领域的实战应用,重点围绕 JavaFX 框架,涵盖界面布局、控件使用、事件处理、FXML、样式美化(CSS)、多线程与UI响应优化,以及桌面应用的打包与发布。通过完整示例项目,帮助学习者掌握 使用 Java 构建现代化、跨平台桌面应用程序的核心能力。

37

2026.01.14

php与html混编教程大全
php与html混编教程大全

本专题整合了php和html混编相关教程,阅读专题下面的文章了解更多详细内容。

19

2026.01.13

PHP 高性能
PHP 高性能

本专题整合了PHP高性能相关教程大全,阅读专题下面的文章了解更多详细内容。

37

2026.01.13

MySQL数据库报错常见问题及解决方法大全
MySQL数据库报错常见问题及解决方法大全

本专题整合了MySQL数据库报错常见问题及解决方法,阅读专题下面的文章了解更多详细内容。

19

2026.01.13

PHP 文件上传
PHP 文件上传

本专题整合了PHP实现文件上传相关教程,阅读专题下面的文章了解更多详细内容。

16

2026.01.13

PHP缓存策略教程大全
PHP缓存策略教程大全

本专题整合了PHP缓存相关教程,阅读专题下面的文章了解更多详细内容。

6

2026.01.13

jQuery 正则表达式相关教程
jQuery 正则表达式相关教程

本专题整合了jQuery正则表达式相关教程大全,阅读专题下面的文章了解更多详细内容。

3

2026.01.13

交互式图表和动态图表教程汇总
交互式图表和动态图表教程汇总

本专题整合了交互式图表和动态图表的相关内容,阅读专题下面的文章了解更多详细内容。

45

2026.01.13

nginx配置文件详细教程
nginx配置文件详细教程

本专题整合了nginx配置文件相关教程详细汇总,阅读专题下面的文章了解更多详细内容。

9

2026.01.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
PHP课程
PHP课程

共137课时 | 8.6万人学习

JavaScript ES5基础线上课程教学
JavaScript ES5基础线上课程教学

共6课时 | 7万人学习

PHP新手语法线上课程教学
PHP新手语法线上课程教学

共13课时 | 0.9万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号