How can I change path as root dir (PHP / Apache )?

Viewed 22

Nowadays I use path to file (in DB) like this

"/files/person_1/awatar.png" - it works , file_get_content ("/files/person_1/awatar.png") = true - is ok!

But now I changed my web server and ... In PHP I can see "directory not found exception"

Path on server: /var/www/public_html/new_service_xxxxx/files/awatar.png In PHP I have "/" as first character, I don't want to change it.

What I should change ?

<VirtualHost *:80>
    ServerName test.new_service_xxxxx.pl
    ServerAlias www.new_service_xxxxx.pl
    DocumentRoot /var/www/public_html/new_service_xxxxx


    <Directory /var/www/public_html/new_service_xxxxxk>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

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

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm index.php5
    </IfModule>

</VirtualHost>
1 Answers

Go to the following locations and change the root folder, into a local folder in your Desktop.

   a) /etc/apache2/sites-available/000-default.conf
         Change "DocumentRoot /var/www/html"

   b) /etc/apache2/apache2.conf
         Find "<Directory /var/www/html/>
                 Options Indexes FollowSymLinks
                 AllowOverride None
                 Require all granted
               </Directory>"
         And change "/var/www/html"

I hope it helps.

Related