{"id":253883,"date":"2022-10-07T08:07:25","date_gmt":"2022-10-07T00:07:25","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=253883"},"modified":"2022-09-28T11:08:03","modified_gmt":"2022-09-28T03:08:03","slug":"apache-linux-shell","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/apache-linux-shell.html","title":{"rendered":"\u7b80\u5355\u4ecb\u7ecd\u6e90\u7801\u5b89\u88c5apache\u811a\u672c\u90e8\u7f72\u8fc7\u7a0b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u6e90\u7801\u5b89\u88c5apache\u811a\u672c\u90e8\u7f72,\u672c\u6587\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u7684\u975e\u5e38\u8be6\u7ec6\uff0c\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6216\u5de5\u4f5c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u501f\u9274\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u6e90\u7801\u5b89\u88c5apache\u811a\u672c\u90e8\u7f72<\/strong><\/div>\n
[root@localhost ~]# ls\r\nanaconda-ks.cfg  httpd.tar.xz\r\n[root@localhost ~]# tar xf httpd.tar.xz  \u89e3\u538b\u5b58\u653e\u811a\u672c\u7684\u538b\u7f29\u5305\r\n[root@localhost ~]# ls\r\nanaconda-ks.cfg  httpd  httpd.tar.xz\r\n[root@localhost ~]# cd httpd\/\r\n[root@localhost httpd]# ls\r\napache_lnh.sh(\u7f16\u8bd1\u5b89\u88c5apache\u811a\u672c)  config.sh(\u9644\u5c5e\u811a\u672c)  files\r\n[root@localhost httpd]# ls files\/    \/\/\u5b58\u653e\u5b89\u88c5\u5305\u7684\u76ee\u5f55\r\napr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.53.tar.gz  httpd-2.4.54.tar.gz  zhuawawa(\u6e90\u7801\u5305\u7684\u76ee\u5f55)\r\n[root@localhost httpd]# cat apache_lnh.sh \r\n#\/bin\/bash\r\n \r\n#\u5217\u51fahttpd\u7248\u672c\u53f7\u8fdb\u884c\u9009\u62e9\r\ncat > \/tmp\/xbz.txt < \/dev\/null\r\nif [ $? -ne 0 ];then\r\n            useradd -r -M -s \/sbin\/nologin apache\r\n    else\r\n            echo \"\u7528\u6237\u5df2\u5b58\u5728\"\r\nfi\r\n#\u5b89\u88c5\u4f9d\u8d56\u5305\r\ndnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ wget make vim  zip --allowerasing\r\n#\u89e3\u538b\u6e90\u7801\u5305\r\nrm -rf \/tmp\/*\r\ntar xf files\/apr-1.7.0.tar.gz -C \/tmp\/\r\ntar xf files\/apr-util-1.6.1.tar.gz -C \/tmp\/\r\ntar xf files\/httpd-$apache_version.tar.gz -C \/tmp\/\r\n#\u7f16\u8bd1\u5b89\u88c5apr\r\ncd \/tmp\/apr-1.7.0\r\nif [ ! -d \/usr\/local\/apr ];then\r\nsed -i '\/$RM \"$cfgfile\"\/d' configure\r\n.\/configure --prefix=\/usr\/local\/apr && \\\r\nmake && make install   \r\nelse\r\n        ls \/usr\/local\r\n        echo \"apr \u7f16\u8bd1\u5b89\u88c5\u5b8c\u6210\"\r\nfi\r\n#\u7f16\u8bd1\u5b89\u88c5apr-util\r\ncd ..\/apr-util-1.6.1\/\r\nif [ ! -d \/usr\/local\/apr-util ];then\r\n.\/configure --prefix=\/usr\/local\/apr-util --with-apr=\/usr\/local\/apr && \\\r\nmake && make install\r\nelse\r\n         ls \/usr\/local\/\r\n         echo \"apr-util \u7f16\u8bd1\u5b89\u88c5\u5b8c\u6210\"      \r\nfi\r\n#\u7f16\u8bd1\u5b89\u88c5httpd\r\ncd ..\/httpd-$apache_version\/\r\nif [ ! -d ${install_dir} ];then\r\n            .\/configure --prefix=${install_dir} \\\r\n                    --enable-so \\\r\n                    --enable-ssl \\\r\n                    --enable-cgi \\\r\n                    --enable-rewrite \\\r\n                    --with-zlib \\\r\n                    --with-pcre \\\r\n                    --with-apr=\/usr\/local\/apr \\\r\n                    --with-apr-util=\/usr\/local\/apr-util\/ \\\r\n                    --enable-modules=most \\\r\n                    --enable-mpms-shared=all \\\r\n                    --with-mpm=prefork   \r\n             make && make install   \r\nelse\r\n          ls ${install_dir}\r\n          echo \"httpd \u7f16\u8bd1\u5b89\u88c5\u5b8c\u6210\"\r\nfi\r\n#\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf,man\u6587\u6863,\u5934\u6587\u4ef6\r\necho \"export PATH=${install_dir}\/bin:\\$PATH\" > \/etc\/profile.d\/apache.sh\r\nln -s ${install_dir}\/include \/usr\/include\/apache &> \/dev\/null\r\ngrep 'apache' \/etc\/man_db.conf &> \/dev\/null\r\nif [ $? -ne 0 ];then\r\n            sed -i \"22a MANDATORY_MANPATH                       ${install_dir}\/man\" \/etc\/man_db.conf\r\nfi\r\n#\u5c06\u5176\u52a0\u5165systemd\u670d\u52a1\u91cc\u9762\r\ncat > \/usr\/lib\/systemd\/system\/httpd.service <<\/eof> \/dev\/null\r\nif [ $? -eq 0 ];then\r\n        echo \"Include conf\/extra\/httpd-vhosts.conf\" >> $install_dir\/conf\/httpd.conf\r\nfi\r\n#\u914d\u7f6e\u865a\u62df\u4e3b\u673a\r\ncat > $install_dir\/conf\/extra\/httpd-vhosts.conf <<\/eof>\r\n    DocumentRoot \"$install_dir\/htdocs\/zhuawawa.example.com\"\r\n    ServerName zhuawawa.example.com\r\n    ErrorLog \"logs\/zhuawawa.example.com-error_log\"\r\n    CustomLog \"logs\/zhuawawa.example.com-access_log\" common\r\n\r\nEOF\r\n#\u6dfb\u52a0\u9632\u706b\u5899\u89c4\u5219\r\nfirewall-cmd --add-rich-rule 'rule family=ipv4 source address=0.0.0.0\/0 port port=80 protocol=tcp accept' --permanent &> \/dev\/null\r\nfirewall-cmd --reload\r\n#\u521b\u5efa\u7f51\u7ad9\u5b58\u653e\u76ee\u5f55\r\nmkdir -p $install_dir\/htdocs\/zhuawawa.example.com\r\ncp -r files\/zhuawawa\/* $install_dir\/htdocs\/zhuawawa.example.com\r\n \r\n#\u91cd\u542fhttpd\r\nsystemctl restart httpd\r\n#\u67e5\u770b\u7aef\u53e3\r\nss -antl\r\n[root@localhost httpd]# ls\r\napache_lnh.sh  config.sh  files\r\n[root@localhost httpd]# ls files\/\r\napr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.53.tar.gz  httpd-2.4.54.tar.gz  zhuawawa(\u63d0\u524d\u5c06\u6e90\u7801\u5305\u89e3\u538b\u5230\u8fd9\u91cc)\r\n[root@localhost httpd]# ls files\/zhuawawa\/  (\u6b64\u5904\u662f\u6211\u89e3\u538b\u7684\u6e90\u7801\u5305)\r\nBattle_City  audio  css  images  index.html  js  tk.zip<\/eof><\/pre>\n

\u8fdb\u884c\u8bbf\u95ee:<\/p>\n

\"\"<\/p>\n

[root@localhost ~]# tar -Jcf httpd.tar.xz httpd\/  \/\/\u538b\u7f29\u811a\u672c\u5b58\u653e\u76ee\u5f55\r\n[root@localhost ~]# ls\r\nanaconda-ks.cfg  httpd  httpd.tar.xz<\/pre>\n

\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8e\u6e90\u7801\u5b89\u88c5apache\u811a\u672c\u90e8\u7f72\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"

[root@localhost ~]# ls anaconda-ks.cfg httpd.tar.xz [ro […]<\/p>\n","protected":false},"author":1479,"featured_media":166111,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-253883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=253883"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253883\/revisions"}],"predecessor-version":[{"id":253891,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253883\/revisions\/253891"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/166111"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=253883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=253883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=253883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}