Using a symlink as the document root in MAMP hosts - apache

I'm using MAMP PRO v3.0.7.2
I want to specify a symlink as the document root for a specific entry in MAMP Pro's host section which points to the latest build of my project, which can change many times a day during development. The problem is when I select this symlink as my document root, MAMP rewrites the path to match whichever directory to symlink is pointing to.
The build script for my project updates that symlink to point to the latest release directory on every rebuild, but MAMP still has that previous release as the document root.
So for example I want the document root to be:
/Users/username/Sites/projectname/live
which is a symlink that currently points to a directory:
/Users/username/Sites/projectname/releases/2014-10-24-17_25_52
MAMP does not respect the symlink path, but instead rewrites it to
/Users/username/Sites/projectname/releases/2014-10-24-17_25_52
So when I rebuild my project later, MAMP is still pointing the document root to the path above, but /live is now pointing to
/Users/username/Sites/projectname/releases/2014-10-24-18_17_48
In the past I have configured Apache manually and it was fine with using the symlink as the document root, and whenever I rebuilt the project the most current build resolved at the URL defined in vhosts without having to edit anything or restart Apache.
I tried manually editing the respective VirtualHost entry MAMP's httpd.conf file in Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf, but whenever the server is restarted it overwrites my changes and rewrites all instances of the path back to whatever directory the /live symlink is currently pointing to.
Is there a way around this so that I can specify a symlink as the document root, and have it always point to that symlink rather than the actual directory that is currently being symlinked to? Otherwise I have to manually change it and restart servers many extra times a day, which gets old pretty fast.

Related

Where is the right place to configure my Apache vhosts in OSX?

I updated my laptop from Mojave to Catalina last night, and this morning I realised that I had lost all my Apache vhosts, my vhost file was replaced with the default file.
I had all my vhosts in /usr/local/etc/httpd/extra/httpd-vhosts.conf
I would like to know which is the right way to do this (store my vhosts), so I (hopefully) won't lost my vhosts in a future update.
Thanks!!
P.D. I'm using "native" Apache, not Homebrew.
Catalina moved the root directory files as part of the upgrade. See https://apple.stackexchange.com/questions/371852/where-does-the-upgrade-to-macos-catalina-move-root-directory-files
From the answer: This took me a long time to figure out, but any file that was formerly at, e.g., /my-cool-directory was moved to /Users/Shared/Relocated Items/Security/my-cool-directory.
You might try checking in your /Users/Shared/Relocated Items/Security folder for your original Apache files.
It depends on what you do include in your httpd.conf file.
You can try use a custom created vhosts file eg. Include /private/etc/apache2/extra/mycustom-httpd-vhosts.conf next time.
After the last catalina update my custom files where not moved out of their places.
I had the same issue with updating to catalina. All my changes were gone.
By default the httpd.conf includes config files in the other directory:
Include /private/etc/apache2/other/*.conf
I place my vhosts and userdir configs in this directory now. It looks like it works just fine. Another custom file I had in there was not touched by the update.

symlink on bash on windows : apache tries to open a .htaccess that doesn't exist

i try to work on a php project that uses symlinks (it was developped on linux).
i'm on windows, i use bash on windows aka bash on ubuntu on windows aka windows subsystem for linux as a development server.
when apache tries to reach a file within the symlinks it fails.
e.g. when i try to open /var/www/website/symlink/index.html it returns a 403 :
[core:error] [pid 742] AH00554: Access to file /var/www/website/symlink/.htaccess denied by server: not a regular file
i don't know why but it seems apache tries to open a .htaccess file that does not exist, and of course fails at it.
(the symlink points out of the scope of the virtualhost root)
everything is 777.
i can successfully access /var/www/website/symlink/index.html from the command line.
i can successfully access the index.html file when i remove the symlink and copy its target directory instead.
i've tried to delete symlinks and recreate them, it doesn't change anything.
i've tried to create /var/www/website/symlink/.htaccess but it doesn't change anything.
does it sound like a bug or a bad apache configuration or something else ?
this issue was related to this bug : https://github.com/Microsoft/BashOnWindows/issues/650
i got everything to work by removing symlinks and recreate them without trailing slash.
it seems that in a symlink with a trailing slash every directories and every files exist (just try to cd dsfkjhgfkdshjajklhdaf e.g.)
this explains that apache was finding a non existent .htaccess file and was desperately trying to read it.
i wonder when this bug will get fixed though...

Project missing in Localhost (WAMP)

I got a copy of my project from work, and put it into the www folder of Wamp, in a different PC. However, when loading localhost, I am not able to see the folder in the list.
I attempted to create a few new folders, and they display correctly in localhost. Even if I rename this folder to something else, it still refuses to show up.
This is what my www directory looks like :
And this is what localhost shows me:
Update :
If I copy the files inside mainProject and paste them into either test1 or test2, that folder disappears from localhost as well.
Update 2:
Deleting/Removing the .htaccess file from mainProject makes the folder visible in localhost, but when I try to access it, it gives me file not found error for obvious reasons! Can add snippets from the .htaccess file if needed!
You should not put anything into the \wamp\www folder, this is where the WAMPServer homepage lives in a file called index.php
So it looks from you first sentence that you have overwritten this file with one of your own projects files.
The simple solution is to install WAMPServer onto another PC and restore the \wamp\www folder from there. Alternatively uninstall WAMPServer, delete the \wamp folder and all subfolders, re-install WampServer and then copy your project into a sub folder of the \wamp\www folder. The wamp homepage is not actually required, but it can make life easier.
Also check the wampserver.com/forum/en there is a document there called 'WAMPServer 2.5 The Homepage, Your Projects Menu and the need for Virtual Hosts ' describing how to setup Virtual Hosts which also provides a more buttet proof environment to run a project in.
ADDITIONAL INFO:
Ok now you have undone the damage you did, you now need to learn how to create a Virtual Hosts for each of the projects you want to run/develop.
You can undo the changes you made to Document Root, Directory and Virtual Host in the httpd.conf file, these can all be individually set from within a Virtual host definition.
See this post on the WampServer forum site

Apache returning 404 for requests inside /javascript directory

I have a project with several sub-directories. Everything works just fine, except if I try to access files inside the /root/javascript directory, I get a 404. The files do in fact exist, and I am in fact typing the path correctly. If I simply rename the directory I can then access the files. Rename it back, and I get the 404 again. VHost file works fine. No .htaccess files involved.
Apache version: 2.4.9
OS: Ubuntu 13.10
After much searching and trying different things, here's what the problem came down to:
By default, Apache 2.4 on Ubuntu enables a config file called javascript-common, which redirects any requests to files inside /javascript (that is, a directory at the root of your project called 'javascript') to /usr/share/javascript.
Solution 1
Use the following command to disable the javascript-common configuration file:
a2disconfig javascript-common
Solution 2
Add your JavaScript files inside that /usr/share/javascript directory. That way Apache will actually find those files and no 404 will be returned. One benefit of doing things this way is that you won't need multiple copies of the same files (jquery.js, etc.js) that multiple projects use...
Solution 3
Delete the directory /usr/share/javascript, and create a symbolic link that points to your project's /javascript directory. Keep in mind that if you have more than one project (vhost file), they will all serve from the same JavaScript file from the original project. In other words, this is probably not the best solution...
The a2disconfig solution didn't work for me, but then through some searching, I realized that the javascript-common is something that can be uninstalled.
So I fixed the problem by removing javascript-common:
sudo apt-get remove javascript-common
I'm not sure the point of this package, or why it would be installed automatically, but I'm glad that my javascript files are loading again!
I am running Ubuntu 14.04.1 LTS with the lamp-server bundle
Encountering the same problem, I found a similar answer resolved it.
sudo a2disconf javascript-common
sudo service apache2 restart
After the a2disconf (and note it is apparently now a2disconf and not a2disconfig)
I did get a message to execute "sudo service apache2 reload"
the reload did not resolve the issue... thus the restart
as an aside -- I cannot imagine what the developers were thinking when they loaded this little gem -- some of my javascript files might be viable across domains... but certainly not all !
You could just override /javascript alias in your .conf to reflect what you want:
Alias /javascript /my_custom_dir

Changing WAMP root folder with special character in path to folder

I am trying to change WAMP directory but in my path there is one word (comupter name) with special character š, so when I change dir and restart wamp it stays yellow... I am sure it is because of that because when I use some other path (without special char) it works just fine.
How can I change WAMP root dir to be that path?
Full path : C:\Users\Dušan\Dropbox
This may be difficult. As you need to make Apache, MySQL, and PHP all work with this special path... On windows.
And I'm honestly unsure if this won't cause major problems.
My advice is to crate a SHORTCUT folder (like ln -sf on linux), and link it to your destination. You can then install there and work directly on your sites.
Apache conf and mysql, etc. would see a normal path name.
God only knows how the UTF-8 path conversion works between linux and windows ports of these products.
Again, I'd try a standard folder C:\wamp, linked to your www or whichever directory via a shortcut.