Making users’ homepages work with Apache
I have previously made a folder under Salt’s srv directory called ‘salt’. Now I created a folder called ‘apache’ and inside it a file called ‘init.sls’.
sudo mkdir apache
already in the /srv/salt directory:
I created a default homepage: sudoedit default-index.html
Then I applied the state using: sudo salt ‘*’ sate.apply apache
Oh no! It doesn’t work. Why is that. I went to check up on my file and noticed that I had forgotten a few lines of code. Fixed that…
Applied the state again.
And now it works!
Trying to make PHP work on the users’ homepages
First I made a state called php.sls using code from Lauri Mattila as an example since he had gotten it to actually work.
So I made the state in order to test out whether it would work or not, since I’d had trouble with php when I tried installing it manually.
Got this error when I applied the state using: sudo salt ‘*’ state.apply apache/php
I realized I hadn’t edited the conf file, so I went and did that.
Unfortunately the same error persisted after this, so I moved on to another task and decided to let this problem simmer for now and come back to it later.
Name based virtual hosting for Apache
First I edited the hosts-file by adding this line: 127.0.0.1 test.com
Then I created a conf file for the virtual host.
Created an .sls -file which moves my new conf file to the right place and removes the default file.
Applied the state: sudo salt ‘*’ state.apply apache/virtualhost
And it works.
Automatically creating homepages for users
Created public_html.sls and index.html files under the srv/salt/apache directory.
– source: salt://apache/index.html
– makedirs: True
Applied the state.