Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #21: Use *.localhost domains instead of *.local #30

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions wsl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ config:
root_password: ""
system:
username: "{{ lookup('env', 'USER') }}"
# Add as many virtualhosts as needed - if a virtualhost already exists, it will not be created
# example.local is an example, you can remove it and add your own local domains
# Add as many virtualhosts as needed - if a virtualhost already exists, it will be skipped
# example.localhost is an example, you can remove it and add your own local domains
virtualhosts:
- "example.local"
- "example.localhost"
33 changes: 11 additions & 22 deletions wsl/os/almalinux9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,44 +102,33 @@ Now check if everything works by opening in your browser:
The installation is complete, your development environment is ready to use.


## Create virtual hosts
## Create virtualhosts
Move inside the directory `development/wsl`:

cd ~/development/wsl/

Using your preferred text editor, open `config.yml` and add the hosts that you want to create under the `virtualhosts` list. Save and close the file.
Using your preferred text editor, open `config.yml` and, under the `virtualhosts` key, enter the virtualhosts that you want to create, each on its own line.

Create the specified virtual hosts:
Already existing ones will be skipped, no need to comment or remove them.

ansible-playbook -i hosts create-virtualhost.yml --ask-become-pass

This will iterate over the list of `virtualhosts` configured in `config.yml` and will output a short summary with the results.

At this step, your virtual host is not yet accessible because first, you need to route the requests to your localhost.

**Run as administrator** any text editor and open file `C:\Windows\System32\drivers\etc\hosts` (if you don't see it, select `All files` from the file type selector).
Save and close the file.

For each item you placed in the `virtualhosts` list, add the below lines to the end of the file (make sure you replace `{virtualhost}` with your virtual host), then save and close the file.
Create the specified virtualhosts:

127.0.0.1 {virtualhost}
::1 {virtualhost}
ansible-playbook -i hosts create-virtualhost.yml --ask-become-pass

Example:
This will iterate over the list of configured `virtualhosts` and will output a short summary with the results.

127.0.0.1 example.local
::1 example.local
127.0.0.1 example2.local
::1 example2.local
Your virtualhost should be accessible and ready to use.

Your virtual host should be accessible and ready to use.
You will install your project under the `html` directory of your project, for example: `/var/www/example.localhost/html`.

You will install your project under the `html` directory of your project, for example: `/var/www/example.local/html`.
The virtualhost's document root is set to the `public` directory of the above location, for example `/var/www/example.local/html/public`.
The virtualhost's document root is set to the `public` directory of the above location, for example `/var/www/example.localhost/html/public`.

**Note**:
* In order to run your installed projects, you need to start AlmaLinux 9 first.
* If you work with virtualhosts, your projects are created under `/var/www/`.
* You can still run PHP scripts under the default Apache project directory, located at `/var/www/html/`.
* If you encounter write permission issues, see [this guide](FAQ.md#how-do-i-fix-common-permission-issues).
* We install PHP 8.1 by default. If you need a different version, see [this guide](FAQ.md#how-do-i-switch-to-a-different-version-of-php).
* We install PHP 8.2 by default. If you need a different version, see [this guide](FAQ.md#how-do-i-switch-to-a-different-version-of-php).
* We install NodeJS 18 by default. If you need a different version, see [this guide](FAQ.md#how-do-i-switch-to-a-different-version-of-nodejs).
6 changes: 3 additions & 3 deletions wsl/os/almalinux9/roles/php/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Install PHP 8.1
command: dnf module install php:remi-8.1 -y
- name: Enable and start PHP 8.1
- name: Install PHP 8.2
command: dnf module install php:remi-8.2 -y
- name: Enable and start PHP 8.2
command: systemctl enable --now php-fpm
- name: Create PHP info file
template:
Expand Down