search
HomeOperation and MaintenanceApacheHow to integrate apache and php together
How to integrate apache and php togetherNov 11, 2020 pm 04:02 PM
apachephp

How to integrate apache and php together

We know that after installing PHP, apache cannot actually process php files. If we want to integrate php with the apache server, we must modify the configuration file.

(Related recommendations: apache)

The method is as follows:

First add the following code to httpd.conf in the conf directory of apache:

LoadModulephp5_module~php installation path/php5apache2_2.dll

PHPIniDir "~php module installation path"

AddTypeapplication/x-httpd-php.php.phtml

How to integrate apache and php together

Here I will briefly explain the above code. The whole code means to let apache load the php processing module (LoadModulephp5_module). The "~php installation path" in the code is based on the location where you installed php. Change it depending on the situation. For example, I installed it in the D drive, so my path is: D:\Myenv\php-5.3.5 (note that the slope here is the backslash "\", which needs to be changed in the code. into a forward diagonal bar "/"), the place to add the code is to add it under a lot of LoadModules in httpd.conf, as shown in the following figure:

How to integrate apache and php together

Then You need to check whether there is this file "php5apache2_2.dll" in the directory you just added. In theory, it should be there. Just in case, you must check it. This file is very important and plays a bridge role.

How to integrate apache and php together

Next step we need to specify the PHP initialization directory, that is, the code "PHPIniDir '~php module installation path'". This code is used to specify the ini file of php. This file PHP will be configured. In layman's terms, you need to tell apache where to put your PHP. In the same way, we replace the "~php module installation path" in the code with the installation path just now

How to integrate apache and php together

Then I will explain to you the meaning of the last line of code. "AddTypeapplication/x-httpd-php.php.phtml" means adding an application type. To explain it in vernacular, when it appears *.php file, php will start processing the file. You can add comments to the configuration file to facilitate your own understanding, as shown below:

How to integrate apache and php together

#So, there are two places where we need to change the path, as shown in the following picture marked in red. Just change the red part to the path where you actually installed PHP (note the forward slope)

How to integrate apache and php together

In addition, it is also very important to set up the PHP file. Find PHP in your PHP installation directory. .ini-development file and change its suffix to php.ini. The reason for changing this is: our php settings need to be modified in php.ini. As shown below: Just delete the dark blue part of the name.

How to integrate apache and php together

After the modification, the file will look like this, as shown below:

How to integrate apache and php together

Now we need to change it in php.ini You can specify the corresponding function module. The specific method is to add the following code "

extension_dir="php extension library path" to the php.ini file you just modified. The purpose of this is to be able to use There are various powerful libraries of PHP, and the "php extension library path" has an "ext" folder under the folder where you installed PHP. Open this folder and it will contain PHP extension libraries. As shown below:

How to integrate apache and php together

Now let's add the extension library path. Use your notepad to open the "php.ini" file and find the "extension_dir" location. You can use search to quickly locate the location. As shown below :

How to integrate apache and php together

Then replace the location "extension_dir='ext'" with the path of your php library. Taking mine as an example, my library path is: D:/ Myenv/php-5.3.5/ext (also note the forward slope), as shown below: Replace the blue part with your library path.

How to integrate apache and php together

The final replacement result is as shown below:

How to integrate apache and php together

Now our integration has been completed and we can test whether it is successful. Test method: Call a simple php function, the function code is as follows:

<?php
    phpinfo();
?>

Then restart your apache to see if it can be used.

If you integrate successfully, you will be able to see the shocking effect below.

How to integrate apache and php together

The above is the detailed content of How to integrate apache and php together. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:gxlcms. If there is any infringement, please contact admin@php.cn delete
图文详解apache2.4+php8.0的安装配置方法图文详解apache2.4+php8.0的安装配置方法Dec 06, 2022 pm 04:53 PM

本文给大家介绍如何安装apache2.4,以及如何配置php8.0,文中附有图文详细步骤,下面就带大家一起看看怎么安装配置apache2.4+php8.0吧~

Linux apache怎么限制并发连接和下载速度Linux apache怎么限制并发连接和下载速度May 12, 2023 am 10:49 AM

mod_limitipconn,这个是apache的一个非官方模块,根据同一个来源ip进行并发连接控制,bw_mod,它可以根据来源ip进行带宽限制,它们都是apache的第三方模块。1.下载:wgetwget2.安装#tar-zxvfmod_limitipconn-0.22.tar.gz#cdmod_limitipconn-0.22#vimakefile修改:apxs=“/usr/local/apache2/bin/apxs”#这里是自己apache的apxs路径,加载模块或者#/usr/lo

apache版本怎么查看?apache版本怎么查看?Jun 14, 2019 pm 02:40 PM

查看​apache版本的步骤:1、进入cmd命令窗口;2、使用cd命令切换到Apache的bin目录下,语法“cd bin目录路径”;3、执行“httpd -v”命令来查询版本信息,在输出结果中即可查看apache版本号。

超细!Ubuntu20.04安装Apache+PHP8环境超细!Ubuntu20.04安装Apache+PHP8环境Mar 21, 2023 pm 03:26 PM

本篇文章给大家带来了关于PHP的相关知识,其中主要跟大家分享在Ubuntu20.04 LTS环境下安装Apache的全过程,并且针对其中可能出现的一些坑也会提供解决方案,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

nginx,tomcat,apache的区别是什么nginx,tomcat,apache的区别是什么May 15, 2023 pm 01:40 PM

1.Nginx和tomcat的区别nginx常用做静态内容服务和代理服务器,直接外来请求转发给后面的应用服务器(tomcat,Django等),tomcat更多用来做一个应用容器,让javawebapp泡在里面的东西。严格意义上来讲,Apache和nginx应该叫做HTTPServer,而tomcat是一个ApplicationServer是一个Servlet/JSO应用的容器。客户端通过HTTPServer访问服务器上存储的资源(HTML文件,图片文件等),HTTPServer是中只是把服务器

php站用iis乱码而apache没事怎么解决php站用iis乱码而apache没事怎么解决Mar 23, 2023 pm 02:48 PM

​在使用 PHP 进行网站开发时,你可能会遇到字符编码问题。特别是在使用不同的 Web 服务器时,会发现 IIS 和 Apache 处理字符编码的方法不同。当你使用 IIS 时,可能会发现在使用 UTF-8 编码时出现了乱码现象;而在使用 Apache 时,一切正常,没有出现任何问题。这种情况应该怎么解决呢?

如何在 RHEL 9/8 上设置高可用性 Apache(HTTP)集群如何在 RHEL 9/8 上设置高可用性 Apache(HTTP)集群Jun 09, 2023 pm 06:20 PM

Pacemaker是适用于类Linux操作系统的高可用性集群软件。Pacemaker被称为“集群资源管理器”,它通过在集群节点之间进行资源故障转移来提供集群资源的最大可用性。Pacemaker使用Corosync进行集群组件之间的心跳和内部通信,Corosync还负责集群中的投票选举(Quorum)。先决条件在我们开始之前,请确保你拥有以下内容:两台RHEL9/8服务器RedHat订阅或本地配置的仓库通过SSH访问两台服务器root或sudo权限互联网连接实验室详情:服务器1:node1.exa

Linux下如何查看nginx、apache、mysql和php的编译参数Linux下如何查看nginx、apache、mysql和php的编译参数May 14, 2023 pm 10:22 PM

快速查看服务器软件的编译参数:1、nginx编译参数:your_nginx_dir/sbin/nginx-v2、apache编译参数:catyour_apache_dir/build/config.nice3、php编译参数:your_php_dir/bin/php-i|grepconfigure4、mysql编译参数:catyour_mysql_dir/bin/mysqlbug|grepconfigure以下是完整的实操例子:查看获取nginx的编译参数:[root@www~]#/usr/lo

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!