{"id":1265,"date":"2017-03-21T19:56:03","date_gmt":"2017-03-21T14:26:03","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1265"},"modified":"2017-03-21T19:56:03","modified_gmt":"2017-03-21T14:26:03","slug":"setup-serveralias-ngnix-webserveralias-domain-name","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/setup-serveralias-ngnix-webserveralias-domain-name\/","title":{"rendered":"Setup ServerAlias on Ngnix Webserver(Alias domain name )"},"content":{"rendered":"<p><strong>Date Posted:21-03-2017<\/strong><\/p>\n<p>Normally, we requires multiple domain names or wildcard domain name (*) or\u00a0 www\u00a0 points to same directory. In apache, we use <span style=\"color: #ff0000;\"><em>ServerAlias <\/em><\/span>to achieve the same. In this post, we will explain on how to add Serveralias on Nginx webserver.<\/p>\n<p>If nginx is not installed, please follow the below post to install nginx webserver.<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-mariadb-ubuntu-16-04-1\/\">Ubuntu 16.04<\/a><\/li>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-fpm-mariadb-on-centos-7\/\">Centos 7<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Implementation:<\/h4>\n<p>We assumes that we would like to add <em>www<\/em> as a Server Alias on nginx. So, whatever request whether its www or nonwww, the request will go to same document root.<\/p>\n<p>Open the domain configuration. If you followed above articles then there will be only one domain configuration ie., <em>default <\/em><\/p>\n<p><code>vi \/etc\/nginx\/sites-available\/default<\/code><\/p>\n<p>Changes the line from,<\/p>\n<blockquote><p>server_name _;<\/p><\/blockquote>\n<p>to,<\/p>\n<blockquote><p>server_name <span style=\"color: #ff0000;\">domain.tld www.domain.tld;<\/span><\/p><\/blockquote>\n<p>Give a space and you can add many number of domains. If the nginx domain configuration is different, we need to update corresponding domain configuration.<\/p>\n<p>Check the nginx configuration syntax errors<\/p>\n<p><code>nginx -t<\/code><\/p>\n<p>Restart nginx configuration to make changes comes into effect.<\/p>\n<p><code>service nginx reload<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date Posted:21-03-2017 Normally, we requires multiple domain names or wildcard domain name (*) or\u00a0 www\u00a0 points to same directory. In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[302,261,271],"class_list":["post-1265","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-alias","tag-linux","tag-nginx","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-kp","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1265"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1265\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}