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 #16: Install Node.js and allow switching to different versions. #17

Merged
merged 1 commit into from
Feb 21, 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
105 changes: 68 additions & 37 deletions wsl/os/almalinux9/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
# Frequently Asked Questions


## How do I switch to PHP 7.4?

sudo dnf module switch-to php:remi-7.4 -y

## How do I switch to PHP 8.1?

sudo dnf module switch-to php:remi-8.1 -y

## How do I switch to PHP 8.2?

sudo dnf module switch-to php:remi-8.2 -y


## How do I fix common permission issues?
If running your project you encounter some permission issues, follow the below steps.

### Errors:
> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data" is not writable...

> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data/cache" is not writable...

> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data/cache/doctrine" is not writable...

**Fix:**

chmod -R 777 data


### Error:
> PHP Fatal error: Uncaught ErrorException: fopen(/var/www/_example.local_/config/autoload/../../log/error-log-_yyyy-mm-dd.log_): Failed to open stream: Permission denied...

**Fix:**

chmod -R 777 log
# Frequently Asked Questions


## How do I switch to a different version of PHP?

### Switch to PHP 7.4

sudo dnf module switch-to php:remi-7.4 -y

### Switch to PHP 8.1

sudo dnf module switch-to php:remi-8.1 -y

### Switch to PHP 8.2

sudo dnf module switch-to php:remi-8.2 -y


## How do I switch to a different version of Node.js?

### Switch to Node.js 18.x

sudo dnf remove nodejs -y
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo dnf install nodejs -y

### Switch to Node.js 16.x

sudo dnf remove nodejs -y
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo dnf install nodejs -y

### Switch to Node.js 14.x

sudo dnf remove nodejs -y
curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo dnf install nodejs -y

### Switch to Node.js 12.x

sudo dnf remove nodejs -y
curl -fsSL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo dnf install nodejs -y

**Note**: Node.js 12.x is no longer actively supported!


## How do I fix common permission issues?
If running your project you encounter some permission issues, follow the below steps.

### Errors:
> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data" is not writable...

> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data/cache" is not writable...

> PHP Fatal error: Uncaught InvalidArgumentException: The directory "/var/www/_example.local_/data/cache/doctrine" is not writable...

**Fix:**

chmod -R 777 data


### Error:
> PHP Fatal error: Uncaught ErrorException: fopen(/var/www/_example.local_/config/autoload/../../log/error-log-_yyyy-mm-dd.log_): Failed to open stream: Permission denied...

**Fix:**

chmod -R 777 log
14 changes: 10 additions & 4 deletions wsl/os/almalinux9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ The installation is complete, your development environment is ready to use.


## Create virtual hosts
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.

Create the specified virtual hosts:
Expand Down Expand Up @@ -133,7 +137,9 @@ You will install your project under the `html` directory of your project, for ex
The virtualhost's document root is set to the `public` directory of the above location, for example `/var/www/example.local/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)
* 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 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).
1 change: 1 addition & 0 deletions wsl/os/almalinux9/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- mariadb
- phpmyadmin
- composer
- nodejs
- git
- virtualhost
loop_control:
Expand Down
5 changes: 5 additions & 0 deletions wsl/os/almalinux9/roles/nodejs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Add Node.js 18.x repo
shell: curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo -E bash -
- name: Install Node.js 18.x
command: "dnf install nodejs -y"
29 changes: 29 additions & 0 deletions wsl/os/ubuntu20/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,35 @@ sudo service apache2 restart
```


## How do I switch to a different version of Node.js?

### Switch to Node.js 18.x

sudo apt remove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs -y

### Switch to Node.js 16.x

sudo apt remove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs -y

### Switch to Node.js 14.x

sudo apt remove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs -y

### Switch to Node.js 12.x

sudo apt remove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs -y

**Note**: Node.js 12.x is no longer actively supported!


## How do I fix common permission issues?
If running your project you encounter some permission issues, follow the below steps.

Expand Down
10 changes: 6 additions & 4 deletions wsl/os/ubuntu20/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ You will install your projects under the `/home/your-username/projects/` directo
The virtualhost's document root is set to the `public` directory of the above location, for example `/home/your-username/projects/example.local/public`.

**Note**:
* In order to run your installed projects, you need to start Ubuntu 20 first
* If you work with virtualhosts, your projects are created under `/home/your-username/projects/`
* 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)
* In order to run your installed projects, you need to start Ubuntu 20 first.
* If you work with virtualhosts, your projects are created under `/home/your-username/projects/`.
* 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).
* Default version of PHP is set to 7.4. If you need a different version, see [this guide](FAQ.md#how-do-i-switch-between-php-versions).
* 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).
1 change: 1 addition & 0 deletions wsl/os/ubuntu20/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
- php
- phpmyadmin
- composer
- nodejs
- git
- user
9 changes: 9 additions & 0 deletions wsl/os/ubuntu20/roles/nodejs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Add Node.js 18.x repo
shell: curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
args:
warn: no
- name: Install Node.js 18.x
apt:
name: nodejs
state: latest