I am trying to set up a virtual host at localhost. I am installing symfony 1.4 on my ubuntu 12.04 LTS, but I got some problems.
I installed apache2, php5 and mySql. Localhost works so I assume that apache it's ok.
You can found symfony installation and configuration instructions here.
After several days these are my configuration files:
http.conf:
ServerName 127.0.0.1
/etc/apache2/sites-available/test:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/user/test/web"
DirectoryIndex index.php
<Directory "/home/user/test/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/user/test/lib/vendor/symfony/data/web/sf
<Directory "/home/user/test/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
and localhost:8080 doesn't works.
UPDATE:
Ok, after several modifications my httpd.conf is the same:
ServerName 127.0.0.1
And my /etc/apache2/sites-available/test:
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "/home/user/test/web"
DirectoryIndex index.php
<Directory "/home/user/test/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/user/test/lib/vendor/symfony/data/web/sf
<Directory "/home/user/test/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
If Apache use the port 80, remove this line in your conf:
NameVirtualHost 127.0.0.1:8080
Then replace all 8080 by 80 and try http://localhost. It should work.
edit:
Regarding the error could not bind to address 127.0.0.1:80 no listening sockets available, it seems you have an other server listening on the port 80.
Maybe it's a better idea to come back on the 8080 port (on the httpd.conf) and then update the ports.conf to set :
NameVirtualHost *:8080
Listen 8080
If you don't have a ports.conf file, find Listen in your main configuration file and do the update.
Verify you have your site test into /etc/apache2/sites-enabled/. if not do:
sudo a2ensite test
This command will enable the site test. Remember to restart apache.
Error message.
(98)Address already in use: make_sock: could not bind to address 127.0.0.1:80 no listening sockets available, shutting down Unable to open logs
It can be solved by commenting out the line Listen 80 in your httpd.conf file.
Regards
Rajkiran
Related
(I'm kinda new to apache). I want to serve a wiki from my server myserver.com. I've created a DNS record for wiki.myserver.com, which can be reached by ssh/http/ping (so, it exists). I have default 000-default.conf, and the following wiki.myserver.conf:
<VirtualHost *:80>
ServerAdmin me#gmail.com
DocumentRoot "/var/www/html/wiki"
ServerName wiki.myserver.com
<Directory /var/www/html/wiki/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/wiki.myserver.com-error_log
CustomLog /var/log/apache2/wiki.myserver.com-access_log common
</VirtualHost>
Output of apache2ctl -t -D DUMP_VHOSTS:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server wiki.myserver.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost wiki.myserver.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost wiki.myserver.com (/etc/apache2/sites-enabled/wiki.myserver.com.conf:1)
Surfing to http://myserver.com results in default apache2 index page, as expected.
Surfing to http://myserver.com/wiki results in wiki page, as expected (I guess).
Surfing to http://wiki.myserver.com results in default apache2 index page, where I expect the wiki page.
What am I doing wrong? I can't find a difference between my setup and what is generally instructed on the internet.
Can you help by suggesting some ways for debugging?
Any help is appreciated.
Just stupid; I had set my servername in /etc/apache2/conf-available/servername.conf to the wrong default. It's working just fine now.
following this tutorial, I've successfully installed pgAdmin4 in server mode. However, pgAdmin4 is accessible by my IP address on the default port. I would like access using another port like the 8081. I've tried by modifying the content of /etc/apache2/sites-available/pgadmin4.conf but without success. Thanks in advance
<VirtualHost *:8081>
ServerName my_ip
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/user/environments/my_env
WSGIScriptAlias / /home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi
<Directory "/home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
I've found the solution myself.
The steps are:
Configure Apache to Listen on each of the ports you want to service. Add Listen 8081 in the ports.conf file.
sudo nano /etc/apache2/ports.conf
Modify the content of pgadmin4.conf as follow
sudo nano /etc/apache2/sites-available/pgadmin4.conf
Type
<VirtualHost my_ip:8081>
ServerName my_ip:8081
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/user/environments/my_env
WSGIScriptAlias / /home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi
<Directory "/home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
Restart apache
I'm developing a web with cakePHP (using MAMP as localhost) and I just configured a virtual hosts to the root of my project.
My /etc/hosts is
127.0.0.1 localhost
127.0.0.1 altair.loc
And my httpd.conf
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/ALTAIR/altair/"
ServerName altair.loc
</VirtualHost>
With this I can access to my project typing http://altair.loc and all controllers and actions works perfectly (i.e. http://altair.loc/controller/action).
The problem is that all files accessed statically fails. For example http://altair.loc/css/main.css fails, but it works if I type http://altair.loc/ALTAIR/altair/css/main.css, as if the virtual host wasn't configured.
Do you know what could be happening?
Thank you in advance
Solved. In httpd.conf is necessary to check that Override is for all, it was an .htaccess and mod_rewrite issue:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
I'm clearly missing something, probably something obvious, but I'm just not seeing it. I have a self-signed certificate configured on my MBP (running Apache via Macports). It's a wildcard cert for *.local and I've configured a named virtual host for a site I'm working on, but when I attempt to access it via https, PHP's $_SERVER variables indicate that the SSL access isn't been recognized/respected. Even though I'm accessing https://mynamedhost.local, the PORT key reports port 80 and no HTTPS key exists.
This is a CakePHP site, so the lack of an HTTPS key prevents RequestHandler::isSSL() from reporting true. Any insights would be much appreciated.
Here's my httpd settings output:
$ httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server www.example.com (/opt/local/apache2/conf/extra/httpd-ssl.conf:74)
port 443 namevhost www.example.com (/opt/local/apache2/conf/extra/httpd-ssl.conf:74)
port 443 namevhost mynamedhost.local (/Users/rob/Library/Application Support/MacPorts/apache/conf.d/mynamedhost.conf:17)
*:80 is a NameVirtualHost
default server localhost (/Users/rob/Dropbox/Application Support/apache/conf.d.osx/_localhost.conf:1)
port 80 namevhost localhost (/Users/rob/Dropbox/Application Support/apache/conf.d.osx/_localhost.conf:1)
port 80 namevhost mynamedhost.local (/Users/rob/Library/Application Support/MacPorts/apache/conf.d/mynamedhost.conf:1)
Syntax OK
My namedhost virtual host definition looks like this:
<VirtualHost *:80>
ServerName mynamedhost.local
DocumentRoot /var/www/mynamedhost/app/webroot
ErrorLog /var/www/.logs/mynamedhost_error_log
CustomLog /var/www/.logs/mynamedhost_access_log common
<Directory /var/www/mynamedhost/app/webroot>
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName namedhost.local
DocumentRoot /var/www/mynamedhost/app/webroot
ErrorLog /var/www/.logs/mynamedhost_error_log
CustomLog /var/www/.logs/mynamedhost_access_log common
<Directory /var/www/mynamedhost/app/webroot>
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Got it. In the Macports extras/httpd-ssl.conf file, the SSL engine was turned on and the certificate files defined. I thought this would trickle down to custom virtual hosts, but I was wrong. On a lark, I decided to drop the following into the *:443 virtual host definition:
SSLEngine on
SSLCertificateFile "/opt/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/local/apache2/conf/server.key"
Now everything seems to work as expected. I still think I have something funky going on in my config, but this is going to have to be okay for now. For anyone playing at home, the modified virtual host config looks like this (the *:80 config as shown above didn't change):
<VirtualHost *:443>
ServerName mynamedhost.local
DocumentRoot /var/www/mynamedhost/app/webroot
ErrorLog /var/www/.logs/mynamedhost_error_log
CustomLog /var/www/.logs/mynamedhost_access_log common
SSLEngine on
SSLCertificateFile "/opt/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/local/apache2/conf/server.key"
<Directory /var/www/mynamedhost/app/webroot>
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Below is my config file:
NameVirtualHost 12.34.56.78:80
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /srv/www/domain1.com/public_html1/
ErrorLog /srv/www/domain1.com/logs/error.log
CustomLog /srv/www/domain1.com/logs/access.log combined
</VirtualHost>
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#domain2.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /srv/www/domain2.com/public_html1/
ErrorLog /srv/www/domain2.com/logs/error.log
CustomLog /srv/www/domain2.com/logs/access.log combined
</VirtualHost>
The thing is when I put www.domain1.com into browser, apache2 doesn't retrieve the web page resides in /srv/www/domain1.com/public_html1/, instead, it gets the page from the default document root defined in another file. However, if I put www.domain2.com, everything works fine. I don't see any difference between two VirtualHost config block, so I wonder what does make the difference. BTW, I haven't put any .htaccess file under their document root.
Try checking your Apache config by issuing:
/usr/sbin/apache2ctl -S
I guess your "default" virtual host uses "www.domain1.com" as its ServerName, thus it responds to the request to "www.domain1.com".
On my machine this happened due to "www.domain1.com" being my machine's hostname. If ServerName is not specified, Apache tries to guess - causing the abovementioned problem.
I solved this by specifying "ServerName default" in sites-available/default.
This might be of some help as well:
http://httpd.apache.org/docs/current/dns-caveats.html
If you are on Windows and probably using a ZendSever, than you MUST do next:
Open file "hosts" in directory "C:\Windows\System32\drivers\etc"
Add
127.0.0.1 www.domain1.com
under
127.0.0.1 localhost
127.0.0.1 domain1.com
It should look like this:
127.0.0.1 localhost
127.0.0.1 domain1.com
127.0.0.1 www.domain1.com
127.0.0.1 domain2.com
127.0.0.1 www.domain2.com
127.0.0.1 domain3.com
127.0.0.1 www.domain3.com
All domains need to be registered in this file.
Just wanted to say that this caught me out too, and changing the ServerName in the default apache site worked for me, as did simply disabling that site using
a2dissite default
Then reloading apache.