How to install Apache with source code installation in Centos 7
Run the following commands (make sure that you have the super user privileges and should have necessary compilers available in the system)
# yum install wget gcc pcre-devel openssl-devel
# cd /usr/local/src/
Download latest version of Apache from http://www.apache.org/
# wget http://ftp.piotrkosoft.net/pub/mirrors/ftp.apache.org//httpd/httpd-2.4.20.tar.gz
# wget http://ftp.ps.pl/pub/apache//apr/apr-1.5.2.tar.gz
# wget http://ftp.ps.pl/pub/apache//apr/apr-util-1.5.4.tar.gz
# tar -zxvf httpd-2.4.20.tar.gz
# tar -zxvf apr-util-1.5.4.tar.gz
# tar -zxvf apr-1.5.2.tar.gz
# cp -r apr-1.5.2 httpd-2.4.20/srclib/apr
# cp -r apr-util-1.5.4 httpd-2.4.20/srclib/apr-util
# cd httpd-2.4.20
# ./configure --enable-ssl --enable-so --with-included-apr --with-mpm=event --with-mysql=/usr/local/mysql/
# make
# make install
# groupadd www
# useradd -G www -r apache
# chown -R apache:www /usr/local/apache2/
# mkdir /var/www
# chown -R apache:www /var/www
# chmod -R 775 /var/www
# cd /usr/local/apache2/conf
# vi httpd.conf
Make sure that ServerRoot is the same as location where You installed apache.
ServerRoot "/usr/local/apache2"
Port by default is set to 80. We will change that later on when we will add reversed proxy
Listen 80
After that set user and group we created previously.
# user apache
# group www
Set ServerName to whatever You want, it will prevent warning when apache will start
ServerName apache
Change
<Directory />
AllowOverride none
Require all denied
</Directory>
To
<Directory "/var/www">
Options -Indexes
AllowOverride none
Require all denied
</Directory>
Next is DocumentRoot, set it to /var/www
DocumentRoot "/var/www"
<Directory "/var/www">
In <Driectory “/var/www” block set Options to:
Options -Indexes -FollowSymLinks -Includes
AllowOverride All
Save the file and exit!
Now it’s finally the time to run httpd server. Procedure is easy, but it can be even easier.
# cd /usr/local/apache2/bin
# ./apachectl start
# ps aux | grep apache | grep -v apache
# chmod +x /etc/init.d/httpd
Run the following commands (make sure that you have the super user privileges and should have necessary compilers available in the system)
# yum install wget gcc pcre-devel openssl-devel
# cd /usr/local/src/
Download latest version of Apache from http://www.apache.org/
# wget http://ftp.piotrkosoft.net/pub/mirrors/ftp.apache.org//httpd/httpd-2.4.20.tar.gz
# wget http://ftp.ps.pl/pub/apache//apr/apr-1.5.2.tar.gz
# wget http://ftp.ps.pl/pub/apache//apr/apr-util-1.5.4.tar.gz
# tar -zxvf httpd-2.4.20.tar.gz
# tar -zxvf apr-util-1.5.4.tar.gz
# tar -zxvf apr-1.5.2.tar.gz
# cp -r apr-1.5.2 httpd-2.4.20/srclib/apr
# cp -r apr-util-1.5.4 httpd-2.4.20/srclib/apr-util
# cd httpd-2.4.20
# ./configure --enable-ssl --enable-so --with-included-apr --with-mpm=event --with-mysql=/usr/local/mysql/
# make
# make install
# groupadd www
# useradd -G www -r apache
# chown -R apache:www /usr/local/apache2/
# mkdir /var/www
# chown -R apache:www /var/www
# chmod -R 775 /var/www
# cd /usr/local/apache2/conf
# vi httpd.conf
Make sure that ServerRoot is the same as location where You installed apache.
ServerRoot "/usr/local/apache2"
Port by default is set to 80. We will change that later on when we will add reversed proxy
Listen 80
After that set user and group we created previously.
# user apache
# group www
Set ServerName to whatever You want, it will prevent warning when apache will start
ServerName apache
Change
<Directory />
AllowOverride none
Require all denied
</Directory>
To
<Directory "/var/www">
Options -Indexes
AllowOverride none
Require all denied
</Directory>
Next is DocumentRoot, set it to /var/www
DocumentRoot "/var/www"
<Directory "/var/www">
In <Driectory “/var/www” block set Options to:
Options -Indexes -FollowSymLinks -Includes
AllowOverride All
Save the file and exit!
Now it’s finally the time to run httpd server. Procedure is easy, but it can be even easier.
# cd /usr/local/apache2/bin
# ./apachectl start
# ps aux | grep apache | grep -v apache
# chmod +x /etc/init.d/httpd
No comments:
Post a Comment