1gz install apr-1.5.1.tar.gz
Command:
Wget http://apache.fayea.com/apache-mirror//apr/apr-1.5.1.tar.gz
Tar zxvf apr-1.5.1.tar.gz
Cd apr-1.5.1
./Configure
Make
Make install
2. Install apr-util-1.3.7.tar.gz
Command:
Http://apache.fayea.com/apache-mirror//apr/apr-util-1.5.4.tar.gz
Tar zxvf apr-util-1.5.4.tar.gz
Cd apr-util-1.5.4
./Configure
Make
Make install
3rd install httpd-2.2.29.tar.gz
Command:
Wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.29.tar.gz
Tar zxvf httpd-2.2.29.tar.gz
Cd httpd-2.2.29
. /Configure-prefix =/usr/local/apache2-enable-dav-enable-modules = so-enable-maintainer-mode-enable-rewrite-with-apr =/usr/local /apr/bin/apr-1-config-with-apr-util =/usr/local/apr/bin/apu-1-config
Make
Make install
4. Start the Apache service
Command:/usr/local/apache2/bin/apachectl start (which can be accessed after startup)
5. Modify the site configuration file
Path:/usr/local/apache2/conf/httpd. conf
Default site directory:/usr/local/apache2/htdocs/
Linux httpd (apache) startup failed
Red Hat Linux enterprise 5
Start httpd faild
Linux httpd: httpd starts failed
I encountered this problem in the virtual machine. After trying many methods, I couldn't start it. Later I found that the problem lies in a file named httpd. conf in the/etc/httpd/conf/directory. There is another httpd in the same directory. conf. bak, as long as the httpd. conf. bak content replication httpd. in the conf file, overwrite the original content and start it. Run service httpd start in shell. We are pleasantly surprised to find that start httpd OK. Start httpd OK
Use service httpd status to check whether httpd is running. Feeling comfortable. Although it's just a beginner's problem, Hey, but I still write it down. Maybe this problem may be helpful for a newbie. Later, I checked in detail what caused the problem. The result is unexpected. The [system]-[management]-[server settings]-[HTTP] tool was used for setting, and then saved and imported. After using this tool, the configuration content is quite different from the initial setting.
I found that modifying the/etc/httpd/conf/httpd. conf file can solve the problem:
1. Comment out the ServerName line, that is, add a # sign at the beginning of the line.
2. Complete the ServerAdmin line. For example: ServerAdmin admin@example.com
3. Correct the file path of the Lockfile, or comment out all of them (add at the beginning of the line #)
4. Load module .........
Loadmodule .........
... # There are many lines. Omitted! In fact, these errors are caused by HTTP code problems. We replace it with an initial file.
Loadmodule .....
Replace the corresponding content in/etc/httpd/conf/httpd. conf. bak.
The content is as follows:
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so
OK. In this case, you can start the httpd service. Use the service httpd start command in shell to start the service.
Add Apache as a Linux service for self-startup
After compiling and installing Apache in the source code mode in Linux, you can run the following command to disable Apache:
/Usr/local/apache2/bin/apachectl start | stop | restart
If you want to include httpd in the service automatically started by the system, you can directly copy the above apachectl file to/etc/rc. d/init. d, and then add the link to the corresponding startup level such as 3, 5. The command is as follows:
Cp/usr/local/apache2/bin/apachectl/etc/rc. d/init. d/httpd
Ln-s/etc/rc. d/init. d/httpd/etc/rc. d/rc3.d/S61httpd
The S61 of the linked file is the serial number at startup. When the init. d Directory contains the httpd script, we can use the service command to start and close apache. Run the following command in any path:
Service httpd start | stop | restart
No prompt information is entered in the script, but the command has been executed. The problem is that apache can be started automatically but cannot be seen in the linux service list, such as running the chkconfig -- list command of ntsysv or Red Hat. To add a service, it is generally implemented through chkconfig -- add xxx, but the script must have the relevant information. Otherwise, chkconfig will prompt that The xxx service does not support chkconfig. Therefore, first edit the httpd script and add the following comments to row 2nd:
# Chkconfig: 35 61 61
# Description: Apache
The three parameters in the first line indicate the running levels of httpd (3, 5), S61, and K61 ). Note: The second line of description must be written!
Save and run: chkconfig -- add httpd.
Add httpd to the service. The S61httpd link will appear in the rc3.d and rc5.d paths, and the K61httpd link will appear in other running-level paths.
Run chkconfig -- list to view the httpd service.