program development

Apache installation and automatic startup under centos 7

Recently play Apache mysql redis, etc., so the pit encountered to summarize the next, step by step installation If you still encounter problems, the article […]

article directories
  1. Recently, I have been playing Apache mysql redis, etc., so I summarized the pitfalls I encountered. If I still encounter problems with the step-by-step installation, just leave a message at the bottom of the article and communicate together... I don't want to talk anymore, I'm starting to wave...
  2. Install centos 7After the system needs to be configured with IP and other information,
  3. vi /etc/sysconfig/network-scripts/ifcfg-eth0
  4. BOOTPROTO=static
  5. The way the network card obtains the ip address, Static (static ip address) dhcp (obtains the ip through the dhcp protocol)
  6. HWADDR=00:50:56:8E:47:EE network card physical address
  7. IPADDR=10.0.0.193 Network card IP address
  8. IPV6INIT=no Whether to enable IPV6
  9. IPV6_AUTOCONF=no
  10. NETMASK=255.255.255.0 Network mask corresponding to network card
  11. NETWORK=192.168.1.0 The network address corresponding to the network card
  12. ONBOOT=yes Whether to set this network interface when the system is started. When set to yes, this device will be activated when the system is started. Default setting is yes
  13. service network restart Restart the service or/etc/init.d/network restart
  14. What you need to change is IPADDR DNS1 GATEWAY DEVICE , just install your own machine and modify it.
  15. After the modifications are completed, the service network restarts and then ping Baidu to see if you can ping. If you can ping, it means you can surf the Internet.
  16. Next step, turn off the firewall. The wall of centos 7 is firewall
  17. systemctl stop firewall.service #Stop firewall
  18. systemctl disable firewall.service #Disable firewall from booting
  19. firewall-cmd-state #Check the default firewall state (not running is displayed after turning off, running is displayed after turning on)
  20. The next step is to upload the apache-dependent package. First, cd it to the root directory and then create a new tools folder, mkdir tools. Upload the dependent package and apache file to the tools below apr-1.6.3.tar.gz 、apr-util-1.6.1.tar.gz、pcre-8.41.zip、openssl-1.0.2n.tar.gz、httpd-2.4.29.tar.gz。
  21. Start decompressing:
  22. tar -xzvf apr-1.6.3.tar.gz
  23. tar -xzvf apr-util-1.6.1.tar.gz
  24. You need to install uzip yum install -y unzip zip first
  25. unzip pcre-8.41.zip
  26. Install apr-1.6.3
  27. Enter the installation directory
  28. cd /tools/apr-1.6.3/
  29. Install and compile
  30. Install gcc first yum -y install gcc
  31. ./ configure –prefix=/usr/local/apr
  32. rm: cannot remove 'libtoolT': No such file or director appears
  33. cd apr-1.6.3
  34. modify
  35. vi configure
  36. 9365 #RM=$ac_cv_prog_RM
  37. 9355 #ac_cv_prog_RM=“rm”
  38. make && make install will not report errors.
  39. Enter the installation directory
  40. cd /tools/apr-util-1.6.1/
  41. yum install -y libxml2-devel
  42. ./ configure –prefix=/usr/local/apr-util/ –with-apr=/usr/local/apr/bin/apr-1-config
  43. In CentOS7 minimum installation version, compile and install apr-util error:
  44. fatal error: expat.h: No such file or director
  45. Solution: yum install expat-devel
  46. make && make install
  47. Enter the installation directory
  48. cd /tools/pcre-8.41/
  49. Install and compile
  50. yum -y install gcc+ gcc-c++
  51. ./ configure –prefix=/usr/local/pcre
  52. make && make install
  53. Enter the installation directory
  54. tar -xvf openssl-1.0.2n.tar.gz
  55. cd openssl-1.0.2n
  56. yum install perl*
  57. ./ config -fPIC –prefix=/usr/local/openssl –openssldir=/usr/local/openssl
  58. make && make install
  59. Install gcc online
  60. #yum install gcc*
  61. cd /tools will install the package httpd-2.4.29Copy.tar.gz to the/tools directory
  62. #tar zxvf httpd-2.4.29.tar.gz
  63. #cd /tools/httpd-2.4.29
  64. yum install zlib-devel
  65. ./ configure –prefix=/opt/apache/apache-2.4.29 –enable-deflate –enable-expires –enable-headers –enable-ssl –enable-cgi –with-zlib –with-mpm=worker –enable-so –enable-rewrite –enable-module=shared –enable-mods-shared=most ap_cv_void_ptr_lt_long=no –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-pcre=/usr/local/pcre –with-ssl=/usr/local/openssl –enable-unique –enable-unique_id
  66. make && make install but an error was reported later
  67. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode’
  68. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler’
  69. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate’
  70. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler’
  71. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree’
  72. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData’
  73. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser’
  74. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse’
  75. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString’
  76. /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler’
  77. collect2: error: ld returned 1 exit status
  78. make[2]: *** [htpasswd] Error 1
  79. make[2]: Leaving directory `/usr/local/httpd-2.4.26/support’
  80. make[1]: *** [all-recursive] Error 1
  81. make[1]: Leaving directory `/usr/local/httpd-2.4.26/support’
  82. make: *** [all-recursive] Error 1
  83. ① Install libxml2-devel
  84. 1 [root@test_01 ~]# yum install -y libxml2-devel
  85. ② Delete the apr-util directory and recompile the installation
  86. 1
  87. 2
  88. 3
  89. 4
  90. 5
  91. [root@test_01 ~]#rm -rf /usr/local/apr-util
  92. [root@test_01 ~]# cd /tools/apr-util-1.6.1/
  93. [root@test_01 apr-util-1.6.1]# make clean
  94. [root@test_01 apr-util-1.6.1]#./ configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
  95. [root@test_01 apr-util-1.6.1]#make && make install
  96. Recompile apache and install it will be ok
  97. Enter the post-installation directory:
  98. # cd /opt/apache/apache-2.4.29/bin
  99. Check the process mode:
  100. # ./ apachectl -l
  101. Compiled in modules:
  102. core.c
  103. worker.c
  104. http_core.c
  105. mod_so.c
  106. Start Apache Web Server:
  107. #./ apachectl start
  108. ServerName localhost:80
  109. Then the browser opens the address and it works appears
  110. Open the following to boot apache
  111. Stop Apache Web Server:
  112. #./ apachectl stop
  113. 1. Copy the apachectl file to/etc/init.d, and then add the link to/etc/rc.d/rc5.d.
  114. The order is as follows:
  115. cp /opt/apache/apache-2.4.29/bin/apachectl /etc/init.d/httpd
  116. ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S85httpd
  117. 2. Running chkconfig-list to find that there is no httpd in the list. Adding it by chkconfig-add httpd may remind you that the httpd service does not support chkconfig and you need to edit/etc/rc.d/init.d/httpd
  118. Add the following comment information:
  119. # chkconfig: 345 85 15
  120. # description: Activates/Deactivates Apache Web Server
  121. 345Represents which linux levels need to be activated httpd, and the activation sequence number is85, the closing sequence number is15
  122. 3. Run chkconfig-list, httpd exists, and you can use service httpd start and service httpd stop to start and stop services
  123. startup
  124. chkconfig –level 2345 httpd on
  125. The tutorial is finished. If you encounter any problems with apache, you can leave messages and communicate with each other...