yum The solution for apache not parsing php: 1. Install the dependency package httpd-devel; 2. Check the path of apsx; 3. Add the apxs path parameter when compiling php; 4. Modify the apache configuration file; 5 , just restart the service.
The operating environment of this article: centos7 system, php5.6 version, DELL G3 computer
How to solve the problem that yum apache does not parse php Problem?
Centos7: yum installs apache, compiles and installs php5.6, and the solution does not parse php
First, let’s talk about the scenario where the problem occurs:
Because I am lazy, I use yum to install apache. Because the centos source with php 5.4 cannot meet the environmental requirements, and I don’t want to use other sources, so I choose source code to compile and install php 5.6
After the installation is completed , apache does not parse php, the phenomenon of not parsing is that the browser directly displays or downloads the source code of the php file
I will briefly explain the process, search for the specific steps by yourself, and then focus on a few easy to step on. Pitfall
1. After installing apache in yum, you must install the dependency package httpd-devel, otherwise the file apxs does not exist, and the path of apxs needs to be configured when compiling php
yum install httpd yum install httpd-devel
2. View The path where apsx is located
rpm -ql httpd-devel|grep apxs /usr/bin/apxs //此行为 grep 结果,不同系统的路径可能不同,以实际结果为准,下同 /sur/share/man/man1/apxs.1.gz
3. When compiling php, add the apxs path parameter to generate libphp5.so
./configure \ --with-apxs2=/usr/bin/apxs
4. Install
make && make install
5. Configure services, Start the service and environment variables, which are omitted here
6. Modify the apache configuration file, the configuration file path of apache2.4 under Centos7.4 is
vim /etc/httpd/conf/httpd.conf //在LoadModule后面添加:LoadModule php5_module modules/libphp5.so //不添加则访问.php文件将会变成下载 //在DirectoryIndex后面添加:index.php //在AddType application/x-gzip .gz .tgz后面添加:AddType application/x-httpd-php .php //.php前面有一个空格
7. Restart the service
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to solve the problem of yum apache not parsing php. For more information, please follow other related articles on the PHP Chinese website!