linux--Compile and install httpd service, same IP port, different domain name

Source: Internet
Author: User
Tags install openssl

1. Environment, first off firewall

[[email protected] ~]# systemctl status firewalld[[email protected] ~]# systemctl disable firewalld[[email protected] ~]# systemctl stop firewalld[[email protected] ~]# setenforce 0

Compiling and installing httpd-2.4

//安装开发环境yum groupinstall "Development Tools"yum groups mark install "Development Tools"//安装检查yum grouplist//创建系统用户,组但不创建新组文件groupadd -r apacheuseradd -M -s /sbin/nologin -g apache apache    (-M/不自动登陆,-s/这里指不登陆,-g/指定用户组)   yum -y install openssl-devel pcre-devel expat-devel libtool
Download and install apr-1.4+ and Apr-util-1.4+cd/usr/src/wget Http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.bz2wget/HTTP/ mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2//unzipped into Bz2tar XF Apr-1.6.3.tar.bz2tar XF apr-util-1.6.1.tar.bz2 Edit apr-1.6.3 Configuration cd apr-1.6.3vim configurecfgfile= "${ofile}t" trap "$RM \" $cfgfile \ "; Exit 1 "1 2 15$rm" $cfgfile "//This line with comment # or delete//configuration procedure./configure--prefix=/usr/local/apr//compiling and installing the installation process make & amp;& make install//apr-util-1.6.1 configuration cd/usr/src/apr-util-1.6.1./configure--prefix=/usr/local/apr-util-- with-apr=/usr/local/apr//compile and install make && make install//compile and install Httpdwget http://mirror.bit.edu.cn/apache//httpd/ Httpd-2.4.34.tar.bz2[[email protected] ~]# lshttpd-2.4.34.tar.bz2[[email protected] ~]# tar XF Httpd-2.4.34.tar.bz2[[email protected] ~]# CD httpd-2.4.34[[email protected] httpd-2.4.34]#./configure-- Prefix=/usr/local/apache--sysconfdir=/etc/httpd24--enable-so--enable-ssl--enable-cgi--enable-rewrite-- With-zlib--with-pCRE--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/--enable-modules=most--enable-mpms-shared=all- -with-mpm=prefork[[email protected] httpd-2.4.34]# make && make install

Note:
./configure--prefix=/usr/local/apache \//installation path
"--sysconfdir=/etc/httpd24 \ config path
--with-mpm=prefork can be changed into worker

Virtual Host
There are three types of virtual hosts:

    • Different ports of the same IP
    • Same port with different IP
    • same IP different port different domain name

Vim/etc/httpd24/httpd.conf

  ServerName www.example.com:80//Uncomment (delete #) [[email protected] httpd-2.4.34]# vim/etc/httpd24/ httpd.conf//Enter configuration, with IP, different domain name <virtualhost 192.168.56.11:80> ServerName www.guohui.com documentroot "/usr/lo Cal/apache/htdocs/guohui "errorlog" Logs/guohui/error_log "Customlog" Logs/guohui/access_log "combined <Dir  Ectory "/usr/local/apache/htdocs/guohui" > <RequireAll> Require All granted Require not IP     192.168.1 </RequireAll> </directory></virtualhost><virtualhost 192.168.56.11:80> ServerName www.guohui1.com documentroot "/usr/local/apache/htdocs/guohui" errorlog "Logs/guohui/error_log" Cus Tomlog "Logs/guohui/access_log" combined <directory "/usr/local/apache/htdocs/guohui" > <requireall>         ; Require all granted Require not IP 192.168.1 </RequireAll> </directory></virtualhost> ; Set Nu  

Create a URL file

[[email protected] httpd-2.4.34]# cd /usr/local/apache/htdocs/[[email protected] htdocs]# mkdir guohui guohui1[[email protected] guohui]# echo ‘guo‘ > guohui/index.html[[email protected] guohui]# echo ‘hui‘ > guohui1/index.html

Create a file under logs

[email protected] ~]# cd /usr/local/apache/logs[[email protected] logs]# mkdir guohui guohui1

Assigning permissions to a master group

chown -R apache.apache /usr/local/apache/htdocschown -R apache.apache /usr/local/apache/logs[[email protected] htdocs]# cd /usr/local/apache/htdocs[[email protected] htdocs]# chown -R apache.apache guohui[[email protected] htdocs]# chown -R apache.apache guohui1

Starting mode
1.

[[email protected] htdocs]# /usr/local/apache/bin/apachectl start   启动                                              /usr/local/apache/bin/apachectl gracefu   重启服务                                                                                            apachectl -t 检查

2.

/usr/local/apache/bin/httpd 启动/usr/local/apache/bin/httpd -t 检查语法/usr/local/apache/bin/apachectl                                      start                                      restart                                      stop                                      restart

Edit Etc/host file location, ip+ URL

windows  C:\Windows\System32\drivers\etclinux etc/hostcurl www.guohui.com  访问要清空浏览器缓存-j 4  //4核速度

linux--Compile and install httpd service, same IP port, different domain name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.