I have a 'data collection' website and I'm trying to write some forms for it, the results of which I would like to echo out via PHP. However, I wrote some very basic code testing out the echo statement and I'm getting odd results. My code is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pre-Early-Access Access (testing area)</title>
</head>
<body>
<div class="tweets-container">
</div>
<form class="form">
<div class="form-group">
<label for="name">Full Name</label>
<input type="text" class="form-control" id="name" name="name">
</div>
<div class="form-group">
<label for="name">Watchlists You're On (separate entries with ';' symbol)</label>
<input type="text" class="form-control" id="name" name="watchlists">
</div>
<div class="form-group">
<label for="name">Twitter ID (after the @ sign)</label>
<input type="text" class="form-control" id="name" name="twitterId">
</div>
<div class="form-group">
<label for="name">Email Address</label>
<input type="text" class="form-control" id="name" name="email">
</div>
<div class="form-group">
<label for="name">PGP Key (if you have one)</label>
<input type="text" class="form-control" id="name" name="pgpkey">
</div>
<div class="form-group">
<label for="name">Home IP Address</label>
<input type="text" class="form-control" id="name" name="ipaddress">
</div>
<div class="form-group">
<label for="name">Uncheck if you do not wish to be placed on our watchlist</label>
<input type="checkbox" class="form-control" id="name" name="watch" checked>
</div>
<input type="submit" value="Submit">
</form>
<?php
echo "<p>Privacy through surveillance</p>";
?>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
</body>
</html>
I have tried using echo("<p>Privacy through surveillance</p>");
instead, with no luck.
The result of running php -v
on my server is:
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies
The end result comes out as pictured below:
No errors are logged to the browser console when viewing.
I would like only:
Privacy through surveillance
To show, without the extra characters.
I have renamed the index.html file to index.php, as well as placed the following lines in my apache2.conf file:
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
As per the linked solution. However, upon attempting to restart the apache2 process after inputing the new settings, I get this error:
apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: failed (Result: exit-code) since Wed 2017-01-11 23:01:51 UTC; 6min a Docs: man:systemd-sysv-generator(8) Process: 10654 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCE
Process: 10678 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAI lines 1-8/8 (END)
When I remove the lines suggested as additions in the answer to the question listed as a duplicate e.g.
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
I am able to restart the server as normal, but the index.php
php is still not parsed correctly.
The output of running sudo apachectl -e debug
on the server the file is serving from is as follows:
[Wed Jan 11 23:25:45.567849 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module access_compat_module from /usr/lib/apache2/modules/mod_access_compat.so [Wed Jan 11 23:25:45.568122 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module alias_module from /usr/lib/apache2/modules/mod_alias.so [Wed Jan 11 23:25:45.568271 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module auth_basic_module from /usr/lib/apache2/modules/mod_auth_basic.so [Wed Jan 11 23:25:45.568420 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module authn_core_module from /usr/lib/apache2/modules/mod_authn_core.so [Wed Jan 11 23:25:45.568564 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module authn_file_module from /usr/lib/apache2/modules/mod_authn_file.so [Wed Jan 11 23:25:45.568712 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module authz_core_module from /usr/lib/apache2/modules/mod_authz_core.so [Wed Jan 11 23:25:45.568835 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module authz_host_module from /usr/lib/apache2/modules/mod_authz_host.so [Wed Jan 11 23:25:45.568955 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module authz_user_module from /usr/lib/apache2/modules/mod_authz_user.so [Wed Jan 11 23:25:45.569089 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module autoindex_module from /usr/lib/apache2/modules/mod_autoindex.so [Wed Jan 11 23:25:45.569283 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module deflate_module from /usr/lib/apache2/modules/mod_deflate.so [Wed Jan 11 23:25:45.569406 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module dir_module from /usr/lib/apache2/modules/mod_dir.so [Wed Jan 11 23:25:45.569514 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module env_module from /usr/lib/apache2/modules/mod_env.so [Wed Jan 11 23:25:45.569629 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module filter_module from /usr/lib/apache2/modules/mod_filter.so [Wed Jan 11 23:25:45.569744 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module mime_module from /usr/lib/apache2/modules/mod_mime.so [Wed Jan 11 23:25:45.569898 2017] [so:debug] [pid 10961] mod_so.c(266): AH01575: loaded module mpm_event_module from /usr/lib/apache2/modules/mod_mpm_event.so [Wed Jan 11 23:25:45.570047 2017] [so:debug] [pid 10961:tid 140329551361920] mod_so.c(266): AH01575: loaded module negotiation_module from /usr/lib/apache2/modules/mod_negotiation.so [Wed Jan 11 23:25:45.570193 2017] [so:debug] [pid 10961:tid 140329551361920] mod_so.c(266): AH01575: loaded module rewrite_module from /usr/lib/apache2/modules/mod_rewrite.so [Wed Jan 11 23:25:45.570324 2017] [so:debug] [pid 10961:tid 140329551361920] mod_so.c(266): AH01575: loaded module setenvif_module from /usr/lib/apache2/modules/mod_setenvif.so [Wed Jan 11 23:25:45.570591 2017] [so:debug] [pid 10961:tid 140329551361920] mod_so.c(266): AH01575: loaded module status_module from /usr/lib/apache2/modules/mod_status.so httpd (pid 10871) already running
I have also tried using the short form php tags:
<?="<p>Privacy through surveillance</p>"?>
Which instead output:
Privacy through surveillance
"?>
On adding just
LoadModule php7_module modules/libphp7.so
To the apache2.conf
file the server fails. On checking the failure logs with journalctl -xe
I see:
-- Unit apache2.service has begun starting up. Jan 12 00:27:09 ubuntu apache2[12850]: * Starting Apache httpd web server apache2 Jan 12 00:27:09 ubuntu apache2[12850]: * Jan 12 00:27:09 ubuntu apache2[12850]: * The apache2 configtest failed. Jan 12 00:27:09 ubuntu apache2[12850]: Output of config test was: Jan 12 00:27:09 ubuntu apache2[12850]: apache2: Syntax error on line 221 of /etc/apache2/apache2.conf: Cannot load module Jan 12 00:27:09 ubuntu apache2[12850]: Action 'configtest' failed. Jan 12 00:27:09 ubuntu apache2[12850]: The Apache error log may have more information. Jan 12 00:27:09 ubuntu systemd1: apache2.service: Control process exited, code=exited status=1 Jan 12 00:27:09 ubuntu systemd1: Failed to start LSB: Apache2 web server. -- Subject: Unit apache2.service has failed -- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit apache2.service has failed.
-- The result is failed. Jan 12 00:27:09 ubuntu systemd1: apache2.service: Unit entered failed state. Jan 12 00:27:09 ubuntu systemd1: apache2.service: Failed with result 'exit-code'. Jan 12 00:27:09 ubuntu polkitd(authority=local)[3507]: Unregistered Authentication Agent for unix-process:12841:366652013 Jan 12 00:27:36 ubuntu sudo[12866]: peter : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/journalctl -xe Jan 12 00:27:36 ubuntu sudo[12866]: pam_unix(sudo:session): session opened for user root by root(uid=0)