Localhost für verschiedene Projekte

Hallo,

ich habe heute eine LAMP-Umgebung mit Hilfe der Seite https://en.opensuse.org/SDB:LAMP_setup erstellt und habe ein paar Fragen zur weiteren Vorgehensweise.

Wenn ich es richtig sehe, wurden im Verzeichnis /etc mehrere Verzeichnisse neu angelegt, u. a. apache2 und php7

Das Hoch- und Runterfahren der Datenbank klappt:

systemctl start mysql
systemctl stop mysql
systemctl restart mysql

Der Webserver funktioniert ebenfalls:
Wenn ich localhost im Browser eingebe, wird die Seite index.html aus dem Verzeichnis /srv/www/htdocs angezeigt.
Ich habe dort eine weitere Seite angelegt - index.php mit dem Inhalt <?php>phpinfo() -, die wird auch angezeigt.

Nun möchte ich aber mit mehreren Projekten in meinem üblichen Projektpfad arbeiten. Ich habe unter ~/Projekte deshalb zwei Test-Projekte angelegt, php1 und php2.

Was muss ich tun, wo muss ich was ändern, damit ich im Browser nur php1 (für den Aufruf von index.html) bzw. php1/index.php eingeben muss - das gleiche mit php2 -, damit mir das Projekt meiner Wahl angezeigt wird bzw. ggf. auch localhost (für /srv/www/htdocs/index.html) und localhost/php1 (für ~Projekte/php1/index.html) statt php1 sowie localhost/php2 (für ~Projekte/php2/index.html) statt php2?

Und was ist generell üblich? Vielleicht habe ich ja einen falschen Ansatz. Irgendwann werde ich aus der Test-/Anfängerphase heraus sein und dann ein Projekt auf den Strato-Server portieren wollen unter https://www.mein-PHP-Projekt.de; könnte/sollte ich die URL jetzt schon irgendwo eingeben?

Grüße

Linux:/etc # cd ~/Projekte
Linux:~/Projekte # ls -l php*
php1:
insgesamt 8
-rw-r--r-- 1 user1 users 62 20. Feb 11:38 index.html
-rw-r--r-- 1 user1 users 39 20. Feb 11:34 index.php

php2:
insgesamt 8
-rw-r--r-- 1 user1 users 62 20. Feb 11:38 index.html
-rw-r--r-- 1 user1 users 39 20. Feb 11:34 index.php
Linux:~/Projekte # 

-------------------------------------------------------

Linux:/srv/www/htdocs # ls -l
insgesamt 20
-rw-r--r-- 1 root root  302 13. Mär 2006  favicon.ico
drwxr-xr-x 1 root root  106 10. Nov 13:42 gif
-rw-r--r-- 1 root root   45 11. Jun 2007  index.html
-rw-r--r-- 1 root root   21 20. Feb 07:53 index.php
-rw-r--r-- 1 root root 2356  7. Aug 2017  info2html.css
drwxr-xr-x 1 root root 2954 20. Feb 07:07 phpMyAdmin
-rw-r--r-- 1 root root   26 29. Jan 12:06 robots.txt
Linux:/srv/www/htdocs # 

Man kan verschienede root directories in Apache configurieren.
Die “Haupt” root ist (vorconfiguriert) die Documentroot:

DocumentRoot "/srv/www/htdocs"
<Directory "/srv/www/htdocs">
.........
</Directory>

Auch schon da ist:

Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
 .........
</Directory>

Ich habe zB hinzugefügt:

Alias /milweb/ "/home/henk/milweb/"

<Directory "/home/henk/milweb">
 .............
</Directory>

und

Alias /smweb/ "/home/smweb/midrange/"

<Directory "/home/smweb/midrange">
 ............
</Directory>

