How to add a domain alias without www in plesk 12 - plesk

Let's say I have www.mydomain.com set up in Plesk 12. How can I create an alias like mydomain.mycompany.com for that domain? Currently Plesk adds automatically the www prefix.
Thanks!

What you really want to do is add a SUB DOMAIN not a domain alias. Here is a help article https://www.conetix.com.au/support/article/how-add-sub-domain-plesk-12 .

Think your domain has www redirect, if you disable it on domain, alias should not have www prefix too.
Please check this answer about auto www prefix: https://stackoverflow.com/questions/23546923/website-getting-redirected-to-drop-www-from-url/23547600#23547600

Had somewhat the same problem.
I wanted domain.com to redirect, but only www.domain.com did.
In the Domain Alias page, uncheck "Synchronize DNS zone with the primary domain".
Then there will be DNS records for the domain alias itself. For me this did the trick, because there was an A-record without www and an CNAME with www and both with and without www will work.
Maybe you can add a record to mydomain.mycompany.com there too.

I had the same problem, added a DNS A-Record *.domain.ltd
Then added a Domain Alias and unchecked "Synchronize DNS zone with the primary domain", checked "Webservice" and "301 Redirect" in Plesk, that worked for me.

The unwanted "www" server alias is hardcoded in the virtual host config template. Modification is easy though. You have to create a custom virtual host config template with only one line removed.
Infos in the manual: https://docs.plesk.com/en-US/obsidian/advanced-administration-guide-linux/virtual-hosts-configuration/changing-virtual-hosts-settings-using-configuration-templates.68693/
These are the steps to remove the "www" server alias for Apache Webserver:
Step 1: Create a folder for custom domain templates
sudo mkdir -p /usr/local/psa/admin/conf/templates/custom/domain
Step 2: Add a copy of the default template to the custom template folder
sudo cp /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php
Step 3: Comment out the "www" server alias
sudo sed -i 's/ ServerAlias "www\.<?php echo \$alias->asciiName ?>"/# ServerAlias "www.<?php echo $alias->asciiName ?>"/' /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php
Step 4: Reconfigure webserver configurations
sudo /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

Related

How does one change nagios default url to custom url?

