PHP Classes
elePHPant
Icontem

PHP Add Apache Virtual Host: Add a virtual host to Apache configuration

Recommend this page to a friend!

  Author Author  
Name: Evaldo Barbosa <contact>
Classes: 3 packages by
Country: Brazil Brazil
Age: 36
All time rank: 136090 in Brazil Brazil
Week rank: 369 Up26 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can be used to add a virtual host to Apache configuration.

It creates a Apache configuration file with the definitions of a virtual host for a given IP address, domain and document root folder.

The class can also create a .htaccess file to set mod_rewrite options, add domain to the /etc/hosts file, download and install Composer.

Details
{startverticalbanner}
# Add Virtualhosts Tool

PHP Script to create Apache virtual hosts (VHost) using the command line.

#### Usage:
> sudo path_to/addhost.php IP DOMAIN PATH_TO_PROJECT_FOLDER [--htaccess] [--composer] [--errorlog]

or

> sudo path_to/addhost.php IP DOMAIN --removehost

or

> sudo path_to/addhost.php IP DOMAIN --checkhost

#### Example:
> sudo path_to/addhost.php 127.0.2.1 dev.localdomain /home/user/project

#### How does this work?

First addhost verifies if the project source folder exists, if not it is created. After that addhost
opens the /etc/hosts file and appends the IP and DOMAIN. Finally the virtual host config file is creates in the apache enabled sites folder.

#### I want to configure something. How I do?

* With --htaccess option automatically creates the .htaccess in your public folder.
* With --composer addhost downloads composer.phar file and creates a project composer.json.
* With --errorlog provides you with a virtualhost's error log file.

#### I need to use proxy, does this works?
Yeah! This package now is preparet to support proxy. You need to edit the conf file and define two constants.

###### EXAMPLE:
PROXY_HOST: Here you should write the IP or proxy host name and port number separated by ':'.
Example: define('PROXY_HOST','192.168.0.15:3128');

PROXY_USER: Here you should write the proxy user and password separated by ':'.
Example: define('PROXY_USER','evaldobarbosa:myproxypassword');

#### Can Addhost remove old VHosts?
Yes! See below for the syntax to remove old hosts.
> sudo path_to/addhost.php 127.0.2.1 dev.localdomain --removehost

#### Finally...

Restart apache.

Article (brazilian portuguese)
---
> PHP-DF.org - http://bit.ly/19zPh3A

> iMasters - http://bit.ly/1aYFFjz

  Classes of Evaldo Barbosa  >  PHP Add Apache Virtual Host  >  Download Download .zip .tar.gz  >  Support forum Support forum (4)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Add Apache Virtual Host
Base name: add-host
Description: Add a virtual host to Apache configuration
Version: 2
PHP version: 5.3
License: GNU Lesser General Public License (LGPL)
All time users: 1217 users
All time rank: 3049
Week users: 0 users
Week rank: 689 Equal
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Unix Use of capabilities specific of POSIX, Unix like operating systems View top rated classes
Group folder image Systems administration System configuration and management View top rated classes
Group folder image Configuration Configuration formats parsing and generation View top rated classes
Group folder image Hosting Web hosting tools and extensions View top rated classes


  Innovation Award  
PHP Programming Innovation award nominee
July 2013
Number 2


Prize: One downloadable e-book of choice by O'Reilly
Apache is a popular Web server that has configuration format which is not very trivial to understand.

This class can help automating several types of tasks to setup virtual hosts handled by Apache.

Manuel Lemos

  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Good (93%) Good (93%) - - - - Not sure (56%) 1584
Month: Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Plain text file addhost.class.php Class Class source
Accessible without login Plain text file addhost.php Appl. Application script
Accessible without login Plain text file conf.php Conf. Configuration script
Accessible without login Plain text file de_de.lang.php Aux. external contribuition
Accessible without login Plain text file en_en.lang.php Aux. Auxiliary script
Accessible without login Plain text file pt_br.lang.php Aux. Auxiliary script
Accessible without login Plain text file README.md Data Auxiliary data

Install with Composer Install with Composer - Download Download all files: add-host.tar.gz add-host.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.