Install Apache server.
First, clean-up yum:
[root@alpha ~]# yum clean all Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Cleaning repos: base extras updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors
Update our packages:
[root@alpha ~]# yum -y update Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 156 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 166 kB 00:00:00 (3/4): updates/7/x86_64/primary_db | 6.0 MB 00:00:00 (4/4): base/7/x86_64/primary_db | 5.7 MB 00:00:00 Determining fastest mirrors * base: mirror.airenetworks.es * extras: mirror.airenetworks.es * updates: mirror.airenetworks.es No packages marked for update
Install Apache:
[root@alpha ~]# yum -y install httpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.airenetworks.es * extras: mirror.airenetworks.es * updates: mirror.airenetworks.es Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-67.el7.centos.6 will be installed --> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos.6 for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================== Package Arch Version Repository Size =============================================================================================================================== Installing: httpd x86_64 2.4.6-67.el7.centos.6 updates 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 updates 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-67.el7.centos.6 updates 88 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary =============================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 3.0 M Installed size: 10 M Downloading packages: (1/5): apr-1.4.8-3.el7_4.1.x86_64.rpm | 103 kB 00:00:00 (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00 (3/5): httpd-tools-2.4.6-67.el7.centos.6.x86_64.rpm | 88 kB 00:00:00 (4/5): httpd-2.4.6-67.el7.centos.6.x86_64.rpm | 2.7 MB 00:00:00 (5/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------- Total 16 MB/s | 3.0 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-3.el7_4.1.x86_64 1/5 Installing : apr-util-1.5.2-6.el7.x86_64 2/5 Installing : httpd-tools-2.4.6-67.el7.centos.6.x86_64 3/5 Installing : mailcap-2.1.41-2.el7.noarch 4/5 Installing : httpd-2.4.6-67.el7.centos.6.x86_64 5/5 Verifying : mailcap-2.1.41-2.el7.noarch 1/5 Verifying : httpd-2.4.6-67.el7.centos.6.x86_64 2/5 Verifying : apr-util-1.5.2-6.el7.x86_64 3/5 Verifying : apr-1.4.8-3.el7_4.1.x86_64 4/5 Verifying : httpd-tools-2.4.6-67.el7.centos.6.x86_64 5/5 Installed: httpd.x86_64 0:2.4.6-67.el7.centos.6 Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 mailcap.noarch 0:2.1.41-2.el7 Complete! [root@alpha ~]#
Add to start:
[root@alpha ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@alpha ~]#
Create mtb18.costaflores.com folder:
[root@alpha ~]# cd /var/www/html/ [root@alpha html]# mkdir mtb18 [root@alpha html]# chown apache:apache mtb18/ -R [root@alpha html]#
Create VirtualHost file in Apache config:
[root@alpha ~]# cd /etc/httpd/conf.d/
[root@alpha conf.d]# vi website.mtb18.costaflores.com.conf
[root@alpha conf.d]#
<VirtualHost *:80> ServerName mtb18.costaflores.com DocumentRoot /var/www/html/mtb18/ CustomLog logs/mtb18.costaflores.com.log combined ErrorLog logs/mtb18.costaflores.com.error.log </VirtualHost>
Restart Apache server: (Apache start/stop/status/restart)
systemctl start httpd systemctl stop httpd systemctl status httpd systemctl restart httpd
Firewall Add ports:
[root@alpha ~]# firewall-cmd --permanent --add-port="80"/tcp success [root@alpha ~]# firewall-cmd --permanent --add-port="443"/tcp success
Reload firewall rules:
[root@alpha ~]# firewall-cmd --reload success
List rules:
[root@alpha ~]# su -c 'firewall-cmd --zone=public --list-all' public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client ssh ports: 80/tcp 443/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: [root@alpha ~]
Check Apache is listen in port 80:
[root@alpha ~]# netstat -anp |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22208/httpd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 10680/sshd tcp6 0 0 :::22 :::* LISTEN 10680/sshd unix 2 [ ] DGRAM 8480 1/systemd /run/systemd/notify unix 3 [ ] STREAM CONNECTED 34245 10680/sshd unix 3 [ ] STREAM CONNECTED 18000 484/systemd-journal /run/systemd/journal/stdout [root@alpha ~]#
Install nmap:
[root@alpha httpd]# yum install nmap Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirror.airenetworks.es * extras: mirror.airenetworks.es * updates: mirror.airenetworks.es Resolving Dependencies --> Running transaction check ---> Package nmap.x86_64 2:6.40-7.el7 will be installed --> Processing Dependency: nmap-ncat = 2:6.40-7.el7 for package: 2:nmap-6.40-7.el7.x86_64 --> Running transaction check ---> Package nmap-ncat.x86_64 2:6.40-7.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================================== Installing: nmap x86_64 2:6.40-7.el7 base 4.0 M Installing for dependencies: nmap-ncat x86_64 2:6.40-7.el7 base 201 k Transaction Summary =================================================================================================================================================================== Install 1 Package (+1 Dependent package) Total download size: 4.2 M Installed size: 17 M Is this ok [y/d/N]: y Downloading packages: (1/2): nmap-ncat-6.40-7.el7.x86_64.rpm | 201 kB 00:00:00 (2/2): nmap-6.40-7.el7.x86_64.rpm | 4.0 MB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 17 MB/s | 4.2 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:nmap-ncat-6.40-7.el7.x86_64 1/2 Installing : 2:nmap-6.40-7.el7.x86_64 2/2 Verifying : 2:nmap-ncat-6.40-7.el7.x86_64 1/2 Verifying : 2:nmap-6.40-7.el7.x86_64 2/2 Installed: nmap.x86_64 2:6.40-7.el7 Dependency Installed: nmap-ncat.x86_64 2:6.40-7.el7 Complete! [root@alpha httpd]#
Check what ports are listening for TCP connections from the network:
[root@alpha httpd]# nmap -sT -O localhost Starting Nmap 6.40 ( http://nmap.org ) at 2018-02-27 16:13 CET Nmap scan report for localhost (127.0.0.1) Host is up (0.00068s latency). Other addresses for localhost (not scanned): 127.0.0.1 Not shown: 998 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http Device type: general purpose Running: Linux 3.X OS CPE: cpe:/o:linux:linux_kernel:3 OS details: Linux 3.7 - 3.9 Network Distance: 0 hops OS detection performed. Please report any incorrect results at http://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 1.86 seconds [root@alpha httpd]#
Install "mod_ssl" module:
[root@alpha]# yum install mod_ssl Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/2): extras/7/x86_64/primary_db | 185 kB 00:00:00 (2/2): updates/7/x86_64/primary_db | 6.9 MB 00:00:00 Determining fastest mirrors * base: mirror.airenetworks.es * extras: mirror.airenetworks.es * updates: mirror.airenetworks.es Resolving Dependencies --> Running transaction check ---> Package mod_ssl.x86_64 1:2.4.6-67.el7.centos.6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: mod_ssl x86_64 1:2.4.6-67.el7.centos.6 updates 109 k Transaction Summary ======================================================================================================================================================================= Install 1 Package Total download size: 109 k Installed size: 224 k Is this ok [y/d/N]: y Downloading packages: mod_ssl-2.4.6-67.el7.centos.6.x86_64.rpm | 109 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:mod_ssl-2.4.6-67.el7.centos.6.x86_64 1/1 Verifying : 1:mod_ssl-2.4.6-67.el7.centos.6.x86_64 1/1 Installed: mod_ssl.x86_64 1:2.4.6-67.el7.centos.6 Complete! [root@alpha]#
Install Let's Encrypt Certificates:
[root@alpha ~]# yum -y install epel-release [root@alpha ~]# yum -y install yum-utils [root@alpha ~]# yum -y install certbot-apache
[root@alpha ~]# sudo certbot --apache Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org Which names would you like to activate HTTPS for? ------------------------------------------------------------------------------- 1: costaflores.com 2: ico.costaflores.com 3: mtb18.costaflores.com 4: openbravo.costaflores.com 5: openvino.costaflores.com 6: www.costaflores.com 7: martianwinefederation.org 8: www.martianwinefederation.org 9: openvino.org 10: www.openvino.org 11: theluckhunters.com 12: www.theluckhunters.com ------------------------------------------------------------------------------- Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 11 Obtaining a new certificate Performing the following challenges: http-01 challenge for theluckhunters.com Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/httpd/conf.d/website.theluckhunters.com-le-ssl.conf Deploying Certificate to VirtualHost /etc/httpd/conf.d/website.theluckhunters.com-le-ssl.conf Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. ------------------------------------------------------------------------------- 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. ------------------------------------------------------------------------------- Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 Redirecting vhost in /etc/httpd/conf.d/website.theluckhunters.com.conf to ssl vhost in /etc/httpd/conf.d/website.theluckhunters.com-le-ssl.conf ------------------------------------------------------------------------------- Congratulations! You have successfully enabled https://theluckhunters.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=theluckhunters.com ------------------------------------------------------------------------------- IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/theluckhunters.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/theluckhunters.com/privkey.pem Your cert will expire on 2018-10-03. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le [root@alpha ~]#
Uninstall Let's Encrypt Certificates:
[root@alpha ~]# certbot delete --cert-name theluckhunters.com
Install HAPROXY
[root@alpha ~]# yum -y install haproxy Installed: haproxy.x86_64 0:1.5.18-8.el7 Complete! [root@alpha ~]# [root@alpha ~]# cd /etc/haproxy/ [root@alpha haproxy]# mv haproxy.cfg haproxy.cfg.orig [root@alpha haproxy]#