How to change LAMPP webserver root document? - php

How to change LAMPP webserver root document? The default is localhost/xampp/ in /opt/lampp/htdocs But I have a different folder in the /opt/lampp directory and there I have my main website document which I want to load by default. How can I do this? I tried to edit the httpd.conf file in the /opt/lampp/etc and so far I did this but it doesnt seem to work : I commented out 229 line (DocumentRoot "/opt/lampp/htdocs") and added DocumentRoot "/opt/lampp/folder" and also commented by prepending # 231 line (<Directory "/opt/lampp/htdocs">) and added <Directory "/opt/lampp/folder>". What I did wrong or what else needs to be done?

You have to restart your server after editing the config file.

Related

How to change xampp htdocs directory in Mac OS Big Sur

I have installed Xampp 7.2.34 from https://www.apachefriends.org in Big Sur.
XAMPP htdocs folder is placed in /Applications/XAMPP/xamppfiles directory. Is there anyway that I can change the location of htdocs folder and place all my projects in the new location.
Current Location: /Applications/XAMPP/xamppfiles/htdocs
Desired Location: /Users/user/Desktop/Work/PHP/htdocs
I am following this question in Stackoverflow but it seems quite old and I was not able to accomplish what I required.
Already done:
Created new empty htdocs folder on desired location
Changed User daemon to User user in xamppfiles/etc/httpd.conf
Didn't change Group daemon
Changed DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs" to DocumentRoot "/Users/user/Desktop/Work/PHP/htdocs" in xamppfiles/etc/httpd.conf
Changed <Directory "/Applications/XAMPP/xamppfiles/htdocs"> to <Directory "/Users/user/Desktop/Work/PHP/htdocs"> in xamppfiles/etc/httpd.conf
I also uncommented this line of code Include etc/extra/httpd-vhosts.conf in xamppfiles/etc/httpd.conf
Result:
Access forbidden! error.
What did I miss? Has something changed in these years? TIA.
I have the same issue, but worked with this this solution. You could using Xampp in another version, Xampp 7.4.15 with this configuration
This worked for me using XAMPP 8.2.0 and macOS 12.6.2 Monterrey:
Make a copy of htdocs and put it where you want it. In my case, I made my copy in /Users/me/Dropbox/XAMPP/htdocs
Edit /Applications/XAMPP/xamppfiles/etc/httpd.conf
Change
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs”
to
DocumentRoot "/Users/me/Dropbox/XAMPP/htdocs"
Change
<Directory "/Applications/XAMPP/xamppfiles/htdocs”>
to
<Directory "/Users/me/Dropbox/Programming/XAMPP/htdocs">
Change
User daemon
to
User me (your user name)
Edit /Applications/XAMPP/xamppfiles/phpmyadmin/config.inc.php
After
$cfg['SaveDir'] = '';
add
$cfg['TempDir'] = '/tmp';
Edit /Applications/XAMPP/xamppfiles/properties.ini
Change
apache_htdocs_directory=/Applications/XAMPP/xamppfiles/htdocs
to
apache_htdocs_directory=/Users/me/Dropbox/Programming/XAMPP/htdocs
Save the files and restart the servers.
That was it. Hope helps someone. I looked for this answer for a long time.

Apache + PHPMyAdmin - Redirect directory to subdomain

So im running Apache on Ubuntu 16. I have phpmyadmin accessible via a directory because thats how it does it by default (e.g. to access phpmyadmin, I have to go to www.mydomain.com/phpmyadmin)
I wrote an Apache VHost to make it accessible via a subdomain as shown here in my Vhosts:
http://pastebin.com/raw/tyZGbsSC
This works and now I can access phpmyadmin via a subdomain (phpmyadmin.mydomain.com) but the problem is that it is still accessible through the directory (www.mydomain.com/phpmyadmin)
How to i stop this?
There should be a conf file phpmyadmin.conf in /etc/apache2/conf-enabled which contains the following line
Alias /phpmyadmin /usr/share/phpmyadmin
Just comment out that line by putting a hash
#Alias /phpmyadmin /usr/share/phpmyadmin
and restart apache.
That should do the job.
You probably have the server-wide configuration enabled in /etc/apache2/conf-enabled
user#host:~ $ sudo a2disconf phpmyadmin
should disable it for you, or just remove /etc/apache2/conf-enabled/phpmyadmin.conf

