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 solve the problem that ubuntu apache2 cannot open php

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

Share

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

This article will explain in detail how to solve the problem that ubuntu apache2 can not open php. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Ubuntu apache2 can not open php solutions: 1, open the configuration file httpd.conf;2, modify the content to "AddType application/x-httpd-php .php."; 3, install the apache expansion package.

This article operating environment: ubuntu 16.04system, PHP5 version, Dell G3 computer.

Solve the problem that Apache does not parse PHP under Ubuntu

In the past two days, the author encountered a very stupid problem-Apache was unable to parse PHP code. I used it very well before, then suddenly hung up, and then frantically looked for a solution on the Internet, but most of them were php5 version, while I was 7 version. By the way, I posted the solution of version 5:

Modify the configuration file httpd.conf of apache

Find in httpd.conf:

AddType application/x-gzip .gz .tgz

Add below the line

AddType application/x-httpd-php .php

Keep looking. Keep finding:

DirectoryIndex index.html

Change this line to

DirectoryIndex index.html index.htm index.php

And then find:

# ServerName www.example.com:80

Change to

ServerName localhost:80

However, Apache under Ubuntu does not have a httpd.conf configuration file, but references each part of the configuration file through an apache2.conf, so it is not easy to find that configuration in a configuration package, and I have not found it yet.

However, the emperor lived up to the people with good intentions, and finally found a solution:

Sudo apt-get install libapache2-mod-php

This step installs the extension package of apache, which can be used to parse php. I think it is suitable for both version 7 and version 5.

This is the end of this article on "how to solve the problem that ubuntu apache2 cannot open php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

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: 219

*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