Error with DocumentRoot in new Vagrant - apache

I'm attempting to use Jeffrey Way's Vagrant setup (https://github.com/JeffreyWay/Vagrant-Setup) and it almost works for me on a Mac running Yosemite. When Apache restarts at the very end, I get an error stating:
==> default: AH00112: Warning: DocumentRoot [/var/www/html] does not exist
==> default: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Prior to that in his install.sh, he's deleting the html directory and doing a symlink it looks like (I'm new to this, sorry).
To fix it, I ssh into Vagrant, edit /etc/apache2/sites-available/000-default.conf and change the DocumentRoot from /var/www/html to just /var/www and then I'm able to view my site on localhost:8080.
How should I be doing this though so it just works out of the box?

Add the below line after the line sudo ln -fs /vagrant/public /var/www (#38) in install.sh
sed -i "s#DocumentRoot /var/www/html#DocumentRoot /var/www#g" /etc/apache2/sites-available/000-default.conf
Running the updated install script should automatically replace the DocumentRoot from /var/www/html to just /var/www

Related

Apache Virtual Hosts DocumentRoot path

[1] DocumentRoot /var/www/example.com/public_html
[2] DocumentRoot /var/www/example_com/public_html
Which one option is it more preferable? Dotted or underscored?
And once file /etc/apache2/sites-available/example.com.conf is changed, is it needed to re-run also $ sudo a2ensite example.com.conf ? Or change itself is enough? Thanks!
Each option is ok, it's as you want. For my part, on my dedicated server, I'll use example.com syntax.
When you run $ sudo a2ensite example.com.conf for the first time, a symlink is created from /etc/apache2/sites-available/example.com.conf to /etc/apache2/sites-enabled/example.com.conf.
You can change this file at two location, because it's the same file.
If you want to disable your vhost, you should run $ sudo a2dissite example.com.conf

Apache set up mac os yosemite

I am trying to get Apache to run on my yosemite machine, but when i try to access localhost i get http://i.stack.imgur.com/ZzZzB.png.
I ran an apache configtest and got the following
Angus-Mac:mysql root# apachectl configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Angus-Mac.local. Set the 'ServerName' directive globally to suppress this message
Syntax OK
What am i getting wrong? any ideas?
Uncommenting the ServerName and changing it to the domain name solved the issue.
change the group permissions on that folder to _www
sudo chgrp -R _www /Library/WebServer/Documents (all web content is now group _www)
chmod -R go-rwx /Library/WebServer/Documents (nobody other than owner can access web content)
chmod -R g+rx /Library/WebServer/Documents (all web content is now readable/executable/enterable by _www)
then restart apache
It seems your user in httpd.conf is different that the one on the web directory
I found the solution here
Please uncomment the ServerName in line 212 (httpd.conf) and change the domain www.example.com to your domain.
Restart apache

I've wrongly removed /etc/apache2

I'm wondering whether it's possible to install apache2 from scratch, I tried to install it and many times I was informed that a configuration file was removed, and everytime I chose to install the package responsible version. When starting apache service I have this apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName and the localhost url shows Page Web inaccessible.
How can I fix this?
Thanks in advance.
Just add to apache2.conf
Servername localhost
into last line.
(PATH)
sudo nano /etc/apache2/apache2.conf

start apache with 404 with mac

I'm trying to install start apache2 on my own computer but get some problems:
so when I do:
sudo /usr/local/apache2/bin/apachectl start
it gives me:
httpd: Could not reliably determine the server's fully qualified domain name, using xxxs-MacBook-Pro.local for ServerName
httpd (pid 685) already running
and when Im trying to open "http://localhost/" it gives me 404. Is that because the default directory is wrong?
(I also tried to fix the the servername and in my httpd.conf it has #ServerName www.example.com:##Port##
and I changed it to ServerName localhost but doesn't work.)

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.