Home >Operation and Maintenance >phpstudy >Does phpstudy have a mac version? How to use phpstudy under Mac system
Background
I am learning PHP recently, because I don’t want to I spent too much time setting up the environment. In addition, I have used phpstudy on Linux and Windows before. This time I also want to use phpstudy on the mac system. However, I checked online and found that there is no relevant phpstudy installation package on the mac. What should I do? I just used vagrant before, and virtualbox can be used with the Linux version of phpstudy. With the idea in mind, let’s take a look at what we need to prepare to complete our above idea
Prerequisites
1. mac os System
2. vagrant
3. virtualbox
4. git
5. phpstudy
6. Offline version box
Start processing
First install vagrant and virtualbox
Download vagrant mac Version installation package, install it directly by dragging it into Application. Install virtualbox in the same way.
After installation, since the network environment is not very good, we will not use vagrant directly here. Use your own box store. The Centos 7 box downloaded offline is first added to vagrant. The command is as follows
Add the offline box to vagrant
vagrant box add centos/7 /Users/ylf/Desktop/centos-7.0-x86_64.box
After adding, you can use the following command to check whether it is correct
vagrant box list
Create the Vagrantfile configuration file and run the virtual machine
Create a new directory and create a Vagrantfile file in the directory with the following content
# -*- 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
Then open the terminal in the corresponding directory and enter the following command in the terminal
vagrant up && vagrant ssh
Wait a moment, the virtual machine should be ready After creation, the system will ask you to enter a password. The default password for the virtual machine created by vagrant is vagrant. Enter vagrant in the terminal. When entering the password in these terminals, the entered characters will not be displayed. After inputting, just hit Enter. At this point the Linux environment has been configured.
Briefly explain what the above configuration items mean
Set the box used to centos/7
config.vm.box = "centos/7"
Set the default user to root, otherwise the default user is vagrant
config.ssh.username='root' config.ssh.password='vagrant' config.ssh.insert_key='true'
Because it is a machine for learning, the ip is set to a static ip so that the virtual machine and your computer agree on the LAN and can communicate directly.
Tips: The ip address here is set according to the actual ip of your computer. Ifconfig finds the specific ip, the ip here is set to be similar to it. Bridge is a bridge network card. Here I am The wireless network card used, if it is a wired connection, please set it according to the value found in ifconfig
config.vm.network "public_network" , ip: "192.168.3.233" ,bridge: "en1: Wi-Fi (AirPort)"
The virtual machine should have been set up here
Install phpstudy
Put the downloaded phpstudy-all.bin into the same directory as Vagrantfile, and then copy the phpstudy-all.bin installation package to the ~ directory
cp /vagrant/phpstudy-all.bin ~/
Then perform authorization, install
chmod +x ~/phpstudy-all.bin ~/phpstudy-all.bin
and wait for the installation to be completed. Depending on the actual situation, the installation time of each machine is different, ranging from a few minutes to dozens of minutes, depending on the network speed. It also has something to do with the disk. At this time, phpstudy has been installed. After the installation, test whether phpstudy can be started easily and normally.
phpstudy restart
The following error may occur at this time. This reason is because psmisc is not installed, just install it
line 82: killall: command not found
Install psmisc
yum install psmisc
At this point phpstudy has been installed and configured, but if we use it for development, we still need to set up some other things. We need to set up mysql for remote access
mysql remote access
Still run the following command in that virtual machine to log in to mysql
/phpstudy/mysql/bin/mysql -u root -proot
Log in to mysql and adjust the current database
use mysql;
Give the root user remote access rights
grant all privileges on *.* to 'root'@'%' identified by 'root'; flush privileges;
Turn off the firewall
systemctl stop firewalld
Disable the firewall from booting
systemctl disabled firewalld
Here mysql remote connection has been opened, on mac The installation of phpstudy is almost over here. Due to the space, we will talk about how to use phpstorm to cooperate with phpstudy for remote debugging, remote deployment, and automatic upload
Recommended tutorial:phpStudy Quick Getting Started Video Tutorial
The above is the detailed content of Does phpstudy have a mac version? How to use phpstudy under Mac system. For more information, please follow other related articles on the PHP Chinese website!