0

I'm starting a course in PHP which will require its own web-pages that I do not want to conflict with my existing work. The Ubuntu instructions are here: HTTPD - Apache2 Web Server

See the code below in my new "/etc/apache2/sites-available/RecipeCenter". The old "/etc/apache2/sites-available/000-default.conf" still exists. The only difference between the two versions is the line for document root, which was changed from "/var/www/html" to "/var/www/RecipeCenter" in the new file as shown below. After following the instructions, I also ran the update program and restart. No error messages were generated.

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/RecipeCenter

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Entering "localhost/RecipeCenter/testph2.php" into the firefox browser did not work. However, as a test, I did copy the RecipeCenter folder into the same folder as my default folder so I was able to get "localhost/RecipeCenter/testph.php" to work. While that solves the problem, I still have an unanswered concern with why the new .conf file did not work.

0

You should symlink your /etc/apache2/sites-available/RecipeCenter to /etc/apache2/sites-enabled/100-RecipeCenter.conf. (The number doesn't matter too much, though the files are included in alphabetical order, so whatever name you choose for the symlink, it should alphabetically come after 000-default.conf.

Apache actually includes vhost config files from /etc/apache2/sites-enabled. It doesn't include sites-available. The structure is made up like this to allow you to easily enable/disable sites by creating/deleting symlinks in /etc/apache2/sites-enabled, without the need to move or remove files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.