Usually, when we install Appserver, we will get the domain name is http://localhost If we want to change to a different name, such as http://project Or when wanting to have multiple domains to use with multiple projects, what to do?
For example, http://project1 Keep the file in the project1 directory and http://project2 Keep files in project2. Managing or testing is probably a lot easier. Especially if there are many projects and the work will be a lot easier
The basic principle is similar to making a subdomain on localhost :
1. Open the file C:\windows\system32\drivers\etc\hosts with a general text editor and add the desired domain, such as
Can be added according to the number of projects desired And the desired name (Including being able to create subdomain too)
2. Open Appserver's httpd.conf file. Don't know where it is. You can look at the Appserver menu. Click on Apache Edit the httpd.conf Configuration File.
Specify ServerName, which is usually set to localhost as the IP Address.
3. Assign the directory to the domain created with VirtualHost. First of all, we need to define NameVirtualHost Before configuring VirtualHost
We can insert this code from the first line of the file that opens.
The importance of the directory assignment is that the desired directory must be under the DocumentRoot of the server. For example, it is usually specified at C:/AppServ/www We only need to specify a subdirectory under this folder such as C:/AppServ/www/project1
4. After that, create a directory to store files and Restart Apache is complete.
Now the test is easier.
Note: For XAMPP, the httpd.conf file is located in the folder. /xampp/apache/conf/
For example, http://project1 Keep the file in the project1 directory and http://project2 Keep files in project2. Managing or testing is probably a lot easier. Especially if there are many projects and the work will be a lot easier
The basic principle is similar to making a subdomain on localhost :
1. Open the file C:\windows\system32\drivers\etc\hosts with a general text editor and add the desired domain, such as
127.0.0.1 project1And save
127.0.0.1 project2
Can be added according to the number of projects desired And the desired name (Including being able to create subdomain too)
2. Open Appserver's httpd.conf file. Don't know where it is. You can look at the Appserver menu. Click on Apache Edit the httpd.conf Configuration File.
Specify ServerName, which is usually set to localhost as the IP Address.
ServerName localhost:80change to
ServerName 127.0.0.1:80
3. Assign the directory to the domain created with VirtualHost. First of all, we need to define NameVirtualHost Before configuring VirtualHost
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/AppServ/www"
</VirtualHost>
<VirtualHost *:80>
ServerName project
DocumentRoot " C:/AppServ/www/project1 "
</VirtualHost>
<VirtualHost *:80>
ServerName project2
DocumentRoot "C:/AppServ/www/project2"
</VirtualHost>
We can insert this code from the first line of the file that opens.
The importance of the directory assignment is that the desired directory must be under the DocumentRoot of the server. For example, it is usually specified at C:/AppServ/www We only need to specify a subdirectory under this folder such as C:/AppServ/www/project1
4. After that, create a directory to store files and Restart Apache is complete.
Now the test is easier.
Note: For XAMPP, the httpd.conf file is located in the folder. /xampp/apache/conf/
Comments
Post a Comment