diff --git a/wsl/os/almalinux9/FAQ.md b/wsl/os/almalinux9/FAQ.md index e54f4ea..0e649a3 100644 --- a/wsl/os/almalinux9/FAQ.md +++ b/wsl/os/almalinux9/FAQ.md @@ -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 diff --git a/wsl/os/almalinux9/README.md b/wsl/os/almalinux9/README.md index 645aee0..a41198d 100644 --- a/wsl/os/almalinux9/README.md +++ b/wsl/os/almalinux9/README.md @@ -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: @@ -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). diff --git a/wsl/os/almalinux9/install.yml b/wsl/os/almalinux9/install.yml index bb956f7..d031e21 100644 --- a/wsl/os/almalinux9/install.yml +++ b/wsl/os/almalinux9/install.yml @@ -32,6 +32,7 @@ - mariadb - phpmyadmin - composer + - nodejs - git - virtualhost loop_control: diff --git a/wsl/os/almalinux9/roles/nodejs/tasks/main.yml b/wsl/os/almalinux9/roles/nodejs/tasks/main.yml new file mode 100644 index 0000000..f5a0671 --- /dev/null +++ b/wsl/os/almalinux9/roles/nodejs/tasks/main.yml @@ -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" diff --git a/wsl/os/ubuntu20/FAQ.md b/wsl/os/ubuntu20/FAQ.md index 790cece..75e650b 100644 --- a/wsl/os/ubuntu20/FAQ.md +++ b/wsl/os/ubuntu20/FAQ.md @@ -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. diff --git a/wsl/os/ubuntu20/README.md b/wsl/os/ubuntu20/README.md index 772873f..fa65222 100644 --- a/wsl/os/ubuntu20/README.md +++ b/wsl/os/ubuntu20/README.md @@ -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). diff --git a/wsl/os/ubuntu20/install.yml b/wsl/os/ubuntu20/install.yml index 0a7a7a2..924fea7 100644 --- a/wsl/os/ubuntu20/install.yml +++ b/wsl/os/ubuntu20/install.yml @@ -14,5 +14,6 @@ - php - phpmyadmin - composer + - nodejs - git - user diff --git a/wsl/os/ubuntu20/roles/nodejs/tasks/main.yml b/wsl/os/ubuntu20/roles/nodejs/tasks/main.yml new file mode 100644 index 0000000..83d1569 --- /dev/null +++ b/wsl/os/ubuntu20/roles/nodejs/tasks/main.yml @@ -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