Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
lempstack/include/apache.sh at main · linuxeye/lempstack · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
linuxeye
lempstack
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
lempstack
/
include
/
apache.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
184 lines (172 loc) · 8.38 KB
main
Breadcrumbs
lempstack
/
include
/
apache.sh
Copy path
Top
File metadata and controls
Code
Blame
184 lines (172 loc) · 8.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!
/bin/bash
#
Author: yeho <lj2007331 AT gmail.com>
#
BLOG: https://linuxeye.com
Install_Apache
() {
pushd
${current_dir}
/src
>
/dev/null
tar xzf pcre-
${pcre_ver}
.tar.gz
pushd
pcre-
${pcre_ver}
>
/dev/null
./configure
make -j
${THREAD}
&&
make install
popd
>
/dev/null
id -g
${run_group}
>
/dev/null
2>&1
[
$?
-ne
0 ]
&&
groupadd
${run_group}
id -u
${run_user}
>
/dev/null
2>&1
[
$?
-ne
0 ]
&&
useradd -g
${run_group}
-M -s /sbin/nologin
${run_user}
tar xzf httpd-
${apache_ver}
.tar.gz
#
install apr
if
[
!
-e
"
${apr_install_dir}
/bin/apr-1-config
"
]
;
then
tar xzf apr-
${apr_ver}
.tar.gz
pushd
apr-
${apr_ver}
>
/dev/null
./configure --prefix=
${apr_install_dir}
make -j
${THREAD}
&&
make install
popd
>
/dev/null
rm -rf apr-
${apr_ver}
fi
#
install apr-util
if
[
!
-e
"
${apr_install_dir}
/bin/apu-1-config
"
]
;
then
tar xzf apr-util-
${apr_util_ver}
.tar.gz
pushd
apr-util-
${apr_util_ver}
>
/dev/null
./configure --prefix=
${apr_install_dir}
--with-apr=
${apr_install_dir}
make -j
${THREAD}
&&
make install
popd
>
/dev/null
rm -rf apr-util-
${apr_util_ver}
fi
#
install nghttp2
if
[
!
-e
"
/usr/local/lib/libnghttp2.so
"
]
;
then
tar xzf nghttp2-
${nghttp2_ver}
.tar.gz
pushd
nghttp2-
${nghttp2_ver}
>
/dev/null
./configure
make -j
${THREAD}
&&
make install
popd
>
/dev/null
[
-z
"
`
grep /usr/local/lib /etc/ld.so.conf.d/
*
.conf
`
"
]
&&
echo
'
/usr/local/lib
'
>
/etc/ld.so.conf.d/local.conf
ldconfig
rm -rf nghttp2-
${nghttp2_ver}
fi
pushd
httpd-
${apache_ver}
>
/dev/null
LDFLAGS=-ldl ./configure --prefix=
${apache_install_dir}
--enable-mpms-shared=all --with-pcre --with-apr=
${apr_install_dir}
--with-apr-util=
${apr_install_dir}
--enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-remoteip --enable-expires --enable-static-support --enable-suexec --enable-mods-shared=most --enable-nonportable-atomics=yes --enable-ssl --with-ssl --enable-http2 --with-nghttp2=/usr/local
make -j
${THREAD}
&&
make install
popd
>
/dev/null
unset
LDFLAGS
if
[
-e
"
${apache_install_dir}
/bin/httpd
"
]
;
then
echo
"
${CSUCCESS}
Apache installed successfully!
${CEND}
"
rm -rf httpd-
${apache_ver}
pcre-
${pcre_ver}
else
rm -rf
${apache_install_dir}
echo
"
${CFAILURE}
Apache install failed, Please contact the author!
${CEND}
"
&&
grep -Ew
'
NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME
'
/etc/os-release
kill
-9
$$
;
exit
1
;
fi
[
-z
"
`
grep ^
'
export PATH=
'
/etc/profile
`
"
]
&&
echo
"
export PATH=
${apache_install_dir}
/bin:
\$
PATH
"
>>
/etc/profile
[
-n
"
`
grep ^
'
export PATH=
'
/etc/profile
`
"
-a
-z
"
`
grep
${apache_install_dir}
/etc/profile
`
"
]
&&
sed -i
"
s@^export PATH=\(.*\)@export PATH=
${apache_install_dir}
/bin:\1@
"
/etc/profile
.
/etc/profile
/bin/cp ../init.d/httpd.service /lib/systemd/system/
sed -i
"
s@/usr/local/apache@
${apache_install_dir}
@g
"
/lib/systemd/system/httpd.service
systemctl
enable
httpd
sed -i
"
s@^User daemon@User
${run_user}
@
"
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@^Group daemon@Group
${run_group}
@
"
${apache_install_dir}
/conf/httpd.conf
if
[[
!
${nginx_option}
=~
^[1-3]$ ]]
&&
[
!
-e
"
${web_install_dir}
/sbin/nginx
"
]
;
then
sed -i
'
s/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/
'
${apache_install_dir}
/conf/httpd.conf
TMP_PORT=80
elif
[[
${nginx_option}
=~
^[1-3]$ ]]
||
[
-e
"
${web_install_dir}
/sbin/nginx
"
]
;
then
sed -i
'
s/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/
'
${apache_install_dir}
/conf/httpd.conf
sed -i
'
s@^Listen.*@Listen 127.0.0.1:88@
'
${apache_install_dir}
/conf/httpd.conf
TMP_PORT=88
fi
sed -i
"
s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps@
"
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@
"
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_proxy.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_proxy_fcgi.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_suexec.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_vhost_alias.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_rewrite.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_deflate.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_expires.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_ssl.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -ri
'
s@^#(LoadModule.*mod_http2.so)@\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -i
'
s@DirectoryIndex index.html@DirectoryIndex index.html index.php@
'
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@^DocumentRoot.*@DocumentRoot
\"
${wwwroot_dir}
/default
\"
@
"
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@^<Directory
\"
${apache_install_dir}
/htdocs
\"
>@<Directory
\"
${wwwroot_dir}
/default
\"
>@
"
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@
"
${apache_install_dir}
/conf/httpd.conf
if
[
"
${apache_mpm_option}
"
==
'
2
'
]
;
then
sed -ri
'
s@^(LoadModule.*mod_mpm_event.so)@#\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -i
'
s@^#LoadModule mpm_prefork_module@LoadModule mpm_prefork_module@
'
${apache_install_dir}
/conf/httpd.conf
elif
[
"
${apache_mpm_option}
"
==
'
3
'
]
;
then
sed -ri
'
s@^(LoadModule.*mod_mpm_event.so)@#\1@
'
${apache_install_dir}
/conf/httpd.conf
sed -i
'
s@^#LoadModule mpm_worker_module@LoadModule mpm_worker_module@
'
${apache_install_dir}
/conf/httpd.conf
fi
#
logrotate apache log
cat
>
/etc/logrotate.d/apache
<<
EOF
${wwwlogs_dir}
/*apache.log {
daily
rotate 5
missingok
dateext
compress
notifempty
sharedscripts
postrotate
[ -e /var/run/httpd.pid ] && kill -USR1
\`
cat /var/run/httpd.pid
\`
endscript
}
EOF
mkdir
${apache_install_dir}
/conf/vhost
[
"
${apache_mode_option}
"
!=
'
2
'
]
&&
Apache_fcgi=
$(
echo -e
"
<Files ~ (
\\
.user.ini|
\\
.htaccess|
\\
.git|
\\
.svn|
\\
.project|LICENSE|README.md)
\$
>\n Order allow,deny\n Deny from all\n </Files>\n <FilesMatch
\\
.php
\$
>\n SetHandler
\"
proxy:unix:/dev/shm/php-cgi.sock|fcgi://localhost
\"
\n </FilesMatch>
"
)
cat
>
${apache_install_dir}
/conf/vhost/0.conf
<<
EOF
<VirtualHost *:
$TMP_PORT
>
ServerAdmin admin@example.com
DocumentRoot "
${wwwroot_dir}
/default"
ServerName 127.0.0.1
ErrorLog "
${wwwlogs_dir}
/error_apache.log"
CustomLog "
${wwwlogs_dir}
/access_apache.log" common
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
\$
>
Order allow,deny
Deny from all
</Files>
${Apache_fcgi}
<Directory "
${wwwroot_dir}
/default">
SetOutputFilter DEFLATE
Options FollowSymLinks ExecCGI
Require all granted
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
EOF
cat
>>
${apache_install_dir}
/conf/httpd.conf
<<
EOF
<IfModule mod_headers.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
<FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)
\$
">
RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)
\$
" "
\$
1
\$
2"
Header edit "ETag" "^(.*)-gzip(.*)
\$
" "
\$
1
\$
2"
</FilesMatch>
DeflateCompressionLevel 6
SetOutputFilter DEFLATE
</IfModule>
ProtocolsHonorOrder On
PidFile /var/run/httpd.pid
ServerTokens ProductOnly
ServerSignature Off
Include conf/vhost/*.conf
EOF
[
"
${nginx_option}
"
==
'
4
'
-a
!
-e
"
${web_install_dir}
/sbin/nginx
"
]
&&
echo
'
Protocols h2 http/1.1
'
>>
${apache_install_dir}
/conf/httpd.conf
if
[
"
${nginx_option}
"
!=
'
4
'
-o
-e
"
${web_install_dir}
/sbin/nginx
"
]
;
then
cat
>
${apache_install_dir}
/conf/extra/httpd-remoteip.conf
<<
EOF
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
EOF
sed -i
"
s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@
"
${apache_install_dir}
/conf/httpd.conf
sed -i
"
s@LogFormat
\"
%h %l@LogFormat
\"
%h %a %l@g
"
${apache_install_dir}
/conf/httpd.conf
fi
ldconfig
sed -i
"
s@^export LD_LIBRARY_PATH.*@export LD_LIBRARY_PATH=/usr/local/lib:
\$
LD_LIBRARY_PATH@
"
${apache_install_dir}
/bin/envvars
systemctl start httpd
popd
>
/dev/null
}
You can’t perform that action at this time.