Apache2 Virtual Host fails with Name or service not known - apache

Moving from Ubuntu 17.10 to Mint 18.3 and migrating virtual host config files fails with
[core:error] [pid 3012] (EAI 2)Name or service not known: AH00547: Could not resolve host name
On my fresh installed Mint i have done this first
1) sudo a2dissite 000-default.conf
This is my standard Config File using for Vhosts
<VirtualHost *.domain.localhost:80>
ServerName domain.localhost
ServerAlias www.domain.localhost api.domain.localhost
ServerAdmin webmaster#localhost
DocumentRoot /home/dev/projects/domain/web/html/
<Directory /home/dev/projects/domain/web/html/>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature Off
</VirtualHost>
BTW: This steps i'm doing for every project
1) sudo chown -R www-data:www-data PATH_TO_DIR
2) sudo chmod 660 -R PATH_TO_DIR
3) sudo chmod -R -x+X PATH_TO_DIR
4) sudo find PATH_TO_DIR -type d -exec chmod g+s {} \;
5) sudo setfacl -R -d -m u::rwX,g::rwX,o::- PATH_TO_DIR
UPDATE:
adding domains to /etc/hosts, reloading server leads again to the default

I have solved it by modifying "000-default.conf" DocumentRoot Path, then modifying "/etc/apache2/apache2.conf" by adding these lines
<Directory /home/mdev/_projects/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Also this had to be changed from
<VirtualHost *.domain.localhost:80>
to
<VirtualHost *:80>
No entries at /etc/hosts neccassary!

Related

Cann't Find <Directory /var/www> in “000-default” File

I'm working to deploy Laravel 5.3 project to Ubuntu 16.04 Server.
The tutorial I'm following says that there should be
DocumentRoot /var/www
<Directory /var/www>
in the "/etc/apache2/sites-enabled/000-default" file and I should edit them to be :
DocumentRoot /var/www/project/public
<Directory /var/www/project/public>
I found :
DocumentRoot /var/www
but didn't find :
<Directory /var/www>
I tried to put it and put this inside the directory tag
RewriteEngine On
RewriteBase /var/www/project/public
but it results in errors while restarting apache.
What should I do ??
You need to copy you default-000.conf don't overwrited, and no from sites-enabled but from sites-available
sudo a2enmod rewrite //active mode rewriting
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysitename.com.conf
sudo nano /etc/apache2/sites-available/mysitename.com.conf
Paste the vhost :
<Directory /var/www/project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
After this save and do a :
sudo a2ensite mysitename.com.conf
sudo a2dissite 000-default.conf
Add an htaccess to you root folder :
sudo nano /var/www/project/public/.htaccess
sudo chmod 644 /var/www/project/public/.htaccess
sudo chown www-data:www-data -R /var/www //to be sure you have rights
sudo service apache2 reload //to take the new configuration
sudo service apache2 restart //apply ...
Paste you directive rewriting
RewriteEngine On
RewriteBase /var/www/project/public

You don't have permission to access / on this server

I'm on linux mint and I want to configure a virtual host for my symfony 3 application.
this is my Vhost on /etc/apache2/sites-available/evaluation.conf :
<VirtualHost *:80>
ServerName evaluation.dev
ServerAlias www.evaluation.dev
DocumentRoot /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
<Directory /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web>
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
I've added the host in /etc/hosts like that :
127.0.0.1 evaluation.dev
That's not wrking for me and it return this error :
Forbidden
You don't have permission to access / on this server.
Apache/2.4.18 (Ubuntu) Server at evaluation.dev Port 8
Maybe you need to grand files access rights
chown -R www-data:www-data /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
chmod -R 755 /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
and
move the VirtualHost file from /etc/apache2/sites-available/evaluation.conf to /etc/apache2/sites-enabled/evaluation.conf

Apache 2.4 Httpd 403 Forbidden in Vagrant of Centos 7

