Code Monkey home page Code Monkey logo

script-for-apache2's Introduction

Apache2 Configuration with YAML Script


Result


sys1Websites

This YAML script is designed to manage the configuration of an Apache2 server on a given host. It handles the configuration of all aspects related to the provided domain names.

Before using this script, ensure that you have ansible installed on your machine and also have the root password for the host where you want to configure Apache2. Additionally, make sure that the server has openssh-server installed.

You can also do it with ssh keys if you want,for that, you should read this file first.

1. Server configuration

  • Look for the line containing the directive PermitRootLogin on the file /etc/ssh/sshd_config. If it is commented out (starts with a #), remove the # symbol at the beginning of the line and set it to yes : PermitRootLogin yes.

If the PermitRootLogin line is already present and set to no, change it to yes.

  • Then, restart ssh server with sudo sytemctl restart ssh then you should be able to log in as the root user using SSH.

2. Get started

  • Set your server's ip on the file hosts like this :
192.168.0.127
  • Put all your domain names in the domains file:
www.example.com
abd.google.com
xyz.node.xyz

3. Option1 : Launching the script with ssh keys

  • You can launch the script with the following command if you use an SSH key to connect as root on the server and not with a root password
ansible-playbook -i hosts --private-key=your_private_ssh_key script.yaml
  • If you have set a passphrase for the SSH keys:
ansible-playbook -i hosts --private-key=your_private_ssh_key --ask-pass script.yaml
# The --ask-pass option is added
  • Replace your_private_ssh_key with your private key.

3. Option2 : Launching the script with root password

  • You need to install sshpass on your local machine (the machine from which you will run the script.yaml playbook) to enable password-based SSH authentication.

  • Make sure that the host's fingerprint is already configured. You can do this manually with the following command:

ssh <host>
#replace <host> with the IP address of the server
  • Now you can run script.yaml with the following command :
ansible-playbook -i hosts script.yaml -k
  • It will prompt for the SSH pass, which is the root password on the host (server).

4. Accessing all domain names

Now you just need to configure a DNS server or add the following lines to the /etc/hosts file on each machine from which you want to access the domain names:

#server         domain
192.168.43.30   www.example.com
192.168.43.30   abd.google.com
192.168.43.30   xyz.node.xyz

script-for-apache2's People

Contributors

rickaprincy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.