How to install apache server in linux

步履不停
Release: 2019-07-22 09:56:29
Original
13205 people have browsed it

How to install apache server in linux

Compressed package installation method

1. Download httpd-2.4.29.tar.gz

2. Upload to server/usr/local/software

tar -zxvf httpd-2.4.29.tar.gz
./configure --prefix=/usr/local/apache2/ # 设置apache安装目录
Copy after login

If Apr has not been installed, an error will be reported:

checking for APR... no
configure: error: APR not found.  Please read the documentation.
Copy after login

3. Next, install apr, first download apr- 1.6.3.tar.gz

4. Upload to server/usr/local/software

tar -zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
.configure
make
make install
Copy after login

An error will be reported again:

checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
Copy after login

5. Download apr-util-1.6 .1.tar.gz

6. Upload to server/usr/local/software

tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
Copy after login

At this time, an error will be reported:

xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
 #include <expat.h>
                   ^
编译中断。
make: *** [xml/apr_xml.lo] 错误 1
Copy after login

7. It is speculated that expat may be missing. Development library

yum install expat-devel # 中间会让你输入y
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
make # 成功!
make install
Copy after login

8. At this time, go back to install apache. Not only must you specify the path of apr, but also the path of apr-util

./configure --prefix=/usr/local/apache2/  --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
Copy after login

Still reporting errors, many people may come here. It has crashed, but this error is similar to the one encountered before

checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
Copy after login

9. Download pcre-8.41.tar.gz

10. Upload to the server/usr/local/software

tar -zxvf pcre-8.41.tar.gz
./configure
Copy after login

reported an error again, I guarantee this is the last time

checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.
Copy after login

10. Install the c environment

yum install -y gcc gcc-c++
# 错了那么多次,别忘了现在的位置,接下来还是要安装pcre
./configure
make
make install
Copy after login

11. Okay, it’s been a big circle, and the next step is to install it apache

cd ..
cd apache
./configure --prefix=/usr/local/apache2/  --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
make
make install
Copy after login

is so miserable! Another error was reported in the last step:

/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode&#39;  
/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler&#39;  
/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_ParserCre
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: Leaving directory `/usr/local/software/apache/support&#39;
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/usr/local/software/apache/support&#39;
Copy after login

I have never seen this kind of error before, so I searched online and found the answer: the apr version is too high;

12. So I downloaded apr-util- 1.5 http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz

13. Upload to server/usr/local/software

tar -zxvf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util-1.5/ --with-apr=/usr/local/apr
make
make install
Copy after login

14. Repeat step 11. The only difference is that the configuration now specifies: apr-util-1.5. This is very important! ! !

cd ..
cd apache
./configure --prefix=/usr/local/apache2/  --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util-1.5/
make # make时间会比较长
make install
Copy after login

Perfect ending:

Installing configuration files
mkdir /usr/local/apache2/conf
mkdir /usr/local/apache2/conf/extra
mkdir /usr/local/apache2/conf/original
mkdir /usr/local/apache2/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2/htdocs
Installing error documents
mkdir /usr/local/apache2/error
Installing icons
mkdir /usr/local/apache2/icons
mkdir /usr/local/apache2/logs
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
mkdir /usr/local/apache2/include
Installing build system files
mkdir /usr/local/apache2/build
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/usr/local/software/apache&#39;
Copy after login

15. Enter the configuration file location: /usr/local/apache2/conf

cp httpd.conf httpd.conf.bak    # 备份配置文件
vim httpd.conf
# 放掉191行的注释,修改为:
ServerName [你的IP]:80
:wq
Copy after login

16. Start apache

/usr/local/apache2/bin/apachectl start
# 或者
/usr/local/apache2//bin/httpd -k start
Copy after login

Turn off the firewall, enter the server IP in the browser address bar, and the web page will appear: It works!

17. Close apache

ps -ef|grep apache
/usr/local/apache2/bin/apachectl stop
# 或者
/usr/local/apache2//bin/httpd -k stop
# 没错,bin前面就是//
Copy after login

This method of original file installation is too complicated. In fact, There is another way to install the apache service. I don’t know if it conflicts with my previous installation. I will try it today.

yum source installation method

1. yum source installation (requires Internet download)

首先关闭apache服务
yum install httpd # 中间过程中输入:y
Copy after login

Result:

Installed as a dependency:

  apr.x86_64 0:1.4.8-3.el7_4.1      
  apr-util.x86_64 0:1.5.2-6.el7        
  httpd-tools.x86_64 0:2.4.6-67.el7.centos.6      
  mailcap.noarch 0:2.1.41-2.el7        
完毕!
Copy after login

2. The installation location of yum is: /etc/httpd/conf. After I entered it, I backed up the configuration file first. The modified place is different from before, in line 95. For reference only

cd /etc/httpd/conf
cp httpd.conf httpd.conf.bak
# 放掉95行的注释,修改为:
ServerName [你的IP]:80
:wq
Copy after login

3. Start the service

systemctl start httpd.service
Copy after login

Enter the ip in the browser, and the html preset by apache will appear, perfect! ! !

How to install apache server in linux4. Close the service

systemctl stop httpd.service
Copy after login

5. I started the httpd installed in the first way again

/usr/local/apache2/bin/apachectl start
Copy after login

Refresh the browser and the message: It works!, It shows that there is no conflict between the two installation methods.

For more technical articles related to Apache, please visit the Apache Tutorial column to learn!

The above is the detailed content of How to install apache server in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template