Vom client/browser werden die (durch benützen der Alias Name) als
http://localhost/
http://localhost/icons/
http:://localhost/milweb/
http:/localhost/midrange/
gefunden (von andere clients localhost natürlich erzetzt durck den URL des Systems.

Natürlicherweise muß das Apache prozess diese Directories/Files lesen können!

Ich war wohl etwas voreilig. Die Seite index.html wird zwar angezeigt, aber der PHP-Code darin wird nicht angezeigt. Wo muss ich das einstellen?

Und wie hast du in Apache configuriert das PHP benützt werden soll?

Wo muss ich da gucken, Henk?

Es gibt einen File /etc/apache2/conf.d/php7.conf mit folgendem Inhalt:

<IfModule mod_php7.c>
       <FilesMatch "\.ph(p[345]?|tml)$">
           SetHandler application/x-httpd-php
       </FilesMatch>
       <FilesMatch "\.php[345]?s$">
           SetHandler application/x-httpd-php-source
       </FilesMatch>
        DirectoryIndex index.php4
        DirectoryIndex index.php5
        DirectoryIndex index.php
</IfModule>


/etc/sysconfig/apache2
Die Zeile APACHE_MODULES=“…” gibt an welche Apache Module geladen werden sollen.

Oder:

a2enmod -l

Das php5 Modul aktivieren kann man entweder durch Hinzufügen in der Datei, oder mit:

a2enmod php5

Zum deaktivieren:

a2enmod -d php5

PS: da du scheinbar php7 nutzen willst muss du in meinem vorigen Post natürlich “php5” mit “php7” ersetzen… :wink:

PPS: wie man PHP aktiviert steht aber auch auf https://en.opensuse.org/SDB:LAMP_setup#Setting_up_PHP .

@wolfi
Falls du

root # zypper in php7 php7-mysql apache2-mod_php7

und

a2enmod php7

meinst, das habe ich gemacht.

Linux:/srv/www/htdocs # a2enmod php7
"php7" already present

@Henk
php7 ist schon enthalten in /etc/sysconfig/apache2:

APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_core authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout version php7 authn_core"

Ok, hab “übersehen” dass es ja scheinbar in /srv/www/htdocs/ funktioniert, aber nicht in anderen Verzeichnissen.

Liegt dann vermutlich an der Apache Konfiguration.
Wie greifst du jetzt genau auf diese alternativen Verzeichnisse zu?
Wie ist die zugehörige Config?

Evtl. kannst/musst du mit einer .htaccess Datei im entsprechenden Verzeichnis das Ausführen von PHP-Scripts erlauben, bin aber im Moment überfragt wie genau das geht (ist ne Weile her dass ich Apache konfiguriert habe…)

In /home/user/public_html/ sollts aber per default gehen, vielleicht wäre ein akzeptabler Workaround für die einzelnen Projekte verschiedene User zu benützen (bzw. Unterordner von /home/user/public_html/ eines einzelnen Benutzer).

PS: vielleicht hilfts ja die entsprechenden “SetHandler” Direktiven zu deinen <Directory> Definitionen hinzuzufügen.
Also so in der Art:

<Directory "xxxxxx">
<IfModule mod_php7.c>
       <FilesMatch "\.ph(p[345]?|tml)$">
           SetHandler application/x-httpd-php
       </FilesMatch>
       <FilesMatch "\.php[345]?s$">
           SetHandler application/x-httpd-php-source
       </FilesMatch>
        DirectoryIndex index.php4
        DirectoryIndex index.php5
        DirectoryIndex index.php
</IfModule>
.........
</Directory>


(das <IfModule> dient nur zur Verhinderung von Fehlern wenn PHP7 nicht installiert ist und kann auch weggelassen werden…)

Ich bin mir nicht sicher, welche Datei(en) du meinst.

Linux:/etc/apache2 # ls -lr
insgesamt 124
drwxr-xr-x 1 root root    64 20. Feb 07:07 vhosts.d
-rw-r--r-- 1 root root    22 29. Jan 12:06 uid.conf
drwxr-xr-x 1 root root    76 20. Feb 07:07 sysconfig.d
drwxr-xr-x 1 root root    20 20. Feb 07:07 ssl.prm
drwx------ 1 root root    20 20. Feb 07:07 ssl.key
-rw-r--r-- 1 root root  6388 29. Jan 12:06 ssl-global.conf
drwxr-xr-x 1 root root    20 20. Feb 07:07 ssl.csr
drwxr-xr-x 1 root root    20 20. Feb 07:07 ssl.crt
drwxr-xr-x 1 root root    20 20. Feb 07:07 ssl.crl
-rw-r--r-- 1 root root  4868 29. Jan 12:06 server-tuning.conf
-rw-r--r-- 1 root root    85 29. Jan 12:06 mod_usertrack.conf
-rw-r--r-- 1 root root  1504 29. Jan 12:06 mod_userdir.conf
-rw-r--r-- 1 root root   456 29. Jan 12:06 mod_status.conf
-rw-r--r-- 1 root root  1020 29. Jan 12:06 mod_reqtimeout.conf
-rw-r--r-- 1 root root   763 18. Mär 2017  mod_perl-startup.pl
-rw-r--r-- 1 root root  5243 29. Jan 12:06 mod_mime-defaults.conf
-rw-r--r-- 1 root root  1057 29. Jan 12:06 mod_log_config.conf
-rw-r--r-- 1 root root   499 29. Jan 12:06 mod_info.conf
-rw-r--r-- 1 root root   344 29. Jan 12:06 mod_cgid-timeout.conf
-rw-r--r-- 1 root root  1503 29. Jan 12:06 mod_autoindex-defaults.conf
lrwxrwxrwx 1 root root    13 20. Feb 07:07 mime.types -> ../mime.types
-rw-r--r-- 1 root root 13077 29. Jan 12:03 magic
-rw-r--r-- 1 root root  1957 29. Jan 12:06 loadmodule.conf
-rw-r--r-- 1 root root  1053 29. Jan 12:06 listen.conf
-rw-r--r-- 1 root root  9033 29. Jan 12:06 httpd.conf                                                                            
-rw-r--r-- 1 root root   128 29. Jan 12:06 global.conf                                                                           
-rw-r--r-- 1 root root  2924 29. Jan 12:06 errors.conf                                                                           
-rw-r--r-- 1 root root  4260 29. Jan 12:06 default-server.conf                                                                   
drwxr-xr-x 1 root root   124 20. Feb 14:58 conf.d                                                                                
-rw-r--r-- 1 root root  1764 29. Jan 12:06 charset.conv 

---

Linux:/etc/apache2/conf.d # more php7.conf
<IfModule mod_php7.c>
       <FilesMatch "\.ph(p[345]?|tml)$">
           SetHandler application/x-httpd-php
       </FilesMatch>
       <FilesMatch "\.php[345]?s$">
           SetHandler application/x-httpd-php-source
       </FilesMatch>
        DirectoryIndex index.php4
        DirectoryIndex index.php5
        DirectoryIndex index.php
</IfModule>

---

Linux:/etc/apache2 # more httpd.conf
#
# /etc/apache2/httpd.conf 
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information about
# the directives.

# Based upon the default apache configuration file that ships with apache,
# which is based upon the NCSA server configuration files originally by Rob
# McCool. This file was knocked together by Peter Poeml <poeml+apache@suse.de>.

# If possible, avoid changes to this file. It does mainly contain Include
# statements and global settings that can/should be overridden in the
# configuration of your virtual hosts.

# Quickstart guide:
# http://en.opensuse.org/SDB:Apache_installation


# Overview of include files, chronologically:
#
# httpd.conf
#  | 
#  |-- uid.conf  . . . . . . . . . . . . . .  UserID/GroupID to run under
#  |-- server-tuning.conf  . . . . . . . . .  sizing of the server (how many processes to start, ...)
#  |-- loadmodule.conf . . . . . . . . . . .  
[li] load these modules[/li]#  |-- listen.conf . . . . . . . . . . . . .  IP adresses / ports to listen on
#  |-- mod_log_config.conf . . . . . . . . .  define logging formats
#  |-- global.conf . . . . . . . . . . . . .  
[li] server-wide general settings[/li]#  |-- mod_status.conf . . . . . . . . . . .  restrict access to mod_status (server monitoring)
#  |-- mod_info.conf . . . . . . . . . . . .  restrict access to mod_info
#  |-- mod_reqtimeout.conf . . . . . . . . .  set timeout and minimum data rate for receiving requests
#  |-- mod_cgid-timeout.conf . . . . . . . .  set CGIDScriptTimeout if mod_cgid is loaded/active
#  |-- mod_usertrack.conf  . . . . . . . . .  defaults for cookie-based user tracking
#  |-- mod_autoindex-defaults.conf . . . . .  defaults for displaying of server-generated directory listings
#  |-- mod_mime-defaults.conf  . . . . . . .  defaults for mod_mime configuration
#  |-- errors.conf . . . . . . . . . . . . .  customize error responses
#  |-- ssl-global.conf . . . . . . . . . . .  SSL conf that applies to default server _and all_ virtual hosts
#  |
#  |-- default-server.conf . . . . . . . . .  set up the default server that replies to non-virtual-host requests
#  |    |--mod_userdir.conf  . . . . . . . .  enable UserDir (if mod_userdir is loaded)
#  |    `--conf.d/apache2-manual?conf  . . .  add the docs ('?' = if installed)
#  |
#  `-- vhosts.d/ . . . . . . . . . . . . . .  for each virtual host, place one file here
#       `-- *.conf . . . . . . . . . . . . .     (*.conf is automatically included)
#
#
# Files marked 
[li] are NOT read when server is started via systemd service. When server[/li]# is started via service, defaults from /etc/sysconfig/apache2 are taken into account.
#



#  Filesystem layout:
#
# /etc/apache2/
#  |-- charset.conv  . . . . . . . . . . . .  for mod_auth_ldap
#  |-- conf.d/
#  |   |-- apache2-manual.conf . . . . . . .  conf that comes with apache2-doc
#  |   |-- mod_php4.conf . . . . . . . . . .  (example) conf that comes with apache2-mod_php4
#  |   `-- ... . . . . . . . . . . . . . . .  other configuration added by packages
#  |-- default-server.conf
#  |-- errors.conf
#  |-- httpd.conf  . . . . . . . . . . . . .  top level configuration file
#  |-- listen.conf
#  |-- magic
#  |-- mime.types -> ../mime.types
#  |-- mod_autoindex-defaults.conf
#  |-- mod_info.conf
#  |-- mod_log_config.conf
#  |-- mod_mime-defaults.conf
#  |-- mod_perl-startup.pl
#  |-- mod_status.conf
#  |-- mod_userdir.conf
#  |-- mod_usertrack.conf
#  |-- server-tuning.conf
#  |-- ssl-global.conf
#  |-- ssl.crl/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Revocation Lists (CRL)
#  |-- ssl.crt/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificates
#  |-- ssl.csr/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Signing Requests
#  |-- ssl.key/  . . . . . . . . . . . . . .  PEM-encoded RSA Private Keys
#  |-- ssl.prm/  . . . . . . . . . . . . . .  public DSA Parameter Files
#  |-- global.conf
#  |-- loadmodule.conf
#  |-- uid.conf
#  `-- vhosts.d/ . . . . . . . . . . . . . .  put your virtual host configuration (*.conf) here
#      |-- vhost-ssl.template
#      `-- vhost.template



### Global Environment ######################################################
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests.

# run under this user/group id
Include /etc/apache2/uid.conf

# - how many server processes to start (server pool regulation)
# - usage of KeepAlive
Include /etc/apache2/server-tuning.conf

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog /var/log/apache2/error_log

# generated from default value of APACHE_MODULES in /etc/sysconfig/apache2
<IfDefine !SYSCONFIG>
  Include /etc/apache2/loadmodule.conf
</IfDefine>

# IP addresses / ports to listen on
Include /etc/apache2/listen.conf

# predefined logging formats
Include /etc/apache2/mod_log_config.conf

# generated from default values of global settings in /etc/sysconfig/apache2
<IfDefine !SYSCONFIG>
  Include /etc/apache2/global.conf
</IfDefine>

# optional mod_status, mod_info
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf

# mod_reqtimeout protects the server from the so-called "slowloris"
# attack: The server is not swamped with requests in fast succession,
# but with slowly transmitted request headers and body, thereby filling up
# the request slots until the server runs out of them.
# mod_reqtimeout is lightweight and should deliver good results
# with the configured default values. You shouldn't notice it at all.
Include /etc/apache2/mod_reqtimeout.conf

# Fix for CVE-2014-0231 introduces new configuration parameter 
# CGIDScriptTimeout. This directive and its effect prevent request 
# workers to be eaten until starvation if cgi programs do not send 
# output back to the server within the timout set by CGIDScriptTimeout.
Include /etc/apache2/mod_cgid-timeout.conf

# optional cookie-based user tracking
# read the documentation before using it!!
Include /etc/apache2/mod_usertrack.conf

# configuration of server-generated directory listings
Include /etc/apache2/mod_autoindex-defaults.conf

# associate MIME types with filename extensions
TypesConfig /etc/apache2/mime.types
Include /etc/apache2/mod_mime-defaults.conf

# set up (customizable) error responses
Include /etc/apache2/errors.conf

# global (server-wide) SSL configuration, that is not specific to 
# any virtual host
Include /etc/apache2/ssl-global.conf

# forbid access to the entire filesystem by default
<Directory />
    Options None
    AllowOverride None
    <IfModule !mod_access_compat.c>
        Require all denied
    </IfModule>
    <IfModule mod_access_compat.c>
        Order deny,allow
        Deny from all
    </IfModule>
</Directory>

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
    <IfModule !mod_access_compat.c>
        Require all denied
    </IfModule>
    <IfModule mod_access_compat.c>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var

### 'Main' server configuration #############################################
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
Include /etc/apache2/default-server.conf


### Virtual server configuration ############################################
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
IncludeOptional /etc/apache2/vhosts.d/*.conf


# Note: instead of adding your own configuration here, consider 
#       adding it in your own file (/etc/apache2/httpd.conf.local)
#       putting its name into APACHE_CONF_INCLUDE_FILES in 
#       /etc/sysconfig/apache2 -- this will make system updates 
#       easier :) 

Und ich bin mir nicht sicher was du bis jetzt genau gemacht hast, um auf deine Verzeichnisse zuzugreifen.

Du musst die ja irgendwo mittels <Directory “xxx”>…</Directory> deklariert haben (wie von hcvv beschrieben), oder?
(ich denke sonst würde Apache ja überhaupt keinen Zugriff erlauben, bzw. sie nicht “finden”)
Dort fügst du eben diese Zeilen hinzu.

Oder eben in einer .htaccess Datei im entsprechenden Verzeichnis (mit den HTML/PHP Files).

Bzw. ich denke ein “Include /etc/apache2/conf.d/php7.conf” sollte auch gehen.

Falls du mehrere vhosts angelegt hast (was meines Erachtens nach die “normale” Herangehensweise wäre um mehrere Webseiten/Projekte zu haben), ist wahrscheinlich dort was “falsch”. Ein Posten der entsprechended vhosts Config könnte dann helfen… :wink:

Ich habe keine vhosts angelegt. Es gibt in /etc eine hosts, die sieht so aus:

#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#    
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1    localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts

Und dann gibt es noch zwei httpd-vhosts.conf in /opt/lampp/etc/extra und /opt/lampp/etc/original/extra/ mit folgendem Inhalt:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

@wolfi

Ok, hab “übersehen” dass es ja scheinbar in /srv/www/htdocs/ funktioniert, aber nicht in anderen Verzeichnissen.

Es funktioniert der PHP-File, im HTML-File wird kein PHP interpretiert.

Das ist was komplett anderes, darin kannst du statisch Hostnamen zu IP-Adressen zuweisen.

Ich probiers nochmal:
Apache erlaubt normalerweise nur Zugriff auf /srv/www/htdocs/ bzw. ~/public_html/ (via http://localhost/~username/)

Du hast aber geschrieben dass deine HTML/PHP-Dateien in ~/Projekte/ liegen.
Was hast du wo geändert dass diese als Webseite angezeigt werden?

(eine Möglichkeit wäre vhosts mit einem anderen DocumentRoot anzulegen, das hast du aber scheinbar nicht gemacht…)

Obwohl, da fällt mir grade noch was anderes auf.
Du hast geschrieben:

Um PHP-Code auszuführen, muss die Datei aber auch xxx.php heissen, also nicht index.html sondern index.php.
Ist das vielleicht das unmittelbare Problem?

Bzw. du hast ja scheinbar beides, also probier mal index.html zu löschen…
Ansonsten kanns sein dass die bevorzugt wird wenn du nicht explicit http://xxx/index.php aufrufst.

Ich verliere langsam die Übersicht hier.

Bitte jetzt mal genau melden was “lauft” und was "nicht lauft. Am besten miet die zugehörige Teilen der Apache Konfiguration.

Kan ein Browser jetzt:

  • Kan ein Browser jetzt ein HTML Datei vom DocumentRoot (/srv/www/htdocs) herunterladen oder nicht?
  • Kan ein Browser jetzt die Resultaten eines PHP Programs im DocumentRoot bekommen oder nicht?
  • Hast du weitere Dokumenten Startpunkten konfiguriert (über Alias und Directory definition) oder nicht?
  • Wenn ja, kan dan ein Browser ein HTML Datei von dieser Alias herunterladen oder nicht?
  • Auch wenn ja, kommen de Resultaten eines PHP Programs in dieser Alias herunter oder nicht?

Und das ist normal.
Ein HTML-File ist eben ein HTML-File, und kein PHP-File.

Wenn du PHP-Code verwenden willst, muss die Datei xxx.php heissen, wie geschrieben (oder alternativ xxx.php3, xxx.php4, xxx.php5 oder xxx.phtml). Nur dann schickt Apache sie durch den PHP-Interpreter.
Das ist von den SetHandler Direktiven in der Config (php7.conf) so definiert:

<FilesMatch "\.ph(p[345]?|tml)$">
           SetHandler application/x-httpd-php
  </FilesMatch>
  

Das sagt Apache eben, dass Dateien mit dem angegebenen Muster PHP-Files sind…

Du könntest natürlich auch konfigurieren dass .html Files in Wirklichkeit auch PHP-Files sind, aber das macht nicht wirklich Sinn, meiner Meinung nach.

Das alles geht viel einfacher wenn /srv/www/htdocs/ Webroot ist. Also
/srv/www/htdocs/php1
/srv/www/htdocs/php2
usw.

@Henk

Ja, aber der PHP-Code des HTML-Files wird nicht interpretiert. Wolfi323 meint, das sei normal.

Ein PHP-File mit PHP-Code wird korrekt interpretiert.

Bisher noch nicht. Bis jetzt haben wir uns an PHP-Code in einer PHP- bzw. HTML-Datei festgebissen.

Soweit sind wir noch nicht, siehe vorherige Frage.

Soweit sind wir noch nicht, siehe vorvorherige Frage.

Ich habe zwischenzeitlich die Seite Weekend Project: Create Virtual Hosts with Apache - Linux.com gefunden, und das Thema Hosts/Virtualhosts scheint mir da so gut beschrieben zu sein, dass ich hoffe es zu kapieren und dann hinzubekommen.

Das Thema PHP-Code-Interpretation im HTML-File hake ich ab, da es offenbar kein Standard ist und nur mit Klimmzügen und von hinten durch die Brust ins Auge möglich ist.

Bevor es jetzt noch chaotischer wird, würde ich sagen, ich versuche es mit Hilfe der vorgenannten Seite hinzubekommen in Sachen php1- und php2-Testpfaden, und dann melde ich mich noch mal.

“PHP-Code-Interpretation im HTML-File” ist schon Standard. Aber die Datei muss eben xxx.php heissen um Apache zu sagen dass da (auch) PHP-Code enthalten ist. Ansonsten wird Apache eben einfach den Inhalt der Datei liefern ohne den PHP-Interpreter drüberlaufen zu lassen.

Apache selbst hat keine Ahnung von PHP, außerdem gibts ja auch noch andere Skriptsprachen…