What should I do if ubuntu apache2 cannot open php?

藏色散人
Release: 2023-03-14 11:28:01
Original
3027 people have browsed it

ubuntu apache2 cannot open php solution: 1. Open the configuration file httpd.conf; 2. Modify the content to "AddType application/x-httpd-php .php..."; 3. Install apache Expansion pack is enough.

What should I do if ubuntu apache2 cannot open php?

The operating environment of this article: ubuntu 16.04 system, PHP5 version, Dell G3 computer.

ubuntu apache2 What should I do if I cannot open php?

Solution to the problem of Apache not parsing PHP under Ubuntu

In the past two days, the author encountered a very fucking problem-Apache cannot parse PHP code. It has been used well before. , suddenly hung up, and then I was frantically looking for solutions on the Internet, but most of them were version php5, but I was version 7, so I will post the solution for version 5 first:

Modify apache's configuration file httpd.conf

Found in httpd.conf:
AddType application/x-gzip .gz .tgz
Add below this line
AddType application/x-httpd-php .php

Look and continue to find:
DirectoryIndex index.html,
put this line Change it 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 the configuration file httpd.conf, but refers to each configuration file through an apache2.conf Part of the configuration file, it is not easy to find that configuration in a configuration package, and I haven't found it yet. . .

However, Huangtian paid off and finally found a solution:

sudo apt-get install libapache2-mod-php
Copy after login

In this step, the apache expansion pack is installed, which can be used to parse php. I think it does not matter whether it is version 7 or version 5. All can be applied.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if ubuntu apache2 cannot open php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!