i want to change server name in apache. i know its easy as we can make changes in apache.cnf and httpd.cnf file. But i am tired after make changes in all file. i have checked all files and configuration but its not work only repdirect to another ip worked. So how can i change servername ??
<VirtualHost *:443>
ServerName xyz.com
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key.nopass
</VirtualHost>
Thanks for any help.
This can be achieved by installing Apache mod_security module.
After installation , open the Apache configuration file.
$ sudo vi /etc/apache2/apache2.conf #Debian/Ubuntu
$ vi /etc/httpd/conf/httpd.conf #RHEL/CentOS/Fedora
Now change or add these lines below (make sure to change Tech_Web to any other thing you want to appear to clients).
ServerTokens Full
SecServerSignature “Tech_Web”
Finally restart the web server.
Related
I've installed some software for users to be able to change their ldap password on they own named self service password on this path: /usr/share/self-service-password/htdocs.
In sites-enabled my configuration is as follows: (file named 000-default.conf)
<VirtualHost *:80>
ServerName <IP>
DocumentRoot /usr/share/self-service-password/htdocs
DirectoryIndex index.php
AddDefaultCharset UTF-8
LogLevel warn
ErrorLog /var/log/apache2/ssp_error.log
CustomLog /var/log/apache2/ssp_access.log combined
</VirtualHost>
(same thing is "configured" at sites-available").
I've made sure this .conf file (000-default) is enabled by a2ensite, and made sure everything else is disabled, and restarted apache2.
However, When browsing to my IP:81 , it keeps redirecting me to Apache default welcome page under /var/www/html .
I'm trying to find a solution for it for the past 2 hours and couldn't find the reason behind it.
Thanks for anyone willing to assist.
As per your configuration your VirtualHost is accepting connections on port *:80
<VirtualHost *:80>
But then you are testing on IP:81.
Could you please adjust your test to IP:80
or
Adjust the VirtualHost port to *:81
They must match to work.
im new to amazon web services.
I have installed an ec2 instance with lamp, everything seems to be OK.
I manage the server through ssh,
I've created the
/etc/apache2/sites-available/jak-udelat-cz.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin info#jak-udelat.cz
ServerName www.jak-udelat.cz
ServerAlias jak-udelat.cz
DocumentRoot /var/www/html/jak-udelat.cz
LogLevel warn
ErrorLog /var/log/apache2/jak-udelat.log
CustomLog /var/log/apache2/jak-udelat2.log combined
Then I restarted the apache..
But when I run
sudo a2ensite jak-udelat.cz
, i get
ERROR: Site jak-udelat.cz does not exist!
The domain www.jak-udelat.cz is going on the server right, php works, mysql works, everything seems to be ok, instead of this...
Could you please point me out where I'm making mistake?
Your conf file is named jak-udelat-cz.conf, so you should do:
sudo a2ensite jak-udelat-cz
OK :D so, I changed almost everything like without seeing any change, so I absolutely out of mind tried reboot, then once more restart apache and it finally helped! :)
I have a server with multiple websites hosted and distinguishable using name-based virtual hosting of apache.
How do I set it so that a specific website is hosted when the ip of my server is entered in the address bar?
What you want to use is the _default_ VirtualHost.
<VirtualHost _default_:80>
DocumentRoot /www/default80
# ...
</VirtualHost>
It's described here. Basically if nothing else match the request the _default_ host will be used.
EDIT
This could also be written as:
<VirtualHost *>
DocumentRoot /www/default
# ...
</VirtualHost>
Is is important that this is the first VirtualHost in the configuration since Apache will start matching them from top to bottom, selecting the one that fit the best based on ServerName and ServerAlias.
This post might also be of interest:
Apache default VirtualHost
just find the Include sites-enabled/ line in your apache2.conf file and add the path to the conf file you want to be site default above it. from:
Include sites-enabled/
to
Include sites-enabled/mydefault.conf
Include sites-enabled/
When you first install apache2, there is a site configuration file named 000-default.conf. This is going to be the default because it is very likely to appear first in the list of files under /etc/apache2/sites-enabled.
To have your own file as the default, you can either replace the file under /etc/apache2/sites-available/000-default.conf with your own, or replace the link like so:
sudo rm /etc/apache2/sites-enabled/000-default.conf
sudo ln -s ../sites-available/my-site-setup.conf /etc/apache2/sites-enabled/000-default.conf
Then restart apache2 (or just reload).
The _default_ as mentioned by the other answer is for defining a virtual host which can be found with the default IP address. It's not the default virtual host.
<VirtualHost _default_:80>
...
is equivalent to
<VirtualHost *:80>
...
The * is a globing pattern which matches any IP addresses.
Note:
Replacing the 000-default.conf file is okay, but in most cases the installation package is going to view that as a modified file and manage it in some weird way which is why I think it's cleaner to only change the soft link.
Keep it clean, don't delete or edit anything in /etc/apache2/sites-available/.
Create all new site configurations in /etc/apache2/sites-available/. Copy whatever site configuration you want enabled to /etc/apache2/sites-enabled/. Only make sure /etc/apache2/sites-enabled/ has only one configuration file.
Sample format for new apache site configurations in Ubuntu 20.04 LTS is
<VirtualHost *:80>
ServerName http://localhost
ServerAdmin admin#mysite.com
DocumentRoot /var/www/html/mysiteroot/public
<Directory /var/www/html/mysiteroot>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Notice that 000-default.conf is by default in both directories mentioned above and should only be replaced by your new configuration in /etc/apache2/sites-enabled/ so that it can be restored anytime you need it.
Restart Apache2 service after you make any configuration changes.
How can I set up Apache 2.2 to load the site from htdocs/example/ when I write in the address bar example.local?
Thanks in advance
You have to make sure that example.local resolves to your local machine, easiest way is by adding a line like
127.0.0.1 example.local
to your hosts file (linux: /etc/hosts; win: %SystemRoot%\system32\drivers\etc\hosts).
And than you need a vhost in your apache config, like (this is very basic)
<VirtualHost 127.0.0.1:80>
ServerName example.local
DocumentRoot /path/to/htdocs
ErrorLog /path/to/error.log
CustomLog /path/to/access.log combined
</VirtualHost>
That way you should be able to to access files in htdocs/example/ via http://example.local/example/
For more details please refer to the fine apache manual
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.