Tutorial guides how to install Apache and PHP with Puppet modules using Linux. I’m using Xubuntu 12.04.03 32bit. Puppet is great way to handle several computers from one computer.
In this tutorial there are two modules. First module is installing Apache. Second module is installing Apache2 and PHP. After both modules there are explanation how to test modules.
Add package, service and files in to init.pp. Package is installing Apache. Files will create symlinks. This is obligatory if you want to use user directories. Files modify a2enmod so it’s enabling userdirs. When Apache is installed and symlinks are created. Service is checking your Apache is really started and running. If Apache isn’t running service will start it.
Apply apache2 module.
Now you have module that will install Apache, if it isn’t installed. Enables user directories, if those aren’t enabled. And will make sure that Apache is running.
Testing Apache
Let’s try your module is really working. Let’s make public_html folder and add to there example index.html file
Open firefox
Now we are successfully used Puppet modules to install Apache. In second module we are installing Apache and PHP.
Installing Apache and PHP
Now we create new module. Add needed folders and init.pp
Create module that makes same things that first module, but also installs php5 and libapache2-mod-php5. Then module enables php5 working in user directories.
Create templates folder and php5.conf.erb file there what overwrites your php5.conf file. New php5.conf file enables php5 to users. Without making these configure changes to php5.conf php5 isn’t working in user directories.
Apply phpwithapache module
Testing PHP
Modify index.html to index.php what is in your public_html and create example php page
Test your index.php
Conclusion
Now you have created two Puppet modules. First module installed Apache2. Second module installed Apache and PHP. Of course we also tested that Apache and PHP was really working correctly.
Here is what your folder/file tree should look like