Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Apache2+PHP]Créer un répertoire de travail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
Napoleon
Apprentice
Apprentice


Joined: 03 Nov 2010
Posts: 283

PostPosted: Thu Dec 19, 2013 3:31 pm    Post subject: [Apache2+PHP]Créer un répertoire de travail Reply with quote

Ave tout le monde,

Le problème que je tente de résoudre est de faire en sorte que php reconnaisse la racine "/" dans les liens absolus comme étant le répertoire de travail dans /var/www/localhost et non pas le "/" de mon système Linux. Je vous explique ce que j’ai fais et ce qui ne fonctionne pas :


J’ai installé Apache ainsi que php. L’installation à mis en place une configuration par défaut telle que le fichier /var/ww/localhost/htdocs soit un répertoire de travail.

Sauf que j’ai voulu créer un autre répertoire de travail dans /var/www/localhost/tan (« tan » étant le nom de mon projet).

Pour cela j’ai créé le fichier /etc/apache2/vhosts.d/tan.include qui n’est rien d’autre qu’un calque de /etc/apache2/vhosts.d/default_vhost.include (où j’ai seulement changé les deux occurences de "htdocs" par "tan").

Ayant fait celà, j’ai ajouté les lignes suivante à /etc/apache2/vhosts.d/00_default_vhost.conf :
Code:

<VirtualHost *:80>
   ServerName tan
   Include /etc/apache2/vhosts.d/tan.include

   <IfModule mpm_peruser_module>
      ServerEnvironment apache apache
   </IfModule>
</VirtualHost>


et ai changé à la ligne 39 "ServerName localhost" par "ServerName lighty".

Enfin, j’ai donné /var/www/localhost/tan au user Fauve (moi même donc) et ai ajouté lighty et tan dan le /etc/hosts.


En théorie, tout devrait bien marcher. En tout cas, dans /var/www/localhost/tan, lorsque j’utilise un lien absolu en html, la racine "/" est bien la racine de mon projet (c’est à dire le dossier file:///var/www/localhost/tan). Par exemple <img src="/favicon.png"> affiche bien file:///var/www/localhost/tan/favicon.png dans l’html interprété.
En revanche… et c’est ça mon problème, lorsque j’utilise un lien absolu dans une commande php, par exemple <?php include('/css/machin.css'"); ?>, le "/" est vue comme la racine de mon système c’est à dire file:/// et non pas file:///var/www/localhost/tan. C’est donc file:///css/machin.css que php tente d’ouvrir et non pas file:///var/www/localhost/tan/css/machin.css comme je m’y attends.

J’ai trafiqué dans tous les sens la config’ d’Apache dans /etc/apache2 sans succès :/ Est-ce que quelq’un aurait une idée pour placer la racine de php à la racine de mon projet ?

Merci o/
_________________
La vérité n’est que le mensonge le plus crédible au monde.
Back to top
View user's profile Send private message
jaypeche
Apprentice
Apprentice


Joined: 13 Jun 2007
Posts: 173
Location: France

PostPosted: Fri Dec 20, 2013 11:05 am    Post subject: Reply with quote

Pour avoir une config similaire je te file mes fichiers vhosts.d/* fonctionnels :

Le vhost d'exemple est situé sous /var/www/stats/htdocs, libre à toi d'adapter vers /var/www/localhosts/tan...

Fichier /etc/apache2/vhosts.d/stats_vhost.include :

Code:
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
ServerAdmin root@localhost

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# If you change this to something that isn't under /var/www then suexec
# will no longer work.
DocumentRoot "/var/www/stats/htdocs"

# This should be changed to whatever you set DocumentRoot to.
<Directory "/var/www/stats/htdocs">
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        Options Indexes FollowSymLinks

        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        AllowOverride All

        # Controls who can get stuff from this server.
        Order allow,deny
        Allow from all
</Directory>

<IfModule alias_module>
        # Redirect: Allows you to tell clients about documents that used to
        # exist in your server's namespace, but do not anymore. The client
        # will make a new request for the document at its new location.
        # Example:
        #   Redirect permanent /foo http://www.example.com/bar

        # Alias: Maps web paths into filesystem paths and is used to
        # access content that does not live under the DocumentRoot.
        # Example:
        #   Alias /webpath /full/filesystem/path
        #
        # If you include a trailing / on /webpath then the server will
        # require it to be present in the URL.  You will also likely
        # need to provide a <Directory> section to allow access to
        # the filesystem path.

        # ScriptAlias: This controls which directories contain server scripts.
        # ScriptAliases are essentially the same as Aliases, except that
        # documents in the target directory are treated as applications and
        # run by the server when requested rather than as documents sent to the
        # client.  The same rules about trailing "/" apply to ScriptAlias
        # directives as to Alias.
        ScriptAlias /cgi-bin/ "/var/www/stats/cgi-bin/"
</IfModule>

# "/var/www/localhost/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory "/var/www/stats/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
</Directory>

# vim: ts=4 filetype=apache

</Directory>


Extrait fichier /etc/apache2/vhosts.d/00_default_vhost.conf :

Code:
<VirtualHost *:80>
        ServerName stats.domain.org
                Include /etc/apache2/vhosts.d/stats_vhost.include

                        <IfModule mpm_peruser_module>
                                        ServerEnvironment apache apache
                        </IfModule>
</VirtualHost>


Extrait fichier /etc/conf.d/apache2 :


Code:
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D LANGUAGE -D PHP5"

_________________
:-) Gentoo Linux Rullez !
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum