search
HomeBackend DevelopmentPHP TutorialMAMP installation and configuration of PHP development environment in Mac OSX environment

This section describes how to install MAMP on your Mac. Apache Web server, MySQL and phpMyAdmin will be installed through one operation. Friends who need it can refer to

1. Brief introduction:

PHP pages need to be processed through the Web server. Therefore, to develop in PHP, you need access to a PHP-enabled web server and a MySQL database. Also useful is phpMyAdmin, a graphical interface to MySQL. These three components are open source software that can be used to develop, test, and deploy web applications. And it's all free. The Apache web server and PHP are both pre-installed in Mac OS X. But they are not enabled by default. Also, the pre-installed version of PHP lacks many useful features, and you need to install and configure MySQL separately. Unless you're comfortable using the command line in Terminal, installing the all-in-one solution MAMP is much simpler. This section describes how to install MAMP on your Mac. The Apache web server, MySQL, and phpMyAdmin will be installed in one operation.

2. Tools/Materials

(1) MAMP (Macintosh, Apache, MySQL, PHP) download address is an application that allows you to set up a server locally , MAMP file size is about 245MB, initialize MAMP like other software, load and run MAMP, ignore MAMP PRO version, continue to use the free version of MAMP.

Click Preferences, select Ports and click Set Apache & MySQL ports to 80 & 3306 to replace the default value with the recommended port.

Secondly click Web Server/Apache and select the location to be installed. The default location is Macintosh HD/Applications/MAMP/htdocs. Similar to Public_html in the web hosting server folder (the default path can be modified by yourself).

(2)Mac OS X

(3)ThinkPHP

Three. Steps:

1. Open [System Preferences], select [Sharing]

Make sure [Internet Sharing] is turned off.

As long as MySQL has never been installed on the system, you can continue.

2. Download the latest version of MAMP

3. After downloading, click to continue installation

4. Drag the MAMP file into Applications

5. Find MAMP in the application, find the htdocs file and create a new file in this directory:

6. Create a MySQ database: Create a new database through phpMyAdmin

(1) Open MAMP and click Start Servers (you may need to enter your mac username and password), use a browser to access http://localhost/phpmyadmin, the following interface will appear to create a new database

7. After unzipping the downloaded ThinkPHP framework, import the ThinkPHP framework directly into the School folder created in the above steps, and create a new index.php file

<?php
define("APP_DEBUG","ture");
require "./ThinkPHP/ThinkPHP.php"
?>

and then Entering http://localhost:8888/School on the browser will display the following information:

