How it works...

This recipe sets up the initial Apache configuration parameters as constants and then defines two functions. In the remote_server() function, the usual Fabric environment parameters, for example, hosts, user, password, and so on, are placed.

The setup_vhost() function executes a series of privileged commands. First, it checks whether the website's document root path is already created using the exists() function. If it exists, it removes that path and creates it in the next step. Using chown, it ensures that the path is owned by the current user.

In the next step, it uploads a bare bone HTML file, index.html, to the document root path. After uploading the file, it reverts the permission of the files to the web server user.

After setting up the document root, the setup_vhost() function uploads the supplied vhost.conf file to the Apache site configuration path. Then, it sets its owner as the root user.

Finally, the script restarts the Apache service so that the configuration is activated. If the configuration is successful, you should see the sample output shown earlier when you open the URL, http://abc.remote-server.org/, in your browser.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.239.234