文件操作 - apache-rebuild.sh
返回文件管理
返回主菜单
删除本文件
文件: /usr/local/src/apache-rebuild.sh
编辑文件内容
#!/bin/bash #if [[ `cat /etc/fstab | grep -E "tmp.*noexec"` != "" ]]; then mount -o remount,exec /tmp >/dev/null 2>&1 ; fi arch=$(uname -m) pubip=`curl -s http://centos-webpanel.com/webpanel/main.php?app=showip` # CONFIGURE MIRRORS HERE version='2.4.57' apachesource="http://dl1.centos-webpanel.com/files/apache/httpd-$version.tar.gz" # Dependency installer # Dependency installer yum -y install openssl-devel apr-util-devel apr-devel apr apr-util yum -y install libuuid-devel yum -y install perl-core gcc make zlib-devel # ============================================================================== # AUTOMATIC OPENSSL 1.1.1 CHECK & INSTALLATION # ============================================================================== if [ ! -x "/usr/local/openssl/bin/openssl" ]; then echo "==================================================================" echo "[BUILDER] Custom OpenSSL 1.1.1 not found. Installing now..." echo "==================================================================" if [ -f "/root/install_openssl.sh" ]; then bash /root/install_openssl.sh else cd /usr/local/src wget -q https://www.openssl.org/source/openssl-1.1.1w.tar.gz rm -rf openssl-1.1.1w tar -xzf openssl-1.1.1w.tar.gz cd openssl-1.1.1w ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib-dynamic >/dev/null 2>&1 make -j$(nproc) >/dev/null 2>&1 make install >/dev/null 2>&1 echo "/usr/local/openssl/lib" > /etc/ld.so.conf.d/openssl111.conf ldconfig fi echo "[BUILDER] OpenSSL 1.1.1 installation completed." fi # ============================================================================== if [ -f /usr/local/apache/conf/httpd.conf ]; then cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf-cwpsave ; fi test -h /usr/local/src/apache-build || rm -rf /usr/local/src/apache-build mkdir -p /usr/local/src/apache-build cd /usr/local/src/apache-build wget -q $apachesource tar -xf httpd-$version.tar.gz chown -R root:root httpd-$version/ cd httpd-$version/ # Install Patch - this are patches for version 2.4.26+ wget -q "http://dl1.centos-webpanel.com/files/apache/patch/suexec.patch" /usr/bin/patch -p1 < suexec.patch ./configure --enable-so --prefix=/usr/local/apache --enable-unique-id --enable-ssl=shared --with-ssl=/usr/local/openssl --enable-rewrite --enable-deflate --enable-suexec --with-suexec-docroot=/home --with-suexec-caller=nobody --with-suexec-logfile=/usr/local/apache/logs/suexec_log --enable-asis --enable-filter --with-pcre --with-apr=/usr/bin/apr-1-config --with-apr-util=/usr/bin/apu-1-config --enable-headers --enable-expires --enable-proxy --enable-rewrite --enable-userdir configurecheck=$? if [ $configurecheck -eq 0 ];then rm -f /usr/local/apache/conf/httpd.conf fi make clean if [ -e "/usr/bin/nproc" ];then make -j `/usr/bin/nproc` else make fi make install mkdir -p /usr/local/apache/conf.d touch /usr/local/apache/conf.d/empty.conf if [[ "`grep ExtendedStatus /usr/local/apache/conf/httpd.conf 2>/dev/null`" == "" ]]; then echo "ExtendedStatus On" >> /usr/local/apache/conf/httpd.conf echo "Include /usr/local/apache/conf/sharedip.conf" >> /usr/local/apache/conf/httpd.conf echo "Include /usr/local/apache/conf.d/*.conf" >> /usr/local/apache/conf/httpd.conf fi if [[ "`grep ':8181' /usr/local/apache/conf.d/vhosts.conf 2> /dev/null`" != "" ]]; then sed -i "s/^.*Listen 80$/Listen 8181/" /usr/local/apache/conf/httpd.conf sed -i "s/:80/:8181/" /usr/local/apache/conf/sharedip.conf fi sed -i "s|DirectoryIndex index.html|DirectoryIndex index.php index.html index.htm|g" /usr/local/apache/conf/httpd.conf sed -i "0,/^\([[:blank:]]*\)DirectoryIndex.*$/ s//\1 DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html/" /usr/local/apache/conf/httpd.conf cat > /usr/local/apache/conf/sharedip.conf <<EOF <VirtualHost $pubip:80> ServerName $pubip DocumentRoot /usr/local/apache/htdocs ServerAdmin info@centos-webpanel.com <IfModule mod_suphp.c> suPHP_UserGroup nobody nobody </IfModule> <Proxy "*"> <IfModule mod_security2.c> SecRuleEngine Off </IfModule> </Proxy> RewriteEngine On RewriteCond %{HTTP_HOST} !^$pubip\$ RewriteCond %{HTTP_HOST} ^webmail. RewriteRule ^/(.*) http://%{HTTP_HOST}:2095/\$1 [P] </VirtualHost> <Directory "/"> AllowOverride All Require all granted </Directory> EOF sed -i "s|User daemon|User nobody|g" /usr/local/apache/conf/httpd.conf sed -i "s|Group daemon|Group nobody|g" /usr/local/apache/conf/httpd.conf sed -i "s|.*modules/libphp5.so.*||g" /usr/local/apache/conf/httpd.conf sed -i "s|.*httpd-userdir.conf.*|Include conf/extra/httpd-userdir.conf|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule userdir_module modules.*$|LoadModule userdir_module modules/mod_userdir.so|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule unique_id_module modules.*$|LoadModule unique_id_module modules/mod_unique_id.so|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule rewrite_module modules.*$|LoadModule rewrite_module modules/mod_rewrite.so|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule proxy_module modules.*$|LoadModule proxy_module modules/mod_proxy.so|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule proxy_connect_module modules.*$|LoadModule proxy_connect_module modules/mod_proxy_connect.so|" /usr/local/apache/conf/httpd.conf sed -i "s|#LoadModule proxy_http_module modules.*$|LoadModule proxy_http_module modules/mod_proxy_http.so|" /usr/local/apache/conf/httpd.conf mkdir -p /usr/local/apache/conf.d cd /usr/local/apache/bin/ ldconfig #ADDITIONAL_CONFIGURATION if [ ! -e "/usr/local/apache/conf.d/domain-redirects.conf" ];then cat > /usr/local/apache/conf.d/domain-redirects.conf <<EOF RewriteEngine on Alias /myadmin /usr/local/apache/htdocs/phpMyAdmin Alias /MyAdmin /usr/local/apache/htdocs/phpMyAdmin Alias /phpmyadmin /usr/local/apache/htdocs/phpMyAdmin Alias /phpMyAdmin /usr/local/apache/htdocs/phpMyAdmin Alias /webmail /usr/local/apache/htdocs/roundcube Alias /WebMail /usr/local/apache/htdocs/roundcube Alias /roundcube /usr/local/apache/htdocs/roundcube Alias /webftp /usr/local/apache/htdocs/webftp_simple Alias /WebFTP /usr/local/apache/htdocs/webftp_simple Alias /webftp_simple /usr/local/apache/htdocs/webftp_simple EOF fi cat > /usr/local/apache/conf.d/system-redirects.conf <<EOF Redirect permanent /myadmin http://$pubip:2030/pma Redirect permanent /MyAdmin http://$pubip:2030/pma Redirect permanent /phpmyadmin http://$pubip:2030/pma Redirect permanent /phpMyAdmin http://$pubip:2030/pma Redirect permanent /kpanel http://$pubip:2030/ Redirect permanent /cwp http://$pubip:2082/ Redirect permanent /isp http://$pubip:2030/ Redirect permanent /cpanel http://$pubip:2082/ Redirect permanent /scwp https://$pubip:2083/ Redirect permanent /controlpanel http://$pubip:2082/ Redirect permanent /securecontrolpanel https://$pubip:2083/ Redirect permanent /securewhm https://$pubip:2031/ Redirect permanent /whm http://$pubip:2030/ EOF if [[ ! -z "`grep ':8181' /usr/local/apache/conf.d/vhosts/*.conf 2> /dev/null`" ]]; then sed -i "s/^.*Listen 80$/Listen 8181/" /usr/local/apache/conf/httpd.conf sed -i "s/:80/:8181/" /usr/local/apache/conf/sharedip.conf fi if [[ ! -e "/usr/local/apache/conf.d/vhosts/" ]]; then mkdir -p /usr/local/apache/conf.d/vhosts/ fi if [[ ! -e "/usr/local/apache/domlogs/" ]]; then mkdir -p /usr/local/apache/domlogs/ fi if [ ! -e "/usr/local/apache/conf.d/vhosts.conf" ];then cat > /usr/local/apache/conf.d/vhosts.conf <<EOF IncludeOptional /usr/local/apache/conf.d/vhosts/*.conf EOF fi if [[ -z `grep "LogFormat.*\"%b\".*bytes" /usr/local/apache/conf/httpd.conf` ]];then sed -i '0,/ LogFormat/s// LogFormat \"%b\" bytes\n&/' /usr/local/apache/conf/httpd.conf sed -i "s/LogFormat \"%h/LogFormat \"%a/g" /usr/local/apache/conf/httpd.conf fi if [[ ! -z `grep "you@example.com" /usr/local/apache/conf/httpd.conf` ]];then sed -i 's/you@example.com/root@localhost/g' /usr/local/apache/conf/httpd.conf fi service httpd restart echo "Apache Rebuild Completed" echo /usr/local/cwp/php71/bin/php /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications/cli.php --level="info" --subject="Apache Re-Build INFO" --message="Apache Re-Build task completed, please check the log for more details. Click <a title='Apache Re-Build task LOG' href='index.php?module=file_editor&file=/var/log/apache-rebuild.log'>here</a> to check it." test -h /usr/local/src/apache-build || rm -Rf /usr/local/src/apache-build
修改文件时间
将文件时间修改为当前时间的前一年
删除文件