After vagrant up with Centos7 and httpd (Apache 2.4) is installed, I test the testa.dev.conf in /etc/httpd/conf.d as
<VirtualHost *:80>
ServerName html.testa.dev
DocumentRoot "/var/www/html/testa.dev/htdocs"
<Directory "/var/www/html/testa.dev/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
and it can be accessed as http://html.test.dev while
the domain name is added to /etc/hosts in host
NO change in the default setting /etc/httpd/conf/httpd.conf
a test page /var/www/html/testa.dev/htdocs/index.html is created
However, when I'm trying to test other directories, it comes to 403 Forbidden. What I have done is
to create testb.dev.conf in /etc/httpd/conf.d as
<VirtualHost *:80>
ServerName html.testb.dev
DocumentRoot "/srv/www/testb.dev/htdocs"
<Directory "/srv/www/testb.dev/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
to create a test page /srv/www/testb.dev/htdocs/index.html
to grant permissions by
chown -R apache:apache /srv/www/testb.dev/htdocs
chmod -R 755 /srv/www/testb.dev/htdocs
My idea is straight forward. Just want to change /var/www to /srv/www. But it seems there still some configuration around I missed.

incorrect redmine installation

I am trying to install redmine 3.2.0 like in the following article.
The point 2.4 Test Redmine works fine, i.e. I am able to open redmine using http://MY_IP:3000.
After this, I did:
sudo chown -R www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo ln -s /opt/redmine/redmine-3.2.2/public/ /var/www/html/redmine
Added Listen 89 into /etc/apache2/ports.conf.
Created the following sudo vim /etc/apache2/sites-available/redmine.conf:
<VirtualHost MY_IP:89>
ServerAdmin email#example
DocumentRoot /var/www/html/
<Location /redmine>
RailsEnv production
RackBaseURI /redmine
Options -MultiViews
</Location>
</VirtualHost>
Enabled redmine.conf: sudo a2ensite redmine.conf.
Added PassengerUser www-data into /etc/apache2/mods-available/passenger.conf. Now passenger.conf contains the following:
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
PassengerUser www-data
</IfModule>
And restarted apache: sudo service apache2 restart.
So /var/www/html/ contains:
drwxr-xr-x 2 root root 4096 Jan 25 09:32 .
drwxr-x--x 7 root root 4096 Jan 22 07:21 ..
-rw-r--r-- 1 root root 11104 Jan 22 02:57 index.html
lrwxrwxrwx 1 root root 34 Jan 25 09:32 redmine -> /opt/redmine/redmine-3.2.0/public/
Now if I am going to http://MY_IP:89 then /var/www/html/index.html is opened instead of redmine home page.
Could you please advise where I did an error?
Thanks in advance!
UPDATE:
If I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
Redmine won't start, only shows index of (/var/www/html/redmine/).
I SOLVED THE ISSUE:
I did gem install passenger. And I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
From passenger 5.2.0 which was released in January 2018 "PassengerResolveSymlinksInDocumentRoot on" is no longer supported
in your /etc/apache2/sites-available/xxx.conf
make the following changes:
# Not supported from passenger 5.2.0 on wards
# PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /opt/redmine/redmine-3.2.0/public/
My redmine works on apache with this config.
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
<VirtualHost redmine.domain:80>
ServerName redmine.domain
ServerAlias redmine
DocumentRoot /opt/redmine/redmine-3.2.0/public/
<Directory /opt/redmine/redmine-3.2.0/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
allow from all
</Directory>

Fedora httpd.conf virtualhost

I trying to move localhost to home folder, but I get an error 403. Here end of httpd.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/valera5505/sites/localhost
ServerName localhost
<Directory /home/valera5505/sites/localhost>
AllowOverride All
Order allow,deny
Require all granted
</Directory>
</VirtualHost>
Try this (I'm not an Apache pro) :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/valera5505/sites/localhost
ServerName localhost
<Directory /home/valera5505/sites/localhost>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
And try (I'm still not a professional Linux user ):
chmod 755 /home/valera5505
chmod 755 /home/valera5505/sites
chmod 755 /home/valera5505/localhost
Have you assigned correct privileges ?
chown apache:apache -R /home/valera5505/sites
chmod 775 -R /home/valera5505/sites
using -R param is better
also join your user at the apache group
hope you help