Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure PHP in Windows and Linux environment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to install and configure PHP in Windows and Linux environment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to PHP

PHP, or "hypertext preprocessor", is a general open source scripting language. PHP is a scripting language executed on the server side, which is similar to C language and is a commonly used website programming language. PHP's unique syntax is a mix of C, Java, Perl, and PHP's own syntax. Conducive to learning, widely used, mainly suitable for the field of Web development. The abbreviation, originally Personal Home Page, has been officially renamed to "PHP: Hypertext Preprocessor"

Install and configure PHP under Windows

1. Download

Download address https://windows.php.net/download on the official website

Select the latest version to download

More versions such as different VC and Thread Safe left navigation are introduced.

2. Decompress

The file name can be changed to be more concise.

3. Configuration

# load PHPLoadModule php7_module 'D:/tools/php7/php7apache2_4.dll'# load the PHP configuration file into the Apache configuration file, work together PHPIniDir' D:/tools/php7'# configuration Apache assigns work to the PHP module, and gives the PHP code to PHP for processing # that is, the file AddType application/x-httpd-php .php with the .php suffix name

4. Php.ini file

The php.ini file for the above configuration does not exist by default, but exists in development and production formats and needs to be formatted.

5. Test the configuration (this step can be skipped)

Restart the Apache service, open cmd, cut to the Apache decompression directory / bin, and enter instructions

Httpd-M

6. Test the PHP code

It's all ready at this point ("▽") ~

Install and configure PHP under Linux

1. Download and decompress

Cd / usr/local/src/ # change directory wget http://cn2.php.net/distributions/php-7.4.10.tar.bz2 # download wget http://xmlsoft.org/downloads.html/tar jxvf php-7.4.10.tar.bz2 # extract

2. Installation

Cd / usr/local/src/php-7.4.10./configure-prefix=/usr/local/php7-- with-apxs2=/usr/local/apache2.4/bin/apxs-- with-config-file-path=/usr/local/php7/etc-- with-mysql=/usr/local/mysql-- with-pdo-mysql=mysqlnd-- with-mysqli-- with-libxml-dir-- with-gd-- with-jpeg-dir-- with-png-dir-- with-freetype-dir-- with -iconv-dir-with-zlib-dir-- with-bz2-- with-openssl-- with-mcrypt-- enable-soap-- enable-gd-native-ttf-- enable-mbstring-- enable-sockets-- enable-exif-- enable-fpm

When you execute configure, you will report Error, say XXX not found, etc., and install it accordingly until it is correct.

Package 'libxml-2.0', required by' virtual:world', not found

Yum install-y libxml2-devel

Package 'openssl', required by' virtual:world', not found

Yum install-y openssl openssl-devel

Package 'sqlite3', required by' virtual:world', not found

Yum install sqlite-devel

Configure: error: Please reinstall the BZip2 distribution

Yum install-y bzip2 bzip2-devel

Package 'krb5', required by' virtual:world', not found

Yum install krb5-devel

Package 'libcurl', required by' virtual:world', not found

Yum install libcurl-devel

Package 'libjpeg', required by' virtual:world', not found

Yum install libjpeg-devel

Package 'libzip', required by' virtual:world', not found

Yum install libzip-devel

Package 'libxslt', required by' virtual:world', not found

Yum install libxslt-devel

Package 'freetype2', required by' virtual:world', not found

Yum install freetype-devel

Package 'libpng', required by' virtual:world', not found

Yum install libpng-devel

Package 'oniguruma', required by' virtual:world', not found (this is a little troublesome)

Cd / usr/local/src/wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz-O oniguruma-6.9.4.tar.gztar-zxvf oniguruma-6.9.4.tar.gzyum install autoconf automake libtool # input ycd oniguruma-6.9.4/./autogen.sh & &. / configure-- prefix=/usrmake & & make install

3 、 php.ini

Copy formatted php.ini, same as Windows

Cp php.ini-development php.ini / usr/local/php7/ # copy cp php.ini / usr/local/php7//usr/local/php7/bin/php-m # View PHP load module / usr/local/apache2.4/bin/apachectl-M # View httpd load module

4. Configure Apache

Vim / usr/local/apache2.4/conf/httpd.conf # Edit configuration file # modify the following four points # 1.ServerName 195line ServerName www.example.com:80#2.Directory 204line AllowOverride none Require all granted#3.DirectoryIndex 253line DirectoryIndex index.html index.php#4.AddType 391line AddType application/x-httpd-php .php: wq # Save exit (press ESC first) / usr/local/apache2.4/bin/apachectl-t # test configuration language Method / usr/local/apache2.4/bin/apachectl graceful # reload configuration file

5. Start the service

/ usr/local/apache2.4/bin/apachectl startps-ef | grep httpd # View httpd process netstat-lntp | grep 80 # View port 80 curl localhost # test

6. Testing

Iptables-I INPUT-p tcp-- dport 80-j ACCEPT # Open port 80 or configure server security group vim / usr/local/apache2.4/htdocs/test.php # Edit test file: wq # Save exit (press ESC first)

Follow this step and you will succeed.

This is the end of the introduction to "how to install and configure PHP in Windows and Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report