xampp apache web server not starting, exit code 8

My knowledge is very limited with these apache settings. I wanted to have multiple sites that I could work on locally.
Yesterday it worked okay after installation but after shutting down and starting again today, it did not work.
Server won't start and Application log says:
Starting Apache Web Server...
Exit code: 8
Stdout:
apache config test fails, aborting
Stderr:
AH00526: Syntax error on line 237 of /Applications/XAMPP/xamppfiles/etc/httpd.conf:
DocumentRoot must be a directory
It is a folder
httpd.conf
line
237 DocumentRoot "/Users/username/Sites/xampp/site-folder”
238 Directory "/Users/username/Sites/xampp/site-folder">
Any ideas what is wrong and what to do?
Thanks,
Well, It is because of the comma that your text editor changed from " to ” after site-folder”
237 DocumentRoot "/Users/username/Sites/xampp/site-folder”
238 Directory "/Users/username/Sites/xampp/site-folder">
Change to:
237 DocumentRoot "/Users/username/Sites/xampp/site-folder"
238 Directory "/Users/username/Sites/xampp/site-folder">
xampp is Windows, isnt it? lampp is for linux so I guess you want to use a Folder in your Users Home-Directory. (UPDATE: whoops, lampp is the old name, but maybe this answer suits ur needs).
Try
<Directory "C:\Users\username\Sites\xampp\site-folder">
</Directory>
Windows directory seperator is "\" as you can see if you start your "Explorer" and navigate through directories. "C:" is just the default partition where usually windows is installed. If your installation is somewhere else (or if you changed your Users-Directory path to another drive/partition) just change "C:" to wherever your directory is on.
if you are running xampp under windows, you should add the drive letter also eg:
DocumentRoot "C:/Users/username/Sites/xampp/site-folder”
<Directory "C:/Users/username/Sites/xampp/site-folder">
(note that windows uses the \ (backslash) character, but in apache config files you should always use / (slash) instead of \ when you reference directories.)

Apache and vsftp file permission

I have setup apache according to this article
https://help.ubuntu.com/community/ApacheMySQLPHP
and I have created a new site config in /etc/apache2/sites-available/mysite
and changed the document root and directory to :
DocumentRoot /home/gapton/public_html
<Dictory />
..
..
</Directory>
<Directory /home/gapton/public_html/>
...
...
...
...
</Directory>
and I sudo a2dissite default && sudo a2ensite mysite to disable and enable them, restarted apache2 and things are working.
I then setup vsftpd and config the vsftpd.conf file to :
local_enable=YES
write_enable=YES
connect via Notepad++ with the user 'gapton' and I created a file called test.php under home/gapton/public_html. It would not be readable by Apache it seems. I did sudo chmod -R 755 ~/public_html and it would load alright.
However any subsequent files created via vsftpd will not be readable.
Since I have logged in to the only account gapton when connecting via FTP, then any newly created file should be owned by gapton right? What happens when apache tries to access a file/folder location, what credentials does it access it by?
How do I config it so that all files created by gapton can be read by apache? (Also, is it at all advisable?)
Thanks.
I found the problem.
In older version of vsftpd, the umask they apply when writing file was by default 022.
In the current version, such default value has been changed to 077. This mask read 4 write 2 and execute 1 for everyone except the owner.
Changing the umask value in the vsftpd.conf file back to 022 has solved my problem. Hope this help future users of vsftpd facing the same issue.

Changed DocumentRoot in httpd.conf, $_SERVER['DOCUMENT_ROOT'] still the same

So I changed DocumentRoot in my httpd.conf files and $_SERVER['DOCUMENT_ROOT'] still seems to be the same on XAMPP. I've restarted the server and the problem still persists. I've change DocumentRoot before from the original xampp/htdocs folder and it worked fine. Any clues?
Note the DOCUMENT_ROOT for PHP might not be the same as of Apache.
DOCUMENT_ROOT is where the PHP file is located. This could be on Document root or through a different directory.
There's another line in the httpd.conf file that needs changing. In my file it was about 30 lines below the DocumentRoot setting. I found it thanks to the preceding comment line
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/work/htdocs">
I just moved the whole htdocs directory so I also had to change a line in the httpd-xampp.conf file as well.
<Directory "C:/work/htdocs/xampp">

Categories