PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 14, 2022

[FIXED] setting up subdomain in LAMP with PHP

 January 14, 2022     lamp, php     No comments   

Issue

is there a way to have a LAMP server and create subdomain programatically via PHP?

I don't want to install Plesk or cPanel, I know they have API's which lets me create subdomains. But is there a way to go around them and have a bare server with just LAMP services installed.


Solution

You can look at the mass virtual hosting module provided by Apache:

  • http://httpd.apache.org/docs/2.0/vhosts/mass.html

With your PHP, when you want to create a new domain, simply create a new directory ... and implement parts of this configuration (consult the link above) on how to configure your Apache. This will allow a seperate vhost per host ... as opposed to the alternate answer which still requires more configuration work per unique hostname...

 # get the server name from the Host: header
 UseCanonicalName Off

 # this log format can be split per-virtual-host based on the first field
 LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
 CustomLog logs/access_log vcommon

 # include the server name in the filenames used to satisfy requests
 VirtualDocumentRoot /www/hosts/%0/docs
 VirtualScriptAlias /www/hosts/%0/cgi-bin


Answered By - sdolgy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing