我一直在努力将Apache 2.4与php5-fpm一起使用来运行PHP文件。我搜索了很多最新和过时的信息。 https://askubuntu.com/a/935343中对我的要求进行了最好的解释之一 这篇文章提到了多种执行PHP的方法。在这些方法中,我想使用UDS SetHandler方法进行配置(在提到的文章链接中没有3.c)。
尽管我已经根据方法进行了配置,但我的PHP脚本并未执行,而是显示在浏览器中。
这是我的VirtualHost配置
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/log/apache2/example.com_error_log
CustomLog /var/log/apache2/example.com_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /var/www/example.com/public_html>
allow from all
Require all granted
<FilesMatch \.php$>
SetHandler "proxy:fcgi://localhost:8001/"
</FilesMatch>
</Directory>
</VirtualHost>
这是apache2ctl -V和apache2ctl -M的输出
# apache2ctl -V
Server version: Apache/2.4.7 (Ubuntu)
Server built: Apr 18 2018 15:36:26
Server's Module Magic Number: 20120211:27
Server loaded: APR 1.5.1-dev, APR-UTIL 1.5.3
Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
# 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)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
auth_basic_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)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
headers_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_fcgi_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)