


How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
How should we set up a PHP development environment (Apache PHP MySQL) in a Windows environment? "Xiaobai" will take you to find out. Let's set off together! ! !
Install Apache
1. Download Apache, address: http://www.apachelounge.com/download/, as shown below:
2. Unzip the compressed package. It is best to put it in the root directory of the disk, otherwise it is easy to report a path error during configuration. I changed the folder name here to facilitate future configuration, as shown below:
Install PHP
1. Download the PHP compressed package at: https://windows.php.net/download. I downloaded the PHP7.0 Thread Safe version, as shown below:
2. Unzip the compressed package. I unzipped it as follows:
Install MySQL
1. The MySQL55 version I installed, MySQL will not be introduced here. For the installation method, you can search online
2. MySQL official download address: https://dev.mysql.com/downloads/installer/
3. MySQL default installation directory is as follows:
Configuring MySQL
1. Check in the environment variable page
The specific operations are as follows: My Computer-right-click-Properties-Advanced System Settings-Environment Variables
2. Create a new MYSQL_HOME variable, The value is the installation path of MySQL, as shown below:
3. Edit the path system variable and add %MYSQL_HOME%\bin to the end of the path variable
4. Start MySQL and enter the command line: start mysqld, as shown below:
Configuring PHP
1. Open the PHP installation directory and copy php.ini-development first, and then copy php.ini- Development is changed to php.ini and saved
2. Open php.ini to modify the configuration and search for; extension_dir = “ext” and change it to extension_dir = “ext’s directory”, for example, extension_dir = “D:\Software\php7\ext” , as shown below:
3. Open several commonly used extensions, for example: find extension=php_mysqli.dll and remove the preceding semicolon. Open the libraries in the picture below:
Configuring Apache
1. Open the installation directory of Apache, find the httpd.conf file in the conf folder and open it
2. Find the "Define SRVROOT" item and change the value in the quotation marks to the installation directory of Apache, as shown below:
3. Add support for PHP and The installation path of PHP is as shown below:
The code is as follows:
# php7 supportLoadModule php7_module "D:/软件/php7/php7apache2_4.dll"AddType application/x-httpd-php .php .html .htm# configure the path to php.iniPHPIniDir "D:/软件/php7"
Start the Apache service
1. Set environment variables
Right-click My Computer, Properties->Advanced, find the environment variables button at the bottom, select the current user's PATH variable, edit and create the following Entry:
D:\Apache24\bin
D:\Software\php7
D:\Software\php7\ext
2. Install apache service
Open the command line as an administrator, Execute httpd.exe -k install
3. Start the service
Find the bin folder in the installation directory of apache, double-click ApacheMonitor.exe, and apache will be started after double-clicking.
You can select the icon below in the taskbar, right-click to open the Apache Service Monitor window, and manage the Apache service
4. At this time, enter localhost in the browser address bar and press Enter. The apache interface appears, as shown below:
5. Next, create a new phpinfo.php file in the Apache installation directory/htdocs directory, with the content:
<?phpphpinfo();?>
After saving, Enter 127.0.0.1/phpinfo.php in the browser, press Enter, and the version information about PHP will appear, as shown below:
The PHP environment is now set up, and the PHP file can be Put it into the htdocs folder and run
Pitfalls
1. After the browser enters the corresponding PHP address, it cannot parse php
Solution: In the command Enter httpd -t to check if there is a startup problem with Apache , as shown below:
You can see that the error message is that the php7apache2_4.dll file in the PHP installation directory cannot be found. After checking online, the PHP version I downloaded is wrong. I should download the Thread safe version.
Introduction: Summary in Windows environmentBuilding a PHP development environment (Apache PHP MySQL)
2. Unzip the compressed package. It is best to put it in the root directory of the disk, otherwise it is easy to report a path error during configuration. I have changed the folder name here to facilitate future configuration, as shown below:
Install PHP
1. Download the PHP compressed package at: https://windows.php.net/download. I downloaded the PHP7.0 Thread Safe version, as shown below:
2. Unzip the compressed package. I unzipped it as follows:
Install MySQL
1. The MySQL55 version I installed, the installation of MySQL will not be introduced here. Method, you can search online
2. MySQL official download address: https://dev.mysql.com/downloads/installer/
3. MySQL default installation directory is as follows:
Configuring MySQL
1. Check in the environment variable page
The specific operations are as follows: My Computer-right-click-Properties-Advanced System Settings-Environment Variables
2. Create a new MYSQL_HOME variable, value It is the installation path of MySQL, as shown below:
3. Edit the path system variable and add %MYSQL_HOME%\bin to the end of the path variable
4. Start MySQL and enter: start on the command line mysqld, as shown below:
Configure PHP
1. Open the PHP installation directory and copy php.ini-development first, then change php.ini-development to php.ini and save it
2. Open php. ini modify the configuration and search; extension_dir = "ext", change to extension_dir = "ext directory", for example extension_dir = "D:\Software\php7\ext", as shown below:
3. Open several commonly used extensions, for example: find extension=php_mysqli.dll and remove the preceding semicolon. Open the libraries in the picture below:
Configuring Apache
1. Open the installation directory of Apache, find the httpd.conf file in the conf folder and open it
2. Find the "Define SRVROOT" item and change the value in the quotation marks to the installation directory of Apache, as shown below:
3. Add support for PHP and The installation path of PHP is as shown below:
The code is as follows:
# php7 supportLoadModule php7_module "D:/软件/php7/php7apache2_4.dll"AddType application/x-httpd-php .php .html .htm# configure the path to php.iniPHPIniDir "D:/软件/php7"
Start the Apache service
1. Set environment variables
Right-click My Computer, Properties ->Advanced, find the environment variable button at the bottom, select the current user's PATH variable, edit and create the following entries:
D:\Apache24\bin
D:\Software\php7
D:\Software \php7\ext
2. Install the apache service
Open the command line as an administrator and execute httpd.exe -k install
3. Start the service
Find the bin folder in the apache installation directory , double-click ApacheMonitor.exe, and apache will start after double-clicking.
You can select the icon below in the taskbar, right-click to open the Apache Service Monitor window, and manage the Apache service
4. At this time, enter localhost in the browser address bar and press Enter. The apache interface appears, as shown below:
5. Next, create a new phpinfo.php file in the Apache installation directory/htdocs directory, with the content:
<?phpphpinfo();?>
After saving, Enter 127.0.0.1/phpinfo.php in the browser, press Enter, and the version information about PHP will appear, as shown below:
The PHP environment is now set up, and the PHP file can be Put it into the htdocs folder and run
Pitfalls
1. After the browser enters the corresponding PHP address, it cannot parse php
Solution: In the command Enter httpd -t to check if there is a startup problem with Apache , as shown below:
You can see that the error message is that the php7apache2_4.dll file in the PHP installation directory cannot be found. After checking online, the PHP version I downloaded is wrong. I should download the Thread safe version.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial). For more information, please follow other related articles on the PHP Chinese website!

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
