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安装目录
If Apr has not been installed, an error will be reported:
checking for APR... no configure: error: APR not found. Please read the documentation.
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
An error will be reported again:
checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
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
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
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
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/
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/
9. Download pcre-8.41.tar.gz
10. Upload to the server/usr/local/software
tar -zxvf pcre-8.41.tar.gz ./configure
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.
10. Install the c environment
yum install -y gcc gcc-c++ # 错了那么多次,别忘了现在的位置,接下来还是要安装pcre ./configure make make install
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
is so miserable! Another error was reported in the last step:
/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode' /usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler' /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' make[1]: *** [all-recursive] 错误 1 make[1]: Leaving directory `/usr/local/software/apache/support'
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
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
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'
15. Enter the configuration file location: /usr/local/apache2/conf
cp httpd.conf httpd.conf.bak # 备份配置文件 vim httpd.conf # 放掉191行的注释,修改为: ServerName [你的IP]:80 :wq
16. Start apache
/usr/local/apache2/bin/apachectl start # 或者 /usr/local/apache2//bin/httpd -k start
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前面就是//
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
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 完毕!
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
3. Start the service
systemctl start httpd.service
Enter the ip in the browser, and the html preset by apache will appear, perfect! ! !
4. Close the service
systemctl stop httpd.service
5. I started the httpd installed in the first way again
/usr/local/apache2/bin/apachectl start
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!

Reasons for Apache's popularity include its modular design, virtual hosting capabilities, performance optimization, and security. 1. Modular design allows users to load or unload modules, such as mod_rewrite and mod_ssl, according to their needs. 2. The virtual hosting function supports hosting multiple websites on one server. 3. Performance optimization is achieved by enabling KeepAlive, adjusting MPM and using a cache mechanism. 4. Security is guaranteed by regular updates, restricting access and enabling HTTPS.

Apache is the basis of many websites because of its stability, reliability and highly configurable. 1.Apache is developed by the Apache Software Foundation, supports a variety of operating systems and provides static and dynamic content services. 2. Its core functions include handling HTTP requests, virtual hosting and modular design. 3. Configuration examples from basic settings to advanced virtual hosts and URL rewrites. 4. Common errors such as permissions, syntax and module loading problems can be solved through corresponding debugging techniques. 5. Performance optimization includes tuning parameters, using cache and load balancing, and following best practices can improve server efficiency and security.

Apache will continue to develop in cloud-native technology, machine learning, artificial intelligence, blockchain, data security and performance optimization in the future. 1) Cloud native and containerized technologies will be further integrated to launch more optimized versions; 2) More easy-to-use tools and frameworks will be launched in the fields of machine learning and artificial intelligence; 3) Blockchain and distributed ledger technologies will invest more resources to promote standardization and popularization; 4) Data security and privacy protection will be strengthened, and higher security versions and tools will be launched; 5) Performance optimization and best practices will continue to be valued to help developers improve efficiency.

The .htaccess file is used for directory-level configuration, and the virtual host is used to host multiple websites on the same server. 1).htaccess allows adjustment of directory configurations such as URL rewriting and access control without restarting the server. 2) The virtual host manages multiple domain names and configurations through VirtualHost instructions, and supports SSL encryption and load balancing.

Apache can achieve load balancing by configuring mod_proxy and mod_proxy_balancer modules. 1) Make sure Apache has installed and enabled the mod_proxy and mod_proxy_balancer modules. 2) Add load balancing configuration in the Apache configuration file and forward the request to the backend server cluster. 3) The load balancing algorithm can be adjusted and session persistence can be configured as needed to optimize performance and user experience.

How to strengthen the security of Apache servers? This can be achieved through the following steps: limit access to sensitive directories and set access control using configuration files. Use the mod_security module to implement advanced security policies, such as preventing SQL injection attacks. Check the profile syntax regularly, monitor access logs using log analysis tools, and perform penetration testing. Optimize mod_security rule set to balance security and performance, and ensure code readability and maintainability.

To configure SSL/TLS on the Apache server to protect the website, you need to follow the following steps: 1. Obtain the SSL/TLS certificate; 2. Enable SSL/TLS in the Apache configuration file and specify the certificate and private key path; 3. Set up HTTP to HTTPS redirection; 4. Consider using OCSPStapling to improve connection speed; 5. Optimize performance, such as enabling HTTP/2 and session caching.

Apache servers can extend functions through mod_rewrite module to improve performance and security. 1. Turn on the rewrite engine and define rules, such as redirecting /blog to /articles. 2. Use conditional judgment to rewrite specific parameters. 3. Implement basic and advanced URL rewrites, such as .html to .php conversion and mobile device detection. 4. Common errors are used to debug logs. 5. Optimize performance, reduce the number of rules, optimize the order, use the conditions to judge, and write clear rules.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.