Local Apache configuration for proper file handling

I'm new to this, so naked with me. I just configured Apache and PHP to work on my local Mac OS X computer. Now PHP works fine, except when I try to upload files for my live sites. Live sites have separate directories and are sorted by customer name, etc.

I created default symlinks in the root for local web server documents. My problem is that Apache doesn't seem to want to load any of the relative paths that are in the HTML pages. For example, I have src = "/css/main.css", but Apache does not load the file, similarly for images, it just decides how the file was not found 404 error. Then I thought that these might be symbolic links, so I copied the full directory to the root of the Apache document and still had the same result.

I would really like to set up a local development environment to run Apache, PHP, MySQL for localization, and then publish when they are ready. I also tried installing MAMP and had the same problems.

Any help whatsoever would be greatly appreciated. If my explanation is not clear, let me know.

Thank! Alex

+3
source share
2 answers

You can try using src = "./css/main.css" first.

When working with multiple live sites, I like to configure one configuration file for each site using apache, and then upload them all together to the httpd.conf file.

for my setup it looks like this:

in / etc / apache 2 / httpd.conf

I have:

# Begin virtual host directives.

Include conf/bortreb.conf

Include conf/rlmcintyre.conf

Include conf/laserkard.conf

Include conf/judyates.conf

and then in / etc / apache 2 / conf / judyates.conf

I have:

    <VirtualHost *:80>
    #localhost site

    ServerAdmin email@example.com
    DocumentRoot "/home/r/Desktop/web/judyates"
    ServerName localhost
    ServerAlias judyates.localhost
    ErrorLog "/home/r/Desktop/web/judyates/log/error_log.log"
    ScriptAlias /cgi-bin/ "/home/r/Desktop/web/judyates/cgi-bin/"

    <Directory "/home/r/Desktop/web/judyates">
        Options Indexes FollowSymLinks
        Options +ExecCGI
        AddHandler cgi-script cgi pl py
        AllowOverride Options
        Order allow,deny
        Allow from all
    </Directory>

    </VirtualHost>


  <VirtualHost *:80>

    #live site
    ServerAdmin email@example.com
    DocumentRoot "/home/r/Desktop/web/judyates"
    ServerName judyates.com
    ServerAlias *.judyates.com
    ErrorLog "/home/r/Desktop/web/judyates/log/error_log.log"
    ScriptAlias /cgi-bin/ "/home/r/Desktop/web/judyates/cgi-bin/"


    <Directory "/home/r/Desktop/web/judyates">
        Options Indexes FollowSymLinks
        Options +ExecCGI
        AddHandler cgi-script cgi pl py
        AllowOverride Options
        Order allow,deny
        Allow from all

    </Directory>

    </VirtualHost>

This method works very well, because you can set yoursite.localhost subdomain to return to your home IP address.

With this setting, when I work on judyates.com on my computer and want to test anythig, I just go to judyates.localhost in my web browser.

5 , *.conf , , , .

.

, , : http://digitalpbk.blogspot.com/2007/01/making-subdomains-on-localhost.html

, . , , apache, . , judyates.com , , , , .

+2

src= "css/main.css"? ? , css, -, , .

EDIT: , , , URL-. "/css/main.css" . , "main.css" "css" -. , css -. , css , ... css /clientname/css/main.css.

, , , URL-. html , css, "css/main.css". , css, "../css/main.css" - ".." . URL-, , .

, , : http://www.webreference.com/html/tutorial2/3.html. , Google, .

Apache, , URL- ( ), .

+1

Source: https://habr.com/ru/post/1740394/


All Articles