preface
There are a lot of holes in trying to build this environment, so here is a brief summary
Apache + PHP configuration
The MAC operating system has Apache and PHP operating systems, but they are not enabled by default. My personal operating systems are as follows: PHP version: 7.1.23 Apache version 2.4.34 (Unix) Operating system version: macOS Mojave 10.14.6
Open the Apache
Open the terminal and enter the following command
Start Apache: sudo apachectl start Stop Apache: sudo apachectl stop Restart Apache: sudo apachectl restartCopy the code
Enter localhost in your browser. If the following default message “It works! If yes, the Apache service is successfully started.
Open the PHP
To start PHP, you need to modify the Apache configuration file as follows:
1. Open the terminal and run the following command:
sudo vim /etc/apache2/httpd.conf
Copy the code
# 2. Find LoadModule php5_module libexec/apache2 / libphp5. So, remove the annotations (delete) well ahead of the MAC under the default folder for the Apache/Library/WebServer/Documents, Create a file named index.php in this directory and add the following content to the file: Delete the index. HTML file in the original directory and enter localhost in the browser. If the following PHP info page is displayed, PHP is successfully started. If not, restart Apache and try again. 3. Here is a pit I personally stepped into, that is the implementation of the first two steps will show
403 Forbidden You don’t have permission to access/on this server
The main reason for this problem is that 403 does not have permissions (because my PHP file was originally created on the desktop and dragged into the root directory), so we only need to give permissions to that file to solve the problem: 1. Type the following command on your terminal (go to the root directory of index.php, note the space after CD)
cd /library/WebServer/Documents
Copy the code
2. Grant permission
chmod 777 index.php
Copy the code
If the input is correct, the terminal does not respond, restart Apache and refresh the page should display the following info page
Modifying the Apache Directory
Under the above said to the MAC the default folder for the Apache/Library/WebServer/Documents, the directory is hidden by default, the operation is not very convenient, we can be modified into a custom directory, such as my folder path to/Users/Gavin/Sites
1. Open the terminal and run the following command:
sudo vim /etc/apache2/httpd.conf
Copy the code
2. Find the following two places
    DocumentRoot "/Library/WebServer/Documents"     <Directory "/Library/WebServer/Documents">Copy the code
3. Replace the quoted directories with /Users/ Gavin /Sites. After completing the preceding steps, restart Apache, copy the created index. PHP file to the customized directory, and enter localhost in the browser. The directory is successfully modified.
MySQL installation
10.14 MySQL does not come with it, so you need to install it yourself. MySQL 5.7.11-OSx10.10-x86_64.dmg is the latest installation package of MySQL 5.7.11-OSx10.10-x86_64.dmg. Click “No Thanks, Just start my Download.” on the bottom of the page, you will be prompted to log in or register. Double-click the downloaded DMG installation and proceed to the next installation. When the installation is complete, a message will pop up telling you that MySQL has generated a temporary password for the root@localhost account. Please save this password.
Start the MySQL
1. Go to system preferences and open MySQL at the bottom.
/usr/local/mysql/bin/mysqladmin -u root -p'temppassword' password 'newpassword'
Copy the code
phpMyAdmin
After completing the above two steps, MySQL is installed and configured, but for convenience, it is necessary to install a visual tool, I choose phpMyAdmin. Download the latest ZIP package directly from phpMyAdmin’s official website. It is recommended to download the multi-language version, supporting simplified Chinese. Once the download is complete, rename the decompressed folder to phpMyAdmin and place it in the root directory of your custom Apache path. Enter localhost/phpMyAdmin in the browser to display the MySQL login page. In this page, you can set the language and log in to the MySQL database using root and the password previously set. See the following two pages, and you’re done!!
The second problem I encountered
Because I installed XAMMP and mysql before, my environment is a bit chaotic, resulting in the following problems when I log in
$cfg['Servers'] [$i] ['controluser'] = 'root'; (The user name must be root)
$cfg['Servers'] [$i] ['controlpass'] = 'Your own password';
Copy the code
# Final summary: Google is a good thing, encountered problems to copy the original error into the search box on the line, but a problem often have many solutions, not sure of the situation can only be tried and error, in the case of not very sure must be the original file backup! Say more is tears ~~~