I am running Nagios Core 4.0.8 in my environment and I am looking to find a way to change the default url from https://example.com/nagios to https://example.com. Is there a way one can do that?
You will need to edit the cgi.cfg file for Nagios.
vim /usr/local/nagios/etc/cgi.cfg
Change url_html_path=/nagios to url_html_path=/
Edit nagios.conf:
Change ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" to
ScriptAlias /cgi-bin "/usr/local/nagios/sbin"
Comment out the line Alias /nagios "/usr/local/nagios/share" and then add below
DocumentRoot /usr/local/nagios/share
Add the following at top of the configuration:
<VirtualHost *:80>
ServerName status.example.com
and add </VirtualHost> at the bottom.
Edit your /usr/local/nagios/share/config.inc.php file:
Change $cfg['cgi_base_url']='/nagios/cgi-bin'; to $cfg['cgi_base_url']='/cgi-bin';
Restart Apache and Nagios
If you are using Apache to serve your Nagios page you can do different things. Apache configuration files are usually located in /etc/apache2/.
Probably your DocumentRoot is set to /var/www, so you can create a file named "index.html" and place this code inside it to redirect to /nagios URL:
<META HTTP-EQUIV="Refresh" Content="0; URL=/nagios">
You can also edit your nagios apache config (probably /etc/nagios/apache2.conf...) or apache config /etc/apache2/*.conf and add:
RedirectMatch ^/$ /nagios
If you don't like these methods there are more, just think of it as using Apache to redirect, not like a Nagios thing.

Can't access files in a subdirectory using Apache server

I have an Apache 2.2.21 server installed on my Windows 7 machine.
My site is up and my scripts from /scripts subdirectory are working but when I try to load icons from /icons I get a 403 forbidden error.
I've already added this to my httpd.conf file:
<Directory "c:/wamp/www/icons/">
Options Indexes FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Still no effect. So the question is: how can I access files in my /icons subfolder?
P.S.: Using /images subdirectory worked out just fine but the question still remains.
I figured out that /icons/ was included as an alias for some other directory. For me, configuration file was located at:
C:\wamp\bin\apache\apache2.2.21\conf\extra\httpd-autoindex.conf
I had to comment out this line:
Alias /icons/ "c:/Apache22/icons/"
Have you checked the Windows permissions on the /icons directory, and made sure that the Apache user can read that directory? Is there possibly an .htaccess file in the picture?
Edit: Okay, so it's not permissions. My next guess is this: your config above says "everyone is forbidden access except when they're coming from 127.0.0.1". But you're on Windows 7. Windows 7 tries to be helpful and modern - and often tries accessing via IPv6 first. So you might show up as coming from ::1, which is probably failing to match 127.0.0.1. Try turning off IPv6 or adding an Allow from ::1 directive.
Ok so if your httpd.conf doesn't do anyhting you should restart apache. Any changes done to documents have to be restarted so Apache can "Refresh".
<Directory "c:/wamp/www/icons/">
Options Indexes FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
So above this is your code. It basically says in line 4 that Apache should deny connection from all incoming connections connections to the /icons/folder.
Also on line 5 it says to allow incoming connections from only 127.0.0.1 or localhost. So basically the server has access to it!
If changing it doesn't work you should look in .htaccess. Another option is just to copy the Code from a folder that works and paste it and just change the paste from EX:
"C:/WAMP/www/images/" to "C:/WAMP/www/icons".

Redirect example.com to www.example.com VPS & Apache2

I have a VPS and a domain name registered with the provider.
When I enter www.example.com my site is displayed correctly, but entering example.com does not work. I am able to ping www.example.com.
I added the following line to my apache2 default vhosts file:
ServerName example.com
ServerAlias www.example.com
But this did not work.
The VPS is a Debian5 OS.
Any ideas?
Note: There is no option via a provided control panel to add this, it's a basic package I purchased
Thanks
ANSWER
https://serverfault.com/questions/283663/redirect-example-com-to-www-example-com-vps-apache2
Check your DNS first (dig/nslookup)
dig www.example.com
dig example.com
Chances are example.com isn't referring to anything, or a different host, CNAME or ip address.
Add a catch all record if you wish: *.example.com
How to manage DNS depends on your ISP/Hosting provider

How to install cakephp on localhost?

I wanna to know how to install cakephp on localhost?
Please explain me.
I usually make an apache and mysql installation on a linuxbox. I can use windows too, however I do not recommend it ;)
So, I usually make a new entry into the /etc/hosts file to make a sitename available to cakephp.
127.0.0.1 localhost caketest.local
next step to copy all cakephp files into a subdirectory inside /home/myusername/public_html/caketest
app
cake
index.php
plugins
README
vendors
.htaccess
then I set up the site to apache (not neccessary),
<VirtualHost *:80>
DocumentRoot "/home/myusername/public_html/caketest"
ServerName caketest.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/home/myusername/public_html/caketest">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restart apache. you also need to edit the .htaccess files and place a RewriteBase directive with hte path to the actual directory, e.g.
RewriteBase /~myusername/caketest
create a database, set the db connection in cake config files and that's all.
you can point your browser to http://caketest.local
if you do not want a test site url you can skip hosts, and apache vhost creation, but the url to use should be http:/localhost/~myusername/caketest
another important thing is to enable userdir modul in apache, and also check if using php is enabled in userdirs too.
If you're on windows, get WAMP. Install it, then download CakePHP in C:\wamp\www\. Extract CakePHP in that folder so you have a folder kind of like this: C:\wamp\www\cakephp\. Now you can access the installation by going to localhost/cakephp/.
An old article of mine but still quite relevant:
Installing CakePHP
Assuming you have a *AMP setup (Apache+MySQL+PHP), just copy the files to your htdocs folder. On Ubuntu, it's /var/www, so you would create /var/www/myApp and copy the whole Cake structure into there, ending up with something like:
/var/www/myApp/app/
/var/www/myApp/cake/
/var/www/myApp/vendors/
/var/www/myApp/index.php
/var/www/myApp/.htaccess
Then you can access your app by the url: http://localhost/myApp

Multiple Domains on a VPS with Apache

I am planning on getting a VPS soon and have two sites I want to host. I have my local vhosts setup for my development environment using host file to port it correctly.
My question is hopefully simple: When setting up with two separate domains that point to the one VPS server is Apache smart enough, like on the local environment, to automatically filter any requests for domain.com to the correct VHOST like it does locally? I would just like to be sure :)
Thanks!
Example of what I am asking:
Say Domain1.com and Domain2.com are both on my VPS.
When someone requests www.Domain1.com apache sees this and passes it through to the domain1.com vhost file.
When someone requests www.Domain2.com apache sees this and passes it through to the domain2.com vhost file.
Repasting my answer from Hosting two domains using only one VPS? as here it is even more relevant.
As complete beginner, I have been trying to host multiple domains on one Apache VPS. Tutorials had too much information that lead me to confusion.
Below I describe, for complete beginners, how to host multiple domains on one VPS server with Ubuntu and Apache.
IMPORTANT! You need to use root account to execute most operations.
IMPORTANT! If you have been trying to make some changes to apache configuration before, undo them.
Creating VirtualHosts
Create folders for your domains on server.
For example:
/home/apache/domain1
/home/apache/domain2
Put index.html file in each folder with any text.
This is domain1
This is domain2
Go to /etc/apache2/sites-available folder.
Create file domain1.conf
sudo nano domain1.conf
<VirtualHost *:80>
DocumentRoot /home/apache/domain1
ServerName domain1.com
ServerAlias www.domain1.com
</VirtualHost>
Create file domain2.conf
sudo nano domain2.conf
<VirtualHost *:80>
DocumentRoot /home/apache/domain2
ServerName domain2.com
ServerAlias www.domain2.com
</VirtualHost>
You can create subdomains same way.
sudo nano blog.conf
<VirtualHost *:80>
DocumentRoot /home/apache/blog
ServerName blog.domain.com
ServerAlias www.blog.domain.com
</VirtualHost>
Enable created sites
sudo a2ensite domain1.conf
sudo a2ensite domain2.conf
Restart apache
sudo service apache2 reload
Redirecting domain to server
Created VirtualHosts will work only if you redirect your domain name to server IP. Domains are just names that can be translated to IP numbers.
Local computer
To test your configuration on local machine, you need to edit hosts file.
sudo nano /etc/hosts
It should look like this.
127.0.0.1 localhost domain1.com domain2.com
Hosts file tells your computer that domain needs to be redirected to local machine.
IMPORTANT! If you create entry in hosts file for existing domain, for example
127.0.0.1 stackoverflow.com
you will loose access to this website.
Server
In order to redirect domain to you web server, you need to create or modify "A"-type DNS record for given domain to IP address of your server. You can do it by panel control provided by your domain registrar.
If you do not know IP address of your server, log in to that server and type in command line:
ifconfig
The simple answer is 'yes', Apache is that clever. If you are used to using a local vhost file in conjunction with your hosts file to simulate local domains, the exact same technique can be applied on a VPS. The part you are doing with the hosts file is essentially creating a local name server, other than that Apache doesn't know the difference. Simply set the ServerName directive for each named vhost and you should find it working the same as it does locally.

Resources