If you can see a smiling face, it means the connection is successful, and it will be automatically added to the School file. Generate the following files (the files in the red box were created by myself and will not be automatically generated:

After finishing here, you can start PHP development.

Maybe there will be various mistakes in the process: but please continue, knowledge is accumulated little by little. If you encounter wrong ideas and solve them, you will slowly find a lot of progress.

MAMP: Set up Apache, MySQL, PHP environments in OSX and install and debug WordPress locally

The name MAMP comes from Macintosh Apache MySQL PHP, which is obviously specially used to build Apache, MySQL, PHP platform.

Although OSX has pre-installed Apache 1.3.x and PHP 4.3.2 environments, enabling, configuring, installing and integrating MySQL is still an extremely complicated task. The characteristics of MAMP are It is simple (as you can see from the following installation steps), and it will not destroy the files of the system itself. The scope of modifying and creating files is limited to the program itself.

System requirements: Mac OS X 10.4 (Tiger) and above (for 10.3 Panther users can install MAMP 1.4.1)

Installation steps:

Go to the official website to download the latest version.
Open the dmg file and drag MAMP to the Applications folder (note: MAMP must be in the Applications folder to work properly).
Set MAMP

打开 MAMP(而不是 MAMP Pro),选择 Preferences 标签,会看到端口(Ports)的设定。默认 Apache 端口是 8888,如果不修改,就意味着需要通过 http://localhost:8888/ 访问。你也可以改成其他(例如改成 80,就不用输入 : 后面的部分了),但是缺点是,你每次都需要输入密码。
在 PHP 标签选择 PHP 5.2.4 以上版本即可(WordPress 3.2 的最低需求)。
在 Apache 标签,选择文件的存放地点,这个可以任意修改。比如我的设定是:
/Users/renfei/Documents/localhost
点 OK 完成设定。
打开 MAMP 服务并创建数据库

点击 Start Servers,稍等片刻,发现红灯变成绿灯,说明服务开启成功。
开启后,应该自动出现 MAMP 的起始页(如果没有出现,点击 Open Start Page 按钮。
在开启的网页中选择 phpMyAdmin,然后选择“数据库”标签。在“新建数据库”中给你的数据库起一个名字(例如我用 wordpress),填好后直接点“新建”。
安装 WordPress

下载 WordPress。
下载后,解压缩,把 wordpress 文件夹放到之前设定的文件存放地点。按照我的设定,文件全部在 /Users/renfei/Documents/localhost/wordpress
访问 localhost(按照我的设定,地址为localhost:8888/wordpress),并开始熟悉的 WordPress 安装过程。
相关内容按照这样填写:

database name: wordpress
database host/server: localhost
database user: root
database password: root

至此,全部安装过程完成,你可以在本机使用 WordPress 了。

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

The above is the detailed content of MAMP installation and configuration of PHP development environment in Mac OSX environment. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
How can you prevent session fixation attacks?How can you prevent session fixation attacks?Apr 28, 2025 am 12:25 AM

Effective methods to prevent session fixed attacks include: 1. Regenerate the session ID after the user logs in; 2. Use a secure session ID generation algorithm; 3. Implement the session timeout mechanism; 4. Encrypt session data using HTTPS. These measures can ensure that the application is indestructible when facing session fixed attacks.

How do you implement sessionless authentication?How do you implement sessionless authentication?Apr 28, 2025 am 12:24 AM

Implementing session-free authentication can be achieved by using JSONWebTokens (JWT), a token-based authentication system where all necessary information is stored in the token without server-side session storage. 1) Use JWT to generate and verify tokens, 2) Ensure that HTTPS is used to prevent tokens from being intercepted, 3) Securely store tokens on the client side, 4) Verify tokens on the server side to prevent tampering, 5) Implement token revocation mechanisms, such as using short-term access tokens and long-term refresh tokens.

What are some common security risks associated with PHP sessions?What are some common security risks associated with PHP sessions?Apr 28, 2025 am 12:24 AM

The security risks of PHP sessions mainly include session hijacking, session fixation, session prediction and session poisoning. 1. Session hijacking can be prevented by using HTTPS and protecting cookies. 2. Session fixation can be avoided by regenerating the session ID before the user logs in. 3. Session prediction needs to ensure the randomness and unpredictability of session IDs. 4. Session poisoning can be prevented by verifying and filtering session data.

How do you destroy a PHP session?How do you destroy a PHP session?Apr 28, 2025 am 12:16 AM

To destroy a PHP session, you need to start the session first, then clear the data and destroy the session file. 1. Use session_start() to start the session. 2. Use session_unset() to clear the session data. 3. Finally, use session_destroy() to destroy the session file to ensure data security and resource release.

How can you change the default session save path in PHP?How can you change the default session save path in PHP?Apr 28, 2025 am 12:12 AM

How to change the default session saving path of PHP? It can be achieved through the following steps: use session_save_path('/var/www/sessions');session_start(); in PHP scripts to set the session saving path. Set session.save_path="/var/www/sessions" in the php.ini file to change the session saving path globally. Use Memcached or Redis to store session data, such as ini_set('session.save_handler','memcached'); ini_set(

How do you modify data stored in a PHP session?How do you modify data stored in a PHP session?Apr 27, 2025 am 12:23 AM

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Give an example of storing an array in a PHP session.Give an example of storing an array in a PHP session.Apr 27, 2025 am 12:20 AM

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

How does garbage collection work for PHP sessions?How does garbage collection work for PHP sessions?Apr 27, 2025 am 12:19 AM

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor