'httpd-vhost.conf' breaks Wamp? - apache

This is my first post...
I am attempting to host a development website from my laptop using Wamp; my goal is to install Wordpress and have users log in from there homes...
I've successfully installed Wamp 2.2.
I've included 27.0.0.1 localhost in my 'host' file.
I've removed the # from the front of Include conf/extra/httpd-vhosts.conf.
localhost works perfectly until I edit my 'httpd-vhost.conf' file to include the following...
<VirtualHost *:80>
SeverAdmin webmaster#localhost
ServerName localhost
DocumentRoot C:/Program Files/WampServer2/www
ErrorLog "C:/Program Files/WampServer2/www/logs/error.log"
CustomLog "C:/Program Files/WampServer2/www/logs/access.log" common
</VirtualHost>
Once I restart Wamp the icon stays orange. If I attempt to put Wamp online, an alert titled 'Aestan Tray Menu' stating "Could not execute menu item (internal error). [Exception] Could not preform service action: the service has not been started".
Port 80 tested as "not actually used".
When I run 'httpd.exe' a command window opens then immediately closes before I can read it. I've tried various formats to <VirtualHost *:80> with no avail, however once I comment out my changes I am able to successfully restart Wamp and access localhost.
I haven't been able to find post about this problem anywhere! Thanks!

I am not sure this is so complex. I know the original post is very old but just for those with a similar issue since I had it this morning.
To see the error, you run httpd.exe from within the command prompt. Just open a command prompt and then cd into the folder that contains httpd.exe, then type httpd.exe (i.e. don't just double click it from within the folder).
The result should tell you where the error lies. In my case, it was a syntax error inside the vhosts file.

I suspect your problem is the unquoted DocumentRoot with a space in it. Try:
<VirtualHost *:80>
SeverAdmin webmaster#localhost
ServerName localhost
DocumentRoot "C:/Program Files/WampServer2/www" # <- quotes added around this line
ErrorLog "C:/Program Files/WampServer2/www/logs/error.log"
CustomLog "C:/Program Files/WampServer2/www/logs/access.log" common
</VirtualHost>

Related

VHost is showing only "it works" instead of project pages

I've developed virtual hosts in my mac but instead of showing the project its showing "it works".
I have a java application, this is my httpd-vhosts.conf:
<VirtualHost *:8080>
DocumentRoot "/Users/lalarukh/data/code/prestige-apis"
ServerName labraize.in
<Directory "/Users/lalarukh/data/code/prestige-apis">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
etc/hosts file:
127.0.0.1 labraize.in
Uncommented the required lines also in httpd.conf file.
For testing purpose I made a directory in my server folder named test. And made index.html file inside. And called it in hosts as http://test.com But it also returned "It works".
Means that apache vhosts can't get inside the code directory that's why its not working.
vhosts showing 'it works' instead of project pages.
The vhost is listening on port 8080 and not the default 80 so if you want to reach the correct vhost, you need to add :8080 at the end of the URL so in theory: http://labraize.in:8080 should work.

Localhost redirect to different project folder

I am working in a prestashop project.
Operating System: Linux Mint 19.1
CMS: prestashop
The problem came today, when I cloned my production site to my local machine.
It was not the first time I cloned this project. Actually, I have in:
/var/www/html
different directories:
pre_prestashop pre_magento etc
Now as I said, I copied from production real live website, to local machine in a new directory within /var/www/html
I called it:
dev_prestashop
Everything was perfect, and I can see when I type localhost in my browser every project/directory:
pre_prestashop
pres_magento and
=> dev_prestashop
The fact is, when I try to access locahost/dev_prestashop it makes a redirect to my old directory localhost/pre_prestashop (pre_prestashop works and local site is OK, but it is my OLD local site and not dev_prestashop).
I've been googling but none is experiencing this issue.
I check my /etc/apache2/sites-available and see:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ServerName localhost
ServerAlias pre_calleja
ServerAlias dev_prestashop
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I verified every single filed in database, and deleted .htaccess file from root directory in dev_prestashop...
I can't understand what is happening.
Actually, If I comment pre_prestashop to _pre_prestashop and change dev_prestashop to pre_prestashop, everything works perfectly, so problems is not in dev_prestashop.
I would apreciate very much help to understand this problem, more than solve it because now I am working in renamed folder.
Thanks.

Request to apache2 server always redirects to /var/www (Index of /) site

I am currently trying to setup an virtual hosts following this tutorial on DigitalOcean.
The dummy-site I am trying to serve is under /var/www/example/html/index.html. I have not registered an official domain but setup /etc/hosts/ to resolve example.com to the IP address of my server.
I created another conf file called example.conf under /etc/apache2/sites-available and enabled it with sudo a2ensite example.conf and disabled the 000-default.conf.
Now whenever I go to example.com in my browser I get served:
.
This is the same page I would get when directly going to the IP address of my server. Only when I got directly to example.com/example/html I get served the correct index.html.
My current config looks like this:
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And my /etc/hosts file on my laptop like this:
#<ip-address> <hostname.domain.org> <hostname>
<server-ip> example.com
There are some other folders inside /var/www/ as the company I rented the server from had some maintenance sites preinstalled, but that shouldn't matter in this situation. (See edit, this did actually matter).
It feels like I am missing something obvious here, but I can't find a solution for my problem.
Edit:
The obvious thing I was missing, was that 2 additional sites where enabled by default as well.
One had the following contents:
# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.
<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
ServerName <predefined Server name>
</VirtualHost>
After disabling all the other sites, the request to example.com actually went to the right index.html.
I figure, that the above enabled site actually matched the request coming from my browser and showed the www root directory.
The obvious thing I was missing, was that 2 additional sites where enabled by default as well.
One had the following contents:
# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.
<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
ServerName <predefined Server name>
</VirtualHost>
After disabling all the other sites, the request to example.com actually went to the right index.html.
I figure, that the above enabled site actually matched the request coming from my browser and showed the www root directory.

Apache: 3 virtual hosts working perfectly, 1 is not, but settings seem to be the same (Mac)

(OSX Leopard 10.5.8)
I've been using virtual hosts with no problems until now, when I tried to make a new block of code for the next one. The offender is called project1.
I've got an index.php sitting in the project1/html/ folder, just like all the others. But every time I try to go to http://project1/ in the browser I get a 404.
Here's the contents of httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Users/sebu/_SERVER/"
</VirtualHost>
<VirtualHost *:80>
ServerName skeleton
DocumentRoot "/Users/sebu/_SERVER/skeleton/public_html/"
</VirtualHost>
<VirtualHost *:80>
ServerName pickle
DocumentRoot "/Users/sebu/_SERVER/pickle/"
</VirtualHost>
<VirtualHost *:80>
ServerName project1
DocumentRoot "/Users/sebu/_SERVER/project1/html/"
</VirtualHost>
Here's what I've checked already:
I restarted Apache (every time I change something).
I tried clearing the browser cache.
I tried rebooting.
I made sure the file permissions are exactly the same as the other working vhosts (dirs and files).
I've got the line Options Indexes +FollowSymLinks -MultiViews in httpd.conf (turning Multiviews off was the solution to an earlier problem).
I ran httpd -S to check the syntax and it said everything was OK.
I tried pinging project1 just to check and sure enough it says cannot resolve project1: Unknown host
(Not sure if it's worth mentioning, but when I did a ls -la in _SERVER/ I noticed that project1/ had permissions written as drwxr-xr-x# with the # on the end. I read that this meant it was a quarantined file and would wait for me to open it so I ran open project1/ and it went away.)
do you have an entry in /etc/hosts for skeleton, pickle, but not project1? If so, add an entry for project1 and that should resolve your issue.

Error starting apache from terminal after removing MAMP

I removed MAMP recently.
When I try to start apache from Terminal using:
sudo apachectl -k restart
I am getting the message
Warning: DocumentRoot [usr/docs/dummy-host.example.com] does not exist.
First, make sure you're actually trying to execute the proper version of apachectl by issuing the following command:
which apachectl
(You don't want to see any MAMP references there).
Next, find your virtual hosts config (which is likely here if your MAMP references are gone)
/etc/apache2/extra/httpd-vhosts.conf
Make sure your virtual host definitions are good. (Sounds like you're referencing a bad one).
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/Users/yourusername/Sites/mysite"
ServerName mysite.local
ErrorLog "/private/var/log/apache2/mysite-error_log"
CustomLog "/private/var/log/apache2/mysite-access_log" common
</VirtualHost>
(If you're using a custom server name other than 'localhost' like I've defined above, just be sure your /etc/hosts file is up to date with that entry like this:
127.0.0.1 mysite.local
Don't forget to restart apache!
sudo apachectl restart
You probably need to go to apache config file (something like etc/apache2/apache2.conf) and set it an existing document root directory. That is usually done with DocumentRoot directive in this file, or one of the included virtual host config definitions.
Make sure you comment out all the lines inside the /etc/apache2/extra/httpd-vhosts.conf file otherwise you will get the errors.