[users@httpd] Need help getting php7 working..
Hello - I guess I need to appeal to some kind gurus for help, I've been racking my brains out trying to get PHP scripts working under Apache2 and just not getting any traction... I am running the following Apache2 server - > httpd -v > Server version: Apache/2.4.33 (Linux/SUSE) > Server built: 2019-03-25 13:11:14.0 + which supports a number of virtual hosts. I need to be able to get the server to support PHP scripts so as to run applications like WordPress and phpMyAdmin amongst others. Towards this goal I am trying to setup php-fpm and I have been trying to follow the instructions at > https://wiki.apache.org/httpd/PHP-FPM At the moment I do have the php-fpm service up an running. I did not change any of the configuration files for the service, I just left them in the default setup as distributed by OpenSuSE. (I didn't see anything that needed to be changed, but I can post them if that will be helpful.) The log files for php-fpm does not seem to show much - > quasar:/var/log # more php-fpm.log > [16-Apr-2019 09:40:45] NOTICE: fpm is running, pid 15415 > [16-Apr-2019 09:40:45] NOTICE: ready to handle connections > [16-Apr-2019 09:40:45] NOTICE: systemd monitor interval set to 1ms As for Apache2, these are the modules I have loaded - > quasar:/srv/apache # apachectl -M > Loaded Modules: > core_module (static) > so_module (static) > http_module (static) > mpm_prefork_module (static) > unixd_module (static) > systemd_module (static) > actions_module (shared) > alias_module (shared) > auth_basic_module (shared) > authn_core_module (shared) > authn_file_module (shared) > authz_host_module (shared) > authz_groupfile_module (shared) > authz_core_module (shared) > authz_user_module (shared) > autoindex_module (shared) > cgi_module (shared) > dir_module (shared) > env_module (shared) > expires_module (shared) > include_module (shared) > log_config_module (shared) > mime_module (shared) > negotiation_module (shared) > proxy_module (shared) > proxy_html_module (shared) > proxy_http_module (shared) > setenvif_module (shared) > ssl_module (shared) > socache_shmcb_module (shared) > userdir_module (shared) > reqtimeout_module (shared) > jk_module (shared) > rewrite_module (shared) > headers_module (shared) > substitute_module (shared) > filter_module (shared) > xml2enc_module (shared) > version_module (shared) > php7_module (shared) > proxy_fcgi_module (shared) My vhost.conf file looks something like this - > > ServerAdmin u...@mydomain.com > ServerName www.mydomain.com > ServerAlias mydomain.com > > DocumentRoot "/websites/home/user/mydomain.com" > ErrorLog "/var/log/apache2/mydomain.com-error_log" > TransferLog "/var/log/apache2/mydomain.com-access_log" > HostnameLookups Off > UseCanonicalName Off > ServerSignature On > Include /etc/apache2/conf.d/*.conf > Alias / /websites/home/user/mydomain.com/ > > ProxyPassMatch ^/(.*\.php(/.*)?)$ > fcgi://127.0.0.1:9000/websites/home/user/mydomain.com/$1 > > > JkAutoAlias /websites/home/user/mydomain.com > JkMount / tomcatWorker1 > JkMount /* tomcatWorker1 > JkUnMount /*.html tomcatWorker1 > JkUnMount /*.css tomcatWorker1 > JkUnMount /*.js tomcatWorker1 > JkUnMount /*.jpg tomcatWorker1 > JkUnMount /*.png tomcatWorker1 > JkUnMount /*.gif tomcatWorker1 > JkUnMount /*.php tomcatWorker1 > > > ScriptAlias /cgi-bin/ "/websites/home/user/mydomain.com/cgi-bin/" > > AllowOverride None > Options +ExecCGI -Includes > > Require all granted > > > Order allow,deny > Allow from all > > > > > UserDir public_html > Include /etc/apache2/mod_userdir.conf > > > > Options Indexes FollowSymLinks > DirectoryIndex /index.php index.php index.html > AllowOverride None > > Require all granted > > > Order allow,deny > Allow from all > > > > > This is some extra info (for example I am linked to a Tomcat server to handle JSP documents.) but I am striving to be complete and clear. If I try an invoke a url directly on a php file, for example http://mydomain.com/test.php I will get a "File not found" error. If I try an invoke a url on a directory containing an index.php file, I get a listing of the directory. When I try to access a .php file directly the vhost log file displays this error message - > mydomain.com-error_log > [Tue Apr 16 15:21:28.961374 2019] [proxy_fcgi:error] [pid 6651] > [client 192.168.10.10:39940] AH01071: Got error 'Primary script unknown\n' I will be more than happy to share any additional information, just tell me what to do and how... Much appreciate any help getting PHP files working, I fear my Googling research is getting close to exhaustion! ;-) Marc... -- Computers: the final frontier. These are the voyages of the
[users@httpd] Virtual hosts, include php.conf, DirectoryIndex failure
Hi - While I have a work-around for this issue, I thought I would post it here to see what, if any, feedback I might get. Perhaps I am doing something wrong? I run a rather complex server environment where I use both Apache HTTPD and Apache Tomcat servers in combination and host a number of virtual hosts (named and all using the same IP address) On one of my virtual hosts I recently installed WordPress and this required me to also add in PHP support, since WordPress uses mostly PHP scripts. Since this is only needed on one of my virtual hosts, I tried to configure just that virtual host to include the additional stuff needed to support PHP. My attempts to do so failed and the workaround was to include the PHP configuration stuff (php7.conf) at a global level that will affect all the virtual hosts that I am supporting. For now, that is OK and won't bother anything but I am wondering why my initial approach failed and if there is something that I am missing or don't understand. Basically, the symptoms, of what happened, was that the DirectoryIndex index.php setting fails when I just included the php7.conf file in the configuration file for the virtual host. But when I included the php7.file in the global http.conf or in the global default-server.conf files then it works! Error logs do not show anything other than the fact that an index file could not be found when referencing a directory that does indeed have an index.php file in it. I will show the pertinent config files (urls obscured) below in the configuration that fails, and I hope this is not overwhelming. First here is the version info for Apache just so we are all on the same page - httpd -V Server version: Apache/2.4.23 (Linux/SUSE) Server built: 2017-03-22 14:54:04.0 + Server's Module Magic Number: 20120211:61 Server loaded: APR 1.5.1, APR-UTIL 1.5.3 Compiled using: APR 1.5.1, APR-UTIL 1.5.3 Architecture: 64-bit Server MPM: prefork threaded: no 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_PROC_PTHREAD_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="/srv/www" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="/run/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="/var/log/apache2/error_log" -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf" Here is php7.conf that I am including - cat php7.conf SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source DirectoryIndex index.php4 DirectoryIndex index.php5 DirectoryIndex index.php And this is my virtual host configuration (comments removed and URLs obscured)- cat myvirtualhost.conf ServerAdmin m...@mydomain.com ServerName www.myvirtualhost.org ServerAlias myvirtualhost.org DocumentRoot "/srv/tomcat/myvirtualhost_webapps/ROOT" ErrorLog "/var/log/apache2/myvirtualhost.org-error_log" TransferLog "/var/log/apache2/myvirtualhost.org-access_log" HostnameLookups Off UseCanonicalName Off ServerSignature On RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} # THIS INCLUDE STATEMENT AND/OR THE DIRECTIVES IN PHP7.CONF FAILS FOR SOME UNKNOWN REASON! Include /etc/apache2/conf.d/php7.conf Alias / /srv/tomcat/myvirtualhost_webapps/ROOT/ JkMount / tomcatWorker1 JkMount /* tomcatWorker1 JkUnMount /*.html tomcatWorker1 JkUnMount /*.php tomcatWorker1 JkUnMount /*.css tomcatWorker1 JkUnMount /*.js tomcatWorker1 JkUnMount /*.jpg tomcatWorker1 JkUnMount /*.png tomcatWorker1 JkUnMount /*.gif tomcatWorker1 ScriptAlias /cgi-bin/ "/srv/tomcat/myvirtualhost_webapps/ROOT/cgi-bin/" AllowOverride None Options +ExecCGI -Includes Require all granted Order allow,deny Allow from all UserDir public_html Include /etc/apache2/mod_userdir.conf Options +Indexes +FollowSymLinks AllowOverride None Require all granted Order allow,deny Allow from all php_admin_flag engine on php_admin_flag engine on as I said, if I move the "Include /etc/apache2/conf.d/php7.conf" statement to a global configuration