Apache server configuration in Linux
Related packages:
Httpd-2.2.3-29.e15.i386.rpm // MAIN package httpd-devel-2.2.3-29.e15.i386.rpm // development package httpd-manual-2.2.3-29.e15.i386.rpm // Manual documentation system-config-httpd-1.3.3.3-1.e15.noarch.rpm // Configuration tool Note: dependency package problems may occur during installation, you can use YUM installation to configure a firewall to enable YUM.
Automatic loading upon startup:
chkconfig --level 3 httpd on
Configuration instance:
Example 1: create a WEB server in the department. The IP address and port used are 192.168.0.3: 80, and the index.html file is displayed on the first page. Administrator e-mail address is root@bkjia.com, the encoding type of web pages using GB2312, all website resources are stored in the/var/www/html directory, set the Apache root directory to the/etc/httpd directory. Edit the main configuration file httpd. confvim/etc/httpd/conf/httpd. conf // edit master configuration file ServerRoot "/etc/httpd" // set Apache main directory Timeout 120 // Set Request Timeout Listen 80 // set listening port ServerAdmin root@bkjia.com // set Administrator mailbox ServerName 192.168.0.3: 80 // set the host or IPDocumentRoot "/var/www/html" // set the Apache document directory DirectoryIndex index.html // set the homepage file adddefacharcharset GB2312 // set the website code to edit the homepage file for testing: cd/var/www/htmlecho "This is web test sample. "> index.html chmod 705 index.html: service httpd restar
Example 2: assume that the Apache server has two addresses: 192.168.0.2 and 19.16.0.3, configure Apache, bind multiple websites to different IP addresses, and access different IP addresses on the server, you can see different websites.
(Based on IP) mkdir/var/www/ip1/var/www/ip2 // create two home directories to edit httpd. conf file: <Virtualhost 192.168.0.2> // set the virtual host's IP DocumentRoot/var/www/ip1 // set the virtual host's home directory DirectoryIndex index.html // set the Home file ServerAdmin root@bkjia.com // set the Administrator mailbox ErrorLog logs/ip1-error_log // set the location of the Error Log CustomLog logs/ip1-access_log common // set the location of the access log </Virtualhost> <Virtualhost 192.168.0.3> // set the corresponding IP DocumentRoot/ var/www/ip2 DirectoryIndex index.html ServerAdmin root@bkjia.com ErrorLog logs/ip2-error_log CustomLog logs/ip2-access_log common </Virtualhost>
(Based on Domain Name) mkdir/var/www/bkjia/var/www/long // create two home directories to edit httpd. conf file: <Virtualhost 192.168.0.3> // sets the virtual host's IP address DocumentRoot/var/www/bkjia // sets the virtual host's main directory DirectoryIndex index.html // sets the home page file ServerName www.bkjia.com // sets the Virtual Host completely domain Name ServerAdmin root@bkjia.com // set administrator mailbox ErrorLog logs/bkjia-error_log // set location of Error Log CustomLog logs/bkjia-access_log common // set location of access log </Virtualhost> <Virtualhost 192.168.0.3> DocumentRoot/var/www/long DirectoryIndex index.html ServerName www.bkjia.com // set the virtual host full domain name ServerAdmin root@bkjia.com ErrorLog logs/long-error_log CustomLog logs/long-access_log common </Virtualhost>
(Based on the port) mkdir/var/www/port8080/var/www/port8090 // create two main directories to edit httpd. conf file: Listen 8080 Listen 8090 <Virtualhost 192.168.0.3: 8080> // set the corresponding port DocumentRoot/var/www/port8080 // set the virtual host's home directory DirectoryIndex index.html // set the Home file ServerAdmin root@bkjia.com // set the Administrator mailbox ErrorLog logs/port8080-error_log // set the location of the Error Log CustomLog logs/port8080-access_log common // set the location of the access log </Virtualhost> <Virtualhost 192.168.0.3: 8090> // set the corresponding port DocumentRoot/var/www/port8090 DirectoryIndex index.html ServerAdmin root@bkjia.com ErrorLog logs/port8090-error_log CustomLog logs/port8090-access_log common </Virtualhost>
Install a Web Server on Ubuntu Server 14.04 (Linux + Apache + MySQL + PHP)
Install and configure the PHP environment in Linux (Apache2)
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Configuration of Apache Virtual Hosts in Linux
Apache details: click here
Apache: click here
This article permanently updates the link address: