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

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.

Related

How can i reset the httpd.conf file

Does anyone know how I can find the httpd.conf file because I may have accidentally changed some things inside and i can't Ctrl+z because I opened it in notepad file instead of notepad++. i would reinstall the whole wampserver but I have tons of data and files to take the risk. I just need the original file of httpd.conf of Apache 2.4.9. I couldn't find it online.
Use a program such as 7-zip to extract all the files from the wamp installer. Go find the httpd.conf file and copy it over. Also you could just install it temporarily on another windows computer to retrieve the file.
It's good practice to always make a backup of conf files before modifying them, they are specific to your release of apache and the environment it's meant to be used in.

Add MAMP Pro Vhosts with script

I am trying to add add Virtual Host to MAMP Pro with a script that I am writing. Much of the documentation out there covers adding vhosts with MAMP (free, not Pro). What I am trying to do is add the vhost, restart MAMP Pro, and move on to the next part of my script.
I've tried editing httpd.conf at ~/Library/Application Support/appsolute/MAMP PRO/httpd.conf, but when MAMP Pro restarts it is overwritten each time despite the comments on ~line 915, which say to add Include files to add functionality.
The closest someone has gotten to getting an answer is here where the answerer suggests editing the plist files that MAMP Pro uses to generate the new config file each time.
Edit template: MAMP -> File -> Edit Template -> Apache -> httpd.conf and add line at the bottom of the file (change path iy you need, and create your custom conf file):
Include /Applications/MAMP/conf/apache/extra/myVhosts.conf
Then add what you want in this file...

Using a symlink as the document root in MAMP hosts

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.

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