Home > Article > Operation and Maintenance > A brief analysis of how to use PHPStudy on Apple computers
PHPStudy is an integrated software suite for building a PHP development environment on the Windows platform. It can easily install and configure services such as Apache, PHP, and MySQL, making it simple and easy to build a PHP development environment. However, Apple computers do not support this software. How to implement PHP development using Apple computers? This article will introduce how to use PHPStudy on Apple computers.
Step 1: Install XAMPP
XAMPP is a web server environment that supports Apple computers and can be used to develop and test web applications. When using PHPStudy, we can first install XAMPP to implement support for Apache, PHP, and MySQL.
Go to https://www.apachefriends.org/index.html to download the corresponding version of XAMPP. After the installation is complete, open the terminal and enter the following command:
sudo /Applications/XAMPP/xamppfiles/xampp security
Set the MySQL password and start XAMPP.
Step 2: Install phpMyAdmin
phpMyAdmin is an open source tool for managing MySQL databases and is also integrated on PHPStudy. When using XAMPP, we need to install phpMyAdmin manually.
Enter the following command in the terminal:
cd /Applications/XAMPP/xamppfiles/www sudo curl -O https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-all-languages.zip sudo unzip phpMyAdmin-4.9.4-all-languages.zip sudo mv phpMyAdmin-4.9.4-all-languages phpmyadmin
After completion, visit localhost/phpmyadmin. If the phpMyAdmin login page appears, the installation is successful.
Step 3: Configure Apache and PHP
After installing XAMPP, we need to configure the Apache and PHP environments so that they can run correctly. Enter the following command in the terminal:
cd /etc/apache2 sudo vi httpd.conf
Find the following two lines:
LoadModule php7_module libexec/apache2/libphp7.so AddHandler php7-script php
Modify them to:
LoadModule php7_module /Applications/XAMPP/xamppfiles/lib/php/libphp7.so AddHandler php7-script .php
Save and exit.
Then, we need to open the php.ini file for configuration. Enter the following command in the terminal:
cd /etc sudo cp php.ini.default php.ini sudo vi php.ini
Find the following two lines:
;extension=mysql.so ;extension=mysqli.so
Modify them to:
extension=mysql.so extension=mysqli.so
At the same time, find the following line:
;date.timezone =
Modify to:
date.timezone = Asia/Shanghai
Save and exit.
Step 4: Start Apache and MySQL
After completing the above configuration, we need to start the Apache and MySQL services. Enter the following command in the terminal:
sudo /Applications/XAMPP/xamppfiles/xampp startapache sudo /Applications/XAMPP/xamppfiles/xampp startmysql
Step 5: Add site
After completing the above steps, we need to add the site to facilitate PHP development. Enter the following command in the terminal:
cd /Applications/XAMPP/xamppfiles/etc/extra sudo vi httpd-vhosts.conf
Add the following code to the end of the file:
<VirtualHost *:80> ServerName localhost DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs" </VirtualHost> <VirtualHost *:80> ServerName example.com DocumentRoot "/Users/username/Documents/website" </VirtualHost>
Among them, ServerName can be replaced with the domain name you need, and DocumentRoot is the folder path to build the website locally. .
Save and exit.
Step 6: Test the PHP environment
After making the above settings, we can test the PHP environment by accessing localhost or example.com. If there are no problems, the page should display "Hello, PHP".
If a problem occurs, you can enter the following command in the terminal to view the error log and solve the problem:
tail -f /Applications/XAMPP/xamppfiles/logs/error_log
In summary, PHP development can be achieved on Apple computers in a similar way. Although unlike PHPStudy, manual configuration and installation are required, but in this way you can better understand and master the configuration and working principles of the server environment.
The above is the detailed content of A brief analysis of how to use PHPStudy on Apple computers. For more information, please follow other related articles on the PHP Chinese website!