How to install php environment on mac

藏色散人
Release: 2023-03-11 06:54:02
Original
14247 people have browsed it

How to install the PHP environment on mac: 1. Run Apache through "sudo apachectl -v"; 2. Configure PHP; 3. Download and install MySQL; 4. Set up the project through Preferences.

How to install php environment on mac

The operating environment of this article: Mac OS 10.12.1 system, PHP7.1 version, MacBook Air 2019 computer

Quickly under Mac Detailed explanation of the steps to build a PHP development environment

I recently made a back-end project using PHP MySQL Nginx, so I will briefly summarize the method of setting up the environment.

Remarks:

Materials: Apache/Nginx PHP MySQL MAMPMac OS 10.12.1 comes with Apache, Nginx and PHP

1. Run Apache

To check the Apache version, enter the following command in the terminal root directory:

sudo apachectl -v

The terminal will output the Apache version and built time

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

Start Apache

sudo apachectl start

After starting, you can use the browser Visit: http://localhost. If the page displays "It works", it means it has been successful.

Close Apache

sudo apachectl stop

Restart Apache

sudo apachectl restart

2. Configure PHP

Edit Apache’s configuration file, terminal input:

sudo vi /etc/apache2/httpd.conf

Found:

#LoadModule php5_module libexec/apache2/libphp5.so

Remove the previous "#" comment, then: wq Save and exit You can

Copy a copy of php.ini.default and name it php.ini

sudo cp /etc/php.ini.default /etc/php.ini

Restart Apache to make it take effect

sudo apachectl restart

3. Install MySQL

Download MySQL: http://dev.mysql.com/downloads/mysql/ After downloading, double-click to install. After success, a prompt box will pop up:

017-02-12T09:00:08.587153 Z 1 [Note] A temporary password is generated for root@localhost: s;QVTg#=i7wP If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

This temporary password is difficult to remember, so you can change it.

Start MySQL in safe mode and skip the security password. Enter the following command in the terminal:

sudo mysqld_safe --skip-grant-tables &

Modify MySQL password:

The principle is to modify the User field in the table:user of database:mysql to the root password. The password field of the 5.7 version of mysql is authentication_string, and the lower version is called password;

update user set authentication_string=PASSWORD("your password") where User="root";
Copy after login

Refresh privileges, exit and restart:

MySQL flush privileges; MySQL quit; Terminal: service mysql start

The password has been changed and the password has been changed to root.

Open the bottom line of the system preference configuration - MySQL,

Open MySQL: Start MySQL Server Close MySQL: Stop MySQL Server

Note: Automatically Start MySQL Server On Startup is checked by default. After checking, turning on the computer will open MySQL by default. It is recommended that you do not need to check it by default

If you find it inconvenient to view the database through the terminal, you can download Navicat Lite management software, which is super convenient for managing MySQL.

4. The big trick is here. After installing MAMP, you will find that everything you did above is basically a waste... Because after installing this one, there is basically no need to touch anything else, except for a slight change. Configuration or something. Installation address: https://www.mamp.info/en/ It is enough to install the free version

Through the Preferences setting, you can set whether the project uses Apache or Nginx, you can set the port number, and you can also set It uses the version number of PHP, and then you can point the folder to your own project. If it does not exist, create a new one. Finally, just click start.

How to install php environment on mac

How to install php environment on mac

How to install php environment on mac

How to install php environment on mac

##

#Super convenient!

In this way, a complete engineering environment is set up, and then you can happily code!

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of How to install php environment on mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!