系统是Ubuntu server 18.04 php版本是7.2.5
tang@tl-netserver:~$ php -v
PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 5 2018 05:00:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
这个是php的版本信息,Apache2正常安装,能浏览主页,但是php文件直接显示代码,不解析
不知道是哪里出了问题
刚接触Ubuntu 18.04,配置PHP网站死活不成功
-
- 帖子: 3
- 注册时间: 2018-05-19 23:30
- 系统: ubuntu 18.04
- TeliuTe
- 论坛版主
- 帖子: 7668
- 注册时间: 2007-11-25 13:29
- 系统: 16/18/20/w7
- 来自: 新疆博乐
- 联系:
Re: 刚接触Ubuntu 18.04,配置PHP网站死活不成功
下载一个高版本的 XAMPP,看一下里面的配置文件,对照着修改一下: https://www.apachefriends.org/zh_cn/download.html
XAMPP for Linux 5.6.36, 7.0.30, 7.1.17 & 7.2.5
7.2.5 / PHP 7.2.5 包含什么内容? md5 sha1 下载 (64 bit) 134 Mb
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: 刚接触Ubuntu 18.04,配置PHP网站死活不成功
https://help.ubuntu.com/lts/serverguide/php.html.en-GB
PHP - Scripting Language
PHP - Scripting Language
-
- 帖子: 3
- 注册时间: 2018-05-19 23:30
- 系统: ubuntu 18.04
Re: 刚接触Ubuntu 18.04,配置PHP网站死活不成功
按照网站上说明一步步的做了,还是不行poloshiao 写了:https://help.ubuntu.com/lts/serverguide/php.html.en-GB
PHP - Scripting Language
浏览PHP网页,还是直接显示php代码
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: 刚接触Ubuntu 18.04,配置PHP网站死活不成功
1. 檢查浏览PHP网页,还是直接显示php代码
1-1. https://help.ubuntu.com/lts/serverguide ... html.en-GB
HTTPD - Apache2 Web Server
Default Settings
/etc/apache2/mods-available/dir.conf
"index.html index.cgi index.pl index.php index.xhtml index.htm"
看看 有沒有需要 改為
"index.php index.html index.cgi index.pl index.xhtml index.htm"
1-2. https://help.ubuntu.com/lts/serverguide ... figuration
Configuration
Please verify if the files /etc/apache2/mods-enabled/php7.0.conf and /etc/apache2/mods-enabled/php7.0.load exist.
看看 有沒有 這兩個檔案
/etc/apache2/mods-enabled/php7.0.conf
/etc/apache2/mods-enabled/php7.0.load
2. 測試
https://help.ubuntu.com/lts/serverguide ... hp-testing
Testing
2-1. 用 gedit 寫一個檔案
2-1-1. 檔案名稱
phpinfo.php
2-1-2. 檔案內容
<?php
phpinfo();
?>
2-1-3. 儲存到
Apache2 Web server 的 DocumentRoot 目錄內
2-1-4. 設定 phpinfo.php 的權限為 755 或 775
3. 把 http://hostname/phpinfo.php 輸入你的瀏覽器網址欄
其中 hostname 是你的 Apache2 Web server 也可以輸入 IP
看看 顯示的成果
-
- 帖子: 3
- 注册时间: 2018-05-19 23:30
- 系统: ubuntu 18.04
Re: 刚接触Ubuntu 18.04,配置PHP网站死活不成功
搞清楚了,是PHP文件编码的问题,终于可以正常浏览了