First of all, my example of a virtualhost is working without embedding <? php echo 'Hello World'; ?>
in index.html
.
Apache
is on the same machine I am using. PHP
is two times availble on this machine.
$ which php
/usr/bin/php
$ which php7.0
/usr/bin/php7.0
Furthermore: libapache2-mod-php7.0
is already installed.
What I have done until now:
$ sudo mkdir /var/www/www.virtualhost.com/
$ cd /var/www/www.virtualhost.com/
$ sudo cat > index.html
<html>
<body>
<h1>My virtualhost</h1>
PHP Test:<br>
<?php echo "PHP"; ?>
</body>
</html>
ctrl+d
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-availble/virtualhost.com.conf
After editing my virtualhost.com.conf
file it look's like:
<VirtualHost *:80>
ServerName www.virtualhost.com
ServerAlias virtualhost.com
ServerAdmin webmaster@virtualhost.com
DocumentRoot /var/www/www.virtualhost.com
DirectoryIndex index.html index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/www.virtualhost.com/>
Options +Indexes -FollowSymlinks
AllowOverride None
</Directory>
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Then I enabled my site, made an entry in my /etc/hosts
file and restartet apache2
with following commands:
$ sudo a2ensite virtualhost.com.conf
$ sudo apache2ctl restart
The new entries in my /etc/hosts
are:
127.0.0.1 www.testhost.com
127.0.0.1 www.virtualhost.com
Following modules are activated:
$ a2query -m
authz_host (enabled by maintainer script)
proxy_fcgi (enabled by site administrator)
socache_shmcb (enabled by site administrator)
negotiation (enabled by maintainer script)
filter (enabled by maintainer script)
access_compat (enabled by maintainer script)
authz_core (enabled by maintainer script)
deflate (enabled by maintainer script)
authn_file (enabled by maintainer script)
php7.0 (enabled by maintainer script)
authz_user (enabled by maintainer script)
authnz_fcgi (enabled by site administrator)
mime (enabled by maintainer script)
proxy (enabled by site administrator)
mpm_prefork (enabled by site administrator)
dir (enabled by maintainer script)
alias (enabled by maintainer script)
auth_basic (enabled by maintainer script)
setenvif (enabled by maintainer script)
cgi (enabled by site administrator)
env (enabled by maintainer script)
autoindex (enabled by maintainer script)
authn_core (enabled by maintainer script)
status (enabled by maintainer script)
ssl (enabled by site administrator)
Without the line <?php echo "PHP"; ?>
in index.html
the site is working. But if I embed this line php's echo is not echoing.
Do I need something like
LoadModule php7_module modules/libphp7.so
in my /etc/apache2/apache2.conf
?
Any hint for solving this issue is welcome.