Configure PHP development environment in MAC environment: apache+php+mysql

User 1685462 2022-06-24 06:14:47 阅读数:239

configurephpdevelopmentenvironmentmac

One 、 start-up Apache

1、 Open the terminal , Input

sudo apachectl start

You need to enter the password , Enter the computer password , Then input

sudo apachectl -v

You can see that Apache Version information for

Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 16:31:34

Enter... In the browser http://localhost, There will be It works! The page of

Two 、 function PHP

1、 find Apache Configuration file for , In the catalog /etc/apache2/ Next , open Finder, choice " Go to "-" Go to folder ", Input "/etc/apache2/", Find one "httpd.conf" file , Select open with document for editing , Click Command+F, Search for #LoadModule php5_module libexec/apache2/libphp5.so, Pictured

Put the blue line # Remove the number , Then save , If text lock occurs , Unable to unlock , Copy the file to the desktop , Make changes , After modification, copy to the original folder to replace the previous file .

2、 restart Apache, Input... At the terminal

sudo apachectl restart

PHP You can use it .

3、 Input... At the terminal

sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php

That is to say Apache Copy under the root directory of index.html.en And rename it to file info.php.

4、 open info.php, stay It works Followed by , And then restart again Apache, Enter... In the browser http://localhost/info.php, A display will appear php Information page , As shown in the figure .

3、 ... and 、 To configure MySql

1、 stay http://dev.mysql.com/downloads/mysql/ On the website , choice Mac OS X platform , Then select download... In the figure , I started downloading wrong , Installation error , Later, the version in the figure was downloaded and installed successfully

double-click dmg file

Double click installation

2、 Change Password

a) First stop MySQL service

open “ System preferences ”, choice “MySQL”, Click... In the open dialog box “Stop MySQL Server”

Input... At the terminal , Change the password here to 12345, It can also be used for other , Customize it

b) Open the terminal , Enter the command :sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

--skip-grant-tables: Do not start grant-tables( Authorization Form ), Skip access control .

--skip-networking : skip TCP/IP agreement , Only on the local machine ( This option is not required . Don't have to )

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables

c) Enter the command :/usr/local/mysql/bin/mysql

/usr/local/mysql/bin/mysql

At this point, we can log in directly to MySQL Yes .

The terminal can change the password by entering the command

/usr/local/mysql/bin/mysqladmin -u root password 123456

Four 、 Use phpMyAdmin

phpMyAdmin Yes, it is PHP Development management MySql The program , Very practical

1、 download phpMyAdmin, On the website Downloads Select the appropriate version to download , I chose phpMyAdmin-4.6.5.2-All-Languages.tar.bz2

2、 Unzip the downloaded file , In the /Library/WebServer/Documents/ In the folder , And named it phpmyadmin.

3、 Copy /Library/WebServer/Documents/phpmyadmin Medium config.sample.inc.php, And named it config.inc.php, And put it in the current folder .

4、 edit config.inc.php, Modify the

$cfg['Servers']]$i]['host'] = 'localhost';

by

$cfg['Servers']]$i]['host'] = '127.0.0.1';

that will do , If you want to log in without password , In the following statements false Change to true

$cfg['Servers'][$i]['AllowNoPassword'] = false

5、 Enter... In the browser http://localhost/phpmyadmin, enter one user name "root", And the password you just changed , If the password has not been changed , Then follow the no password operation in the previous step , Then you can log in directly .

copyright:author[User 1685462],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/20210723184705179G.html