April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Centos 6.7 apache2.4.x

Centos 6.7 apache2.4.x compile and install and configure virtual hosts, SSL access, user-based access control

apache2.4 new features

Loadable MPMs
At compile time can be made ??of a plurality of removable of MPM. The choice of MPM can also be configured at run time.

Event MPM
full support Event MPM. This is just test version of Apache 2.2.
Asynchronous support
better asynchronous read / write support in support of MPM and platforms.
Per-module and per-directory LogLevel configuration
LogLevel can be set different for different modules and directories.
On debug logging levels to increase the trace1 trace8 tracking method.
Per-Request configuration Sections
<If>, <ElseIf>, and <Else> block can be used in every request can be set on the configuration level.
General-purpose expression parser
new expression parser allows the instruction (eg SetEnvIfExpr, RewriteCond, Header, <If>, etc.)
using a common syntax to specify complex criteria.

KeepAliveTimeout in milliseconds
now in milliseconds (milliseconds) Set the connection holding time (KeepAliveTimeout).
NameVirtualHost directive is no longer needed, it has been deprecated.
Override Configuration
AllowOverrideList allow new directory (.htaccess allowed directory) a more fine-grained control.
Config file variables
can now define and use variables in the configuration file.

Reduced memory usage though adds many new features, version 2.4.x Apache was successfully reduced memory footprint (compared to 2.2.x version).

Ready to work

Before compiling still need to do some preparation. 1, if there apache2.2.x apache2.2.x then we need to deactivate and remove it before you start automatically on a server 2,
apache2.4.x dependent apr also requires version 1.4 or more, so before compiling further QPR need to compile high version 3, making apache2.4.x available boot startup scripts and configuration, etc.

yum groupinstall “Development tools” “Server Platform Development” -y

service httpd stop
chkconfig httpd off
chkconfig –list | grep httpd

Two, apr> = 1.4 version of the compiler

wget http://www.us.apache.org/dist//apr/apr-1.5.2.tar.gz
wget http://www.us.apache.org/dist//apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf apr-1.5.2.tar.gz

cd /root/software/apr-1.5.2
./configure –prefix=/usr/local/apr1.5.2
make && make install

cd /root/software/apr-util-1.5.4
./configure –prefix=/usr/local/aprutil154 –with-apr=/usr/local/apr1.5.2
make && make install

wget http://www.us.apache.org/dist//httpd/httpd-2.4.18.tar.gz
cd /root/software/httpd-2.4.18

./configure –prefix=/usr/local/apache2418 –sysconfdir=/etc/httpd2418 –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr1.5.2 –with-apr-util=/usr/local/aprutil154 –enable-mpms-shared=all –with-mpm=event –enable-modules=most
make  &&  make install

checking for pcre-config… false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@cluster1 httpd-2.4.18]#

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

yum install pcre-devel -y

echo “export PATH=/usr/local/apache2418/bin/:\$PATH”

/etc/profile.d/apache2418.sh

sed -i “$(awk ‘$1==”MANPATH”{i=NR}END{print i}’ /etc/man.config)a \MANPATH\tMANPATH /usr/local/apache2418/man” /etc/man.config

ln -s /usr/local/apache2418/include/ /usr/include/apache

[root@cluster1 ~]# man httpd

[root@cluster1 bin]# ./apachectl -v
Server version: Apache/2.4.18 (Unix)
Server built:   Jan 10 2016 22:52:22
[root@cluster1 bin]#

[root@cluster1 bin]# ss -utnl
Netid  State      Recv-Q Send-Q                                  Local Address:Port                                    Peer Address:Port
udp    UNCONN     0      0                                                   *:40459                                              *:*
udp    UNCONN     0      0                                                   *:935                                                *:*
udp    UNCONN     0      0                                           127.0.0.1:979                                                *:*
udp    UNCONN     0      0                                                   *:111                                                *:*
udp    UNCONN     0      0                                        192.168.1.60:123                                                *:*
udp    UNCONN     0      0                                           127.0.0.1:123                                                *:*
udp    UNCONN     0      0                                                   *:123                                                *:*
udp    UNCONN     0      0                                                  :::935                                               :::*
udp    UNCONN     0      0                                                  :::60761                                             :::*
udp    UNCONN     0      0                                                  :::111                                               :::*
udp    UNCONN     0      0                                                 ::1:123                                               :::*
udp    UNCONN     0      0                                                  :::123                                               :::*
tcp    LISTEN     0      128                                                 *:55775                                              *:*
tcp    LISTEN     0      128                                                :::111                                               :::*
tcp    LISTEN     0      128                                                 *:111                                                *:*
tcp    LISTEN     0      128                                                :::80                                                :::*
tcp    LISTEN     0      128                                                :::22                                                :::*
tcp    LISTEN     0      128                                                 *:22                                                 *:*
tcp    LISTEN     0      100                                               ::1:25                                                :::*
tcp    LISTEN     0      100                                         127.0.0.1:25                                                 *:*
tcp    LISTEN     0      128                                                :::38427                                             :::*
[root@cluster1 bin]# ss -utnl | grep 80
tcp    LISTEN     0      128                   :::80                   :::*
[root@cluster1 bin]#

for I in $(ps aux | grep [h]ttp |awk ‘{print$2}’); do kill -9 $I;done
for I in $(ps aux | grep [a]pache |awk ‘{print$2}’); do kill -9 $I;done

cp /usr/local/apache2418/bin/apachectl /etc/init.d/httpd

sed -i ‘/#!\/bin\/sh/a \# chkconfig: 35 85 15\n# description: Activates\/Deactivates Apache 2.4.18’ /etc/init.d/httpd

chkconfig –add httpd
chkconfig –list httpd

[root@cluster1 ~]# cat /etc/httpd2418/httpd.conf  | grep ‘^[^#]’ | grep -vE ‘^[[:space:]]+#’
ServerRoot “/usr/local/apache2418”
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
<IfModule !mpm_prefork_module>
</IfModule>
<IfModule mpm_prefork_module>
</IfModule>
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot “/usr/local/apache2418/htdocs”
<Directory “/usr/local/apache2418/htdocs”>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files “.ht*”>
Require all denied
</Files>
ErrorLog “logs/error_log”
LogLevel warn
<IfModule log_config_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined
LogFormat “%h %l %u %t \”%r\” %>s %b” common
<IfModule logio_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” combinedio
</IfModule>
CustomLog “logs/access_log” common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ “/usr/local/apache2418/cgi-bin/”
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory “/usr/local/apache2418/cgi-bin”>
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/httpd2418/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include /etc/httpd2418/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
[root@cluster1 ~]#

[root@cluster1 ~]#  cat /etc/httpd2418/extra/httpd-vhosts.conf | grep ‘^[^#]’
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “/usr/local/apache2418/docs/dummy-host.example.com”
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog “logs/dummy-host.example.com-error_log”
CustomLog “logs/dummy-host.example.com-access_log” common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot “/usr/local/apache2418/docs/dummy-host2.example.com”
ServerName dummy-host2.example.com
ErrorLog “logs/dummy-host2.example.com-error_log”
CustomLog “logs/dummy-host2.example.com-access_log” common
</VirtualHost>

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>