Install Web Services - Apache
Server OS: CentOS 6.5 64bits
yum install httpd
Create a VirtualHost
Create a VirtualHost point to website in /var/www/html/linux.com
mkdir /var/www/html/linux.com
vi /var/www/html/linux.com/index.html
With content
Welcome to LINUX Class.
Create a VirtualHost file name linux.com.conf in: /etc/httpd/conf.d/
vi /etc/httpd/conf.d/linux.com.conf
With content:
<VirtualHost *:80>
ServerAdmin ken.vannakk@gmail.com
DocumentRoot /var/www/html/linux.com
ServerName linux.com
ServerAlias www.linux.com
ServerAlias linux.org
ServerAlias www.linux.org
ErrorLog /var/log/httpd/linux.com.error_log
CustomLog /var/log/httpd/linux.com-access_log common
</VirtualHost>
Add Server Name at the end of file in httpd.conf
vi /etc/httpd/conf/httpd.conf
With content
ServerName 127.0.0.1
Start Apache
/etc/init.d/httpd start
Allow port 80 in iptables
vi /etc/sysconfig/iptables
Add this line:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Reload iptables
/etc/init.d/iptables reload
Access to website:
Authentication with Apache
Crate Apache user name: userlinux
htpasswd -c /var/www/html/userpass userlinux
Enter password,
Update VirtualHost
vi /etc/httpd/conf.d/linux.com.conf
<VirtualHost *:80>
ServerAdmin ken.vannakk@gmail.com
DocumentRoot /var/www/html/linux.com
ServerName linux.com
ServerAlias www.linux.com
ServerAlias linux.org
ServerAlias www.linux.org
<Location />
Deny from all
AuthUserFile /var/www/html/userpass
AuthName "Welcome to LINUX Class"
AuthType Basic
Satisfy Any
require valid-user
</Location>
ErrorLog /var/log/httpd/linux.com.error_log
CustomLog /var/log/httpd/linux.com-access_log common
</VirtualHost>
Reload Apache
/etc/init.d/httpd reload
Access to that site again:
Login with the username and password we create
Finished,
#CentOS #Apache #Vannakk
No comments:
Post a Comment