Search

Oct 12, 2015

Config virtualHost proxy in apache WAMP

In config/httpd.conf, recomment httpd-vhotss.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

In hosts file
127.0.0.1       localhost
127.0.0.1 mentor.vn

In config/extra/httpd-vhosts.conf, add codes:
Example: mentor.vn => localhost/mentor


NameVirtualHost *:80
<VirtualHost mentor.vn:80>
    ServerAdmin mentor.vn
    DirectoryIndex index.php
 DocumentRoot "C:\wamp\www\mentor" 
    ServerName mentor.vn
    ErrorLog "logs/mentor.com-error.log"
    CustomLog "logs/mentor.com-access.log" common 
  <Directory "C:\wamp\www\mentor">
    Options Indexes FollowSymlinks 
    AllowOverride all
    Order Allow,Deny
    Allow from all
 </Directory>
</VirtualHost>


CONFIG - UBUNTU

/etc/apache2/sites-available/000-default.config

<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/html
 ServerName 127.0.1.1

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


/etc/apache2/sites-available/testhang.conf

<VirtualHost www.testhang.com:80>
 ServerAdmin www.testhang.com
 DocumentRoot /var/www/html/testhang
 ServerName www.testhang.com

 <Directory /var/www/html/testhang>
     Allow from all
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order Allow,Deny
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/testhang-log.log
 CustomLog ${APACHE_LOG_DIR}/testhang-access.log combined

</VirtualHost>


/etc/hosts


127.0.0.1 localhost
127.0.1.1 ubuntu

127.0.1.1 www.testhang.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Yii: Insert new record to database - Cdbcommand

// Save to database
    public function save(){
        $conn = Yii::app()->db;
        $conn->active = true; // Start connect
        $command = $conn->createCommand();
        $command->insert('archives', array(
            'IdUserCreate' => $this->idUserCreate,
            'Name'=> $this->name,
            'Path'=> $this->path,
            'DateCreate' => $this->dateCreate,
        ));
        $conn->active =  false; // Close connect

    }