首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使apache2在Ubuntu16.04上使用php7服务基于php的项目?

如何使apache2在Ubuntu16.04上使用php7服务基于php的项目?
EN

Ask Ubuntu用户
提问于 2016-03-18 05:33:19
回答 1查看 4.6K关注 0票数 0

Ubuntu16.04添加了libapache2-mod-php7.0,它扰乱了为基于php的项目提供服务的apache2配置(我对此的表述非常含糊,因为我想避免处理那些应该是开箱即用的项目的源代码/不了解内部结构(比如dokuwiki) )。

PHP7官方迁移指南和像Parse error: syntax error, unexpected 'new' (T_NEW)这样的错误(以前没有发生)和我没有进一步研究(见上面)来看,我想要服务的项目与PHP7不兼容,这使我对PHP7设置没有兴趣,因此坚持使用PHP 5。

sudo a2dismod php7.0 && sudo a2enmod php5之后,我得到了一个下载。

代码语言:javascript
运行
AI代码解释
复制
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .htm .html

一直处于站点配置中,例如

代码语言:javascript
运行
AI代码解释
复制
Listen 0.0.0.0:446 https

Alias /dokuwiki/ "/var/www/html/dokuwiki/"

DirectoryIndex index.php index.html index.htm doku.php

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .htm .html

<Directory "/var/www/html/dokuwiki">
    Options None
    AllowOverride Limit

    Require all granted
</Directory>

<VirtualHost richtercloud.de:446 >
    ErrorLog /var/log/dokuwiki/dokuwiki.log
    SSLEngine On
    DocumentRoot "/var/www/html/dokuwiki"
    ServerName richtercloud.de
    SSLCertificateFile /etc/apache2/server.crt
    SSLCertificateKeyFile /etc/apache2/server.key
</VirtualHost>

添加处理程序,如

代码语言:javascript
运行
AI代码解释
复制
AddHandler php5-script .php
AddHandler application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml

代码语言:javascript
运行
AI代码解释
复制
AddType text/html       php

(受https://serverfault.com/questions/215455/what-causes-php-pages-to-consistently-download-instead-of-running-normally启发)没有帮助。

最好将https更改为http,但我所服务的所有项目都配置为相互间构建SSL连接,因此这意味着要避免到最后一刻进行大量配置更改。

/var/log/apache2/error.log包含

代码语言:javascript
运行
AI代码解释
复制
[Fri Mar 18 14:21:45.448248 2016] [core:notice] [pid 12155] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 18 14:22:45.449327 2016] [mpm_prefork:notice] [pid 12155] AH00169: caught SIGTERM, shutting down
[Fri Mar 18 14:22:57.677426 2016] [ssl:warn] [pid 12732] AH01909: richtercloud.fritz.box:443:0 server certificate does NOT include an ID which matches the server name
[Fri Mar 18 14:22:57.677519 2016] [:notice] [pid 12732] mod_qos(009): loaded MPM is 'prefork' but mod_qos should be used with MPM 'Worker' only.
[Fri Mar 18 14:22:57.677565 2016] [:warn] [pid 12732] mod_qos(009): mod_unique_id not available (mod_qos generates simple request id if required)
[Fri Mar 18 14:22:57.793923 2016] [:notice] [pid 12737] FastCGI: process manager initialized (pid 12737)
PHP Warning:  Module 'horde_lz4' already loaded in Unknown on line 0
PHP Warning:  Module 'igbinary' already loaded in Unknown on line 0
PHP Warning:  Module 'imagick' already loaded in Unknown on line 0
PHP Warning:  Module 'intl' already loaded in Unknown on line 0
PHP Warning:  Module 'memcache' already loaded in Unknown on line 0
[Fri Mar 18 14:22:58.010146 2016] [ssl:warn] [pid 12734] AH01909: richtercloud.fritz.box:443:0 server certificate does NOT include an ID which matches the server name
[Fri Mar 18 14:22:58.010260 2016] [:notice] [pid 12734] mod_qos(009): loaded MPM is 'prefork' but mod_qos should be used with MPM 'Worker' only.
[Fri Mar 18 14:22:58.010309 2016] [:warn] [pid 12734] mod_qos(009): mod_unique_id not available (mod_qos generates simple request id if required)
[Fri Mar 18 14:22:58.025190 2016] [mpm_prefork:notice] [pid 12734] AH00163: Apache/2.4.18 (Ubuntu) Embperl/2.5.0 mod_auth_pgsql/2.0.3 mod_auth_gssapi/1.3.3 mod_auth_tkt/2.1.0 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_fcgid/2.3.9 OpenSSL/1.0.2g mod_qos/11.21 mod_scgi/1.13 mod_apreq2-20090110/2.8.0 mod_defensible/1.2 mod_perl/2.0.9 Perl/v5.22.1 configured -- resuming normal operations
[Fri Mar 18 14:22:58.025228 2016] [core:notice] [pid 12734] AH00094: Command line: '/usr/sbin/apache2'

对于每一个(重新)开始,这似乎没有问题。

上面包含的ErrorLog VirtualHostdokuwiki示例

代码语言:javascript
运行
AI代码解释
复制
[Fri Mar 18 03:07:49.551221 2016] [proxy:warn] [pid 4306] [client 192.168.179.52:34298] AH01144: No protocol handler was valid for the URL /doku.php. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

我不知道我是怎么摆脱它的,但它并没有改变什么。

代码语言:javascript
运行
AI代码解释
复制
$ sudo apache2ctl -M 
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 auth_pgsql_module (shared)
 access_compat_module (shared)
 alias_module (shared)
 apreq_module (shared)
 auth_basic_module (shared)
 auth_gssapi_module (shared)
 auth_plain_module (shared)
 auth_tkt_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 defensible_module (shared)
 deflate_module (shared)
 dir_module (shared)
 encoding_module (shared)
 env_module (shared)
 fastcgi_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 geoip_module (shared)
 headers_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 perl_module (shared)
 php5_module (shared)
 qos_module (shared)
 rewrite_module (shared)
 scgi_module (shared)
 setenvif_module (shared)
 slotmem_shm_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)
 xsendfile_module (shared)
 embperl_module (shared)

我知道这是一个基于开发版本的问题,但最好现在就回答,而不是在发布的最初几个小时之后,一群人会遇到这个问题。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2016-03-18 07:00:25

我被mods,糖果,网站和.htaccess弄糊涂了。显然,可以为php5-cgiphp7.0-fpm启用confs,可以用

代码语言:javascript
运行
AI代码解释
复制
sudo a2disconf php7.0-fpm 
sudo systemctl restart apache2.service
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/747474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档