<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thakur Gumansingh on Medium]]></title>
        <description><![CDATA[Stories by Thakur Gumansingh on Medium]]></description>
        <link>https://medium.com/@thakurguman?source=rss-144b78d4a917------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qJnp-Xgq2yzVZPE8tkBEBA.jpeg</url>
            <title>Stories by Thakur Gumansingh on Medium</title>
            <link>https://medium.com/@thakurguman?source=rss-144b78d4a917------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:25:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thakurguman/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Windows 11 Deployment using OPSI Netboot]]></title>
            <link>https://thakurguman.medium.com/2-windows-11-deployment-using-opsi-netboot-bda6143ee335?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/bda6143ee335</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 13:53:54 GMT</pubDate>
            <atom:updated>2026-03-24T14:33:39.142Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Why OPSI Netboot? &amp; Server-Side Foundation</h3><p>Netboot is the core of OPSI’s power. Instead of walking around with USB sticks, the server uses the network (PXE) to push a Linux-based bootimage to a blank machine. This bootimage prepares the hard drive and then hands over the process to a Windows PE (WinPE) environment to finish the installation. It allows for “Zero-Touch” deployment of hundreds of machines simultaneously.</p><h3>1.1 Redis &amp; Core Services</h3><p>OPSI 4.3 depends on Redis to store session data. Without it, the management tool cannot talk to the server.</p><pre>apt update &amp;&amp; apt install opsi-server-full redis-server git p7zip-full wimtools isc-dhcp-server -y apt install tftpd-hpa -y<br>systemctl enable --now redis-server</pre><h3>2. The DHCP Infrastructure</h3><p>All DHCP logic and binding must be configured here before any network boot is attempted.</p><h3>2.1 Enabling OPSI DHCP Logic</h3><p>File: /etc/opsi/backends/dhcpd.conf</p><pre>dhcpd : True<br>dhcpdOnDepot : True</pre><h3>2.2 Binding and ISC-DHCP-Server Setup</h3><p>OPSI does not install the DHCP server by default. Identify your interface using (ip a) and edit /etc/default/isc-dhcp-server to set INTERFACESv4=&quot;your_interface&quot;.</p><p>File: /etc/dhcp/dhcpd.conf</p><pre>authoritative;<br>allow booting;<br>allow bootp;<br><br>subnet 192.168.137.0 netmask 255.255.255.0 {<br>  range 192.168.137.130 192.168.137.150;<br>  option routers 192.168.137.129;<br>  next-server 192.168.137.129; #opsi server IP<br>  filename &quot;opsi/opsi-linux-bootimage/loader/shimx64.efi.signed&quot;;<br>}</pre><pre>systemctl restart isc-dhcp-server</pre><h3>3. TFTP &amp; PXE Boot Configuration</h3><p>This stage bridges the network request to the actual boot files.</p><h3>3.1 TFTP Service Configuration</h3><p>Ensure /etc/default/tftpd-hpa looks like this:</p><pre>TFTP_USERNAME=&quot;tftp&quot;<br>TFTP_DIRECTORY=&quot;/tftpboot&quot;<br>TFTP_ADDRESS=&quot;:69&quot;<br>TFTP_OPTIONS=&quot;--secure --ipv4 --map-file /etc/opsi/tftpd.map&quot;</pre><h3>3.2 Fixing TFTP Failures (Map &amp; Permissions)</h3><p>Check port 69: ss -ulpn | grep :69. If missing, create the map and set rights:</p><pre>mkdir -p /tftpboot/opsi/<br>touch /tftpboot/opsi/opsi-tftp-db.map<br>chown -R tftp:tftp /tftpboot<br>opsi-setup --set-rights /tftpboot<br>systemctl restart tftpd-hpa</pre><h3>3.3 TFTP Symlinks &amp; PXE Logic Bridge</h3><p>Link the package files to the boot directory:</p><pre>ln -sf /var/lib/opsi/depot/opsi-linux-bootimage/install /tftpboot/opsi/linux<br>opsi-setup --set-rights /tftpboot</pre><p>For GRUB2:</p><pre>mkdir -p /tftpboot/opsi/grub<br>ln -s /tftpboot/opsi/cfg/grub.cfg /tftpboot/opsi/grub/grub.cfg<br>opsipxeconfd update</pre><p><em>Note: If MAC-specific boot file is missing in </em><em>/tftpboot/opsi/pxelinux.cfg/, run </em><em>opsiconfd setup and restart.</em></p><h3>4. The WinPE &amp; Windows Media Staging</h3><p>You cannot install Windows from Linux. You need a “Mini-Windows” (WinPE) to run the setup. If your winpe directory is empty, the netboot product cannot function.</p><h3>4.1 WinPE Extraction</h3><p><strong>Method A (Debian Native): </strong>On Debian, you can’t use Windows tools, so you must use wimtools and the ISO you downloaded(you can download ISO from official site).</p><pre>mkdir -p /mnt/iso &amp;&amp; mount -o loop /root/windows11.iso /mnt/iso<br>mkdir -p /var/lib/opsi/depot/win11-x64/winpe/sources<br>cp /mnt/iso/sources/boot.wim /var/lib/opsi/depot/win11-x64/winpe/sources/</pre><p><strong>Method B: (The git repo Method): </strong>If Method A isn’t an option, use the mkWinPE script directly on Debian.</p><pre>mkdir -p /var/lib/opsi/depot/opsi-winpe<br>cd /var/lib/opsi/depot/opsi-winpe<br><br>git clone https://github.com/J-U-B/mkWinPE.git<br>cd mkWinPE &amp;&amp; chmod +x mkwinpe.sh<br>./mkwinpe.sh /root/win11.iso<br><br>mkdir -p /var/lib/opsi/depot/win11-x64/winpe/sources <br>cp -v ./winpe/sources/boot.wim /var/lib/opsi/depot/win11-x64/winpe/sources/</pre><h3>4.2 Windows Media &amp; Verification</h3><pre>mkdir -p /var/lib/opsi/depot/win11-x64/installfiles <br>cp -rv /var/lib/opsi/depot/opsi-winpe/mkWinPE/installfiles/* /var/lib/opsi/depot/win11-x64/installfiles/</pre><p><strong>Mandatory WIM Verification:</strong></p><pre>wiminfo /var/lib/opsi/depot/win11-x64/installfiles/sources/install.wim<br>wiminfo /var/lib/opsi/depot/win11-x64/winpe/sources/boot.wim</pre><h3>5. Driver Integration</h3><p>If the WinPE is not correctly updated, you may face “install missing drivers issue” to fix that switch to the known working WinPE from the official OPSI docs. If the <strong>viostor</strong> driver fails to load on startup, you must inject it directly into the boot.wim within the WinPE environment.</p><p>To build a working Opsi WinPE on <strong>Debian 13</strong>, you must understand that the “Automatic” method is actually a two-part process: the <strong>Opsi Server</strong> prepares the environment, and a <strong>Windows Client</strong> (with ADK installed) does the heavy lifting of building the image.</p><h4>Phase 1: Server-Side Preparation (Debian 13)</h4><p>You must first install the Opsi WinPE package and prepare the driver injection folders.</p><pre># 1. Install the WinPE management package<br>opsi-package-updater -v install opsi-winpe<br><br># 2. Create the driver directory for injection<br>mkdir -p /var/lib/opsi/depot/opsi-winpe/drivers/drivers/preferred/virtio<br><br># 3. Copy your VirtIO (or other) drivers here (.inf, .sys, .cat files)<br># Assuming you have them in /tmp/drivers<br>cp /tmp/drivers/* /var/lib/opsi/depot/opsi-winpe/drivers/drivers/preferred/virtio/<br><br># 4. Set permissions so the Opsi service can read them<br>opsi-set-rights /var/lib/opsi/depot/opsi-winpe</pre><h4>Phase 2: Generating the WinPE (The “Opsi Way”)</h4><p>Opsi cannot “build” a Windows PE file on Linux natively because it requires Microsoft’s dism and adk tools. You must use an existing Windows machine (a &quot;Helper Client&quot;) that already has the Opsi Client Agent installed.</p><ul><li><strong>On your Windows Helper Machine:</strong> Install the <strong>Windows ADK</strong> and the <strong>WinPE Add-on</strong>.</li><li><strong>In Opsi-Configed (Management UI):</strong></li><li>Find your Windows Helper Machine.</li><li>Set the localboot product opsi-winpe to <strong>setup</strong>.</li><li>In the Product Properties (bottom right), ensure arch is set to <strong>x64</strong>.</li><li>Click <strong>Save</strong> and trigger the event (or reboot the Windows machine).</li></ul><h4>Phase 3: Injecting Drivers into the Boot.wim (Manual “Injection” Fix)</h4><p>If the “Automatic” method fails to include your drivers, you must manually inject them into the WIM file on the Debian server using wimtools.</p><p><strong>On the Debian 13 Server:</strong></p><pre># 1. Install wimtools if not present<br>apt update &amp;&amp; apt install wimtools -y<br><br># 2. Create a mount point<br>mkdir -p /mnt/wim_mount<br><br># 3. Mount the WIM file (Index 1 is usually the PE environment)<br># Path depends on where your WIM is: /var/lib/opsi/depot/win11-x64/winpe/winpe.wim<br>wimlib-imagex mountrw /var/lib/opsi/depot/win11-x64/winpe/winpe.wim 1 /mnt/wim_mount<br><br># 4. Inject the drivers (Copy the raw .inf/.sys files into the WIM driver store)<br>cp -r /var/lib/opsi/depot/win11-x64/drivers/drivers/preferred/virtio/* /mnt/wim_mount/Windows/System32/Drivers/<br><br># 5. Unmount and Commit the changes (This saves the drivers into the WIM)<br>wimlib-imagex unmount /mnt/wim_mount --commit<br><br># 6. Final Permission Fix<br>opsi-set-rights /var/lib/opsi/depot/win11-x64</pre><h4>Phase 4: Final Move to Product Folder</h4><p>Once the WIM is created (either by the Helper Client or manually), it must be in the correct location for the Windows 11 installation to work.</p><pre># Ensure the directory exists<br>mkdir -p /var/lib/opsi/depot/win11-x64/winpe/<br><br># Copy the finished WIM into the product folder<br># Opsi 4.3 specifically looks for &#39;winpe.wim&#39;<br>cp /var/lib/opsi/depot/opsi-winpe/global.wim /var/lib/opsi/depot/win11-x64/winpe/winpe.wim<br><br># Refresh the Opsi PXE configuration<br>opsipxeconfd update</pre><h3>6. Client Creation &amp; Deployment Logic</h3><p>Registering a client is the essential first step because OPSI acts as a targeted deployment system rather than a generic network service. By creating a client entry with a specific MAC address, you are pre-authorizing that unique piece of hardware to receive automated tasks, which prevents the server from accidentally wiping or reinstalling random machines that connect to your network. This registration creates a secure handshake between the server and the hardware, allowing OPSI to assign a unique identity (FQDN) to the device and manage its “Requested Action” state. Without this entry in the database, the server has no instructions on what to do when the machine boots, leaving the VM unable to trigger the WinPE environment or start the Windows installation process.</p><h4><em>6.1 Pre-Requisites: Preparing the Target</em></h4><p>Before touching the OPSI management tools, you must prepare your virtual hardware. Create a new VM (suggested: <strong>4GB RAM / 64GB HDD</strong>) and name it <strong>win</strong>. In your virtualization software (VMware or VirtualBox), go to the Network settings, ensure the adapter is set to <strong>Bridged</strong>, and copy the <strong>MAC Address</strong> from the Advanced section (e.g., 00:0C:29:15:8D:14).</p><p>Regarding the naming convention: OPSI identifies clients by their <strong>FQDN (Fully Qualified Domain Name)</strong>. This is a combination of your <strong>Client Name</strong> and your <strong>Domain</strong>. If your client is named <strong>win</strong> and your domain is <strong>opsi.test</strong>, the full ID will be <strong>win.opsi.test</strong>.</p><h4>6.2 Option A: The Graphical Method (opsi-configed)</h4><p>If you prefer a visual interface, you can use the OPSI Configuration Editor. This is a Java-based application that runs on your local workstation.</p><ol><li><strong>Download the Tool:</strong> Open your browser and go to https://&lt;your-server-ip&gt;:4447/configed. Download the .jnlp file or the standalone installer provided on that page.</li><li><strong>Login:</strong> Launch the app and log in with your OPSI admin credentials.</li><li><strong>Create Client:</strong> Right-click in the client list area on the left and select <strong>“Create new opsi client.”</strong></li><li><strong>Fill Information:</strong> Enter the Hostname (win), your Domain (opsi.test), and the MAC Address you copied earlier. Click <strong>Save</strong> (the checkmark icon) at the top.</li><li><strong>Set to Setup:</strong> Click on your new client in the list. Navigate to the <strong>Netboot Products</strong> tab, find <strong>win10-x64</strong>, and in the “Requested Action” column, select <strong>setup</strong>. Click the <strong>Save</strong> icon again to commit the changes.</li></ol><h4>6.3 Option B: The Command Line Method (opsi-admin)</h4><p>This is the fastest method and is ideal for Debian users who want to avoid Java dependencies.</p><ol><li><strong>Register the Client:</strong> Use the modern host creation method to inject the client directly into the OPSI backend:</li></ol><pre>opsi-admin -d method host_createOpsiClient &quot;win.opsi.test&quot; &quot;null&quot; &quot;Windows VM&quot; &quot;null&quot; &quot;00:0c:29:15:8d:14&quot; &quot;192.168.137.150&quot;</pre><p><strong>2. Trigger the Installation:</strong> Set the product state to “setup” so the server knows to push the WinPE environment on boot:</p><pre>opsi-admin -d method setProductActionRequest &quot;win10-x64&quot; &quot;win.opsi.test&quot; &quot;setup&quot;</pre><p><strong>3. Verify the Entry:</strong> Always check that the database successfully saved your request:</p><pre>opsi-admin -d method host_getObjects &#39;&#39; &#39;{&quot;id&quot;: &quot;win.opsi.test&quot;}&#39;</pre><h4>6.3 Common Hardware &amp; IP Fixes</h4><ul><li><strong>The IP Mismatch Error:</strong> If the VM screen shows IP .135 during PXE but the OPSI tool is configured for .150, the boot will hang. The IP in the OPSI command <strong>must</strong> match the IP the DHCP server assigned to that MAC.</li><li><strong>PXE Boot Loop:</strong> If the VM installs but reboots back into the installer, change the <strong>Boot Order</strong> in the VM settings to put the Hard Disk (HDD) before the Network (Net0) after the first stage is complete.</li><li><strong>UEFI vs BIOS:</strong> For modern Windows 11 VMs, ensure the VM is set to <strong>UEFI</strong> and that secure boot is handled by the OPSI shimx64.efi loader.</li></ul><h3><strong>7. Some common errors</strong></h3><h4>7.1 Permission &amp; Samba Deadlocks</h4><p><strong>Critical Error: “No space left on device” during Client-Agent deployment</strong> repository error failed to download opsi-client-agent /opsi deploy client agent to /mnt/hd/opsi-client-agent ... no space left on device</p><p>This is often caused because OPSI tried to copy the whole installfiles folder to the disk instead of just setup.exe. Because WinPE runs in RAM (X: drive). If the Samba connection fails, Opsi sometimes tries to “fallback” to copying files to that RAM drive. Since RAM is limited (usually 2GB-4GB), it hits that “No space” error almost instantly. Fixing the firewall/Samba ports ensures it mounts the drive instead of copying it.</p><pre>ufw allow 137,138/udp <br>ufw allow 139,445/tcp<br>opsi-setup --register-depot<br>opsi-set-rights /var/lib/opsi/depot</pre><h4>7.2 The Black Screen Error</h4><p>The Issue: The Linux bootimage starts, then the screen flashes and goes black. The Fix: Change the VM Graphics card to <strong>SPICE</strong> (Proxmox) or <strong>VMSVGA</strong> (VMware/VirtualBox).</p><h4>7.3 Missing drivers issue (browse drivers manually screen)</h4><p>If your OPSI installation fails to detect a hard drive due to missing VirtIO or storage drivers, you can manually intervene without restarting the deployment. While at the “No drives found” screen, press <strong>Shift + F10</strong> to open the WinPE Command Prompt and identify the OPSI network share — usually mounted as <strong>Z:</strong> or <strong>O:</strong> — by typing the drive letter followed by dir to locate your win11-x64 product folder. Once the drive is identified, execute the command: drvload Z:\path\to\driver\vioscsi.inf</p><p>(prioritizing the SCSI controller driver over the disk driver) to live-inject the required files into the running kernel. After the command returns a &quot;Successfully loaded&quot; message, simply click <strong>Refresh</strong> in the Windows Setup GUI, and your virtual disk will immediately appear for partitioning.</p><h4>7.4 Mouse Cursor Desynchronization</h4><p>While the <strong>SPICE</strong> protocol (used in Proxmox/KVM) is excellent for monitoring the initial boot and WinPE phase, it frequently suffers from <strong>cursor desync</strong> or “laggy mouse” issues if the guest drivers are not yet fully initialized.</p><p>If you find the mouse is unusable during the final stages of setup or after the first desktop load, switch to <strong>Remote Desktop (RDP)</strong> immediately. RDP uses its own virtual input driver which bypasses the hardware emulation issues of the hypervisor.</p><p><strong>To connect from your Linux workstation:</strong> Use xfreerdp3 for the best compatibility with Windows 11&#39;s high-resolution scaling and clipboard integration:</p><pre># Replace &lt;client_ip&gt; with your VM&#39;s assigned IP (e.g., 10.10.10.153)<br># Default OPSI admin password is often nt123<br>xfreerdp3 /u:opsi /p:nt123 /v:&lt;client_ip&gt; /dynamic-resolution +clipboard /cert:ignore</pre><h3>8. Logging &amp; Deep Debug</h3><p>When a deployment fails, “guessing” is your enemy. OPSI provides deep logs at both the server and client levels. Follow this hierarchy to find the root cause.</p><h4>1. Monitoring the Server Engine</h4><p>First, ensure the OPSI services are actually receiving and processing the PXE requests. Open a terminal on your OPSI server and run:</p><ul><li><strong>To watch PXE boot assignments:</strong> journalctl -u opsipxeconfd -f</li><li><strong>To watch API calls and client handshakes:</strong> journalctl -u opsiconfd -f</li><li><strong>For a visual, searchable log interface:</strong> opsiconfd log-viewer</li></ul><h4>2. Tracking the Specific Client Handshake</h4><p>If the services are running but a specific machine is failing, tail the log file named after that client’s IP address. This is where you will see permission errors or “File Not Found” alerts:</p><pre># Replace with your actual client IP<br>tail -f /var/log/opsi/opsiconfd/10.10.10.153.log</pre><h4>3. DHCP/TFTP Verification</h4><p>Sniff traffic: tcpdump -i eth0 port 67 or port 69.</p><h4>4. The “Deep Debug” Method (Stopping the Auto-Reboot)</h4><p>If the installation fails and the VM reboots too fast for you to read the error, you must “freeze” the process.</p><ul><li><strong>Modify the Setup Script:</strong> Navigate to your install files: cd /var/lib/opsi/depot/win11-x64/</li><li><strong>Edit </strong><strong>setup.py:</strong> Open the file and find the very last line (usually reboot()).</li><li><strong>Comment it out:</strong> Change it to # reboot(). This prevents the VM from restarting upon failure.</li><li><strong>Access the “Frozen” Client:</strong> * While the VM is stuck at the error screen, use <strong>Shift + F10</strong> to open a Command Prompt.</li><li>Alternatively, if the OPSI bootimage is still active, you can SSH into the client: ssh root@&lt;client_ip&gt;</li><li><strong>The Password:</strong> Use the opsiHostKey or cmd passwordfound in the OPSI Configed tool under the &quot;Host Properties&quot; or &quot;Netboot Properties&quot; tab for that specific client.</li><li><strong>Locate Local Logs:</strong> Once inside the client, navigate to the C:\opsi\logs or the WinPE X:\ drive logs to see exactly why the Windows Setup engine (Setup.exe) crashed.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bda6143ee335" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OPSI 4.3 Initial Setup Guide (Debian 12)]]></title>
            <link>https://thakurguman.medium.com/opsi-4-3-initial-setup-guide-debian-12-8509c0db7384?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/8509c0db7384</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 13:28:51 GMT</pubDate>
            <atom:updated>2026-03-14T13:28:51.774Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide covers the installation of the OPSI (Open PC Server Integration) core services, the configuration of the management backend, and the resolution of common environmental dependencies.</p><h3>Phase 1: Repository &amp; Security Handshake</h3><p>Before installing OPSI, the system must trust the OPSI maintainers’ signatures. We use a dedicated keyring to avoid cluttering the system’s main certificate store.</p><ol><li><strong>Prepare the Keyring Directory</strong></li></ol><pre>mkdir -p /usr/local/share/keyrings</pre><p><strong>2. Import the OPSI GPG Key:</strong> This ensures all downloaded packages are authentic.</p><pre>curl -fsSL https://download.opensuse.org/repositories/home:/uibmz:/opsi:/4.3:/stable/Debian_12/Release.key | gpg --dearmor | tee /usr/local/share/keyrings/opsi-obs.gpg &gt; /dev/null</pre><p><strong>3. Register the Repository:</strong> We use the uibmz stable mirror, which is the verified path for OPSI 4.3.</p><pre>echo &quot;deb [signed-by=/usr/local/share/keyrings/opsi-obs.gpg] https://download.opensuse.org/repositories/home:/uibmz:/opsi:/4.3:/stable/Debian_12/ /&quot; &gt; /etc/apt/sources.list.d/opsi.list</pre><h3>Phase 2: Core Component Installation</h3><p>To avoid dependency conflicts with non-essential third-party software (like Grafana), we install the functional core components directly.</p><ol><li><strong>Update and Install:</strong></li></ol><pre>apt update apt install opsiconfd opsipxeconfd opsi-utils redis-server -y</pre><h3>Why we use this method:</h3><ul><li><strong>opsiconfd</strong>: The primary service (The &quot;Brain&quot;) handling all logic and communication.</li><li><strong>redis-server</strong>: High-speed data storage for active sessions.</li><li><strong>Excluding Grafana</strong>: Standard Debian repositories do not host the specific Grafana versions required by the OPSI meta-package. Skipping this allows for a clean installation without “broken package” errors.</li></ul><h3>Phase 3: Server Initialization &amp; Identity</h3><p>The OPSI server must generate its own SSL certificates and administrative credentials to allow encrypted communication.</p><ol><li><strong>Run the Core Setup:</strong> Initialize the server while skipping performance metrics (which require specific Redis modules not present by default).</li></ol><pre>opsiconfd setup --skip-setup grafana,metric_downsampling --admin-user adminuser --admin-password linux123</pre><p><strong>2. Apply System Permissions:</strong> Ensure the OPSI services have the necessary Linux rights to read their own configuration and boot files.</p><pre>opsi-set-rights</pre><p><strong>3. Commit Changes:</strong></p><pre>systemctl restart opsiconfd</pre><blockquote><strong><em>Troubleshooting: “500 Internal Server Error”</em></strong><em> If the </em><em>opsi-admin command or the web interface returns a 500 error, it typically means the SSL certificates were not generated properly. </em><strong><em>Fix:</em></strong><em> Re-run </em><em>opsiconfd setup --skip-setup all --admin-user adminuser --admin-password linux123 to force a password/identity sync.</em></blockquote><h3>Phase 4: Verification</h3><p>Before moving to OS deployment, verify the server is healthy.</p><ol><li><strong>Backend Response Check:</strong> Run this command to test the internal API handshake:</li></ol><pre>opsiconfd health-check --list --detailed</pre><p><strong>2. Management Interface Check:</strong> Open a web browser and navigate to: https://&lt;YOUR_SERVER_IP&gt;:4447 <em>Log in with </em><em>adminuser and your chosen password.</em></p><h3>Phase 5: Network Readiness (PXE Setup)</h3><p>To allow a Proxmox VM to “see” this server, the DHCP and TFTP services must be linked.</p><ol><li><strong>TFTP Configuration:</strong> Ensure /etc/default/tftpd-hpa includes the OPSI map file: TFTP_OPTIONS=&quot;--secure --map-file /etc/opsi/tftp.map&quot;</li><li><strong>DHCP Handover:</strong> The DHCP server must point to your OPSI IP (192.168.137.129) as the next-server.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8509c0db7384" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying OPSI 4.3 on WSL2: A Complete Workaround Guide]]></title>
            <link>https://thakurguman.medium.com/deploying-opsi-4-3-on-wsl2-a-complete-workaround-guide-742f4a1b9c2b?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/742f4a1b9c2b</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 19:49:00 GMT</pubDate>
            <atom:updated>2026-03-19T09:24:07.162Z</atom:updated>
            <content:encoded><![CDATA[<p>To successfully deploy software like Visual Studio Code across a network, you must understand the <strong>Server-Client Architecture</strong>. OPSI (Open PC Server Integration) requires two distinct environments:</p><ul><li><strong>The OPSI Server (Linux):</strong> This acts as the “Command Center.” It stores the installation files, manages the database of clients, and hosts the web interface. We are using <strong>Ubuntu 24.04 (Noble)</strong> via WSL2.</li><li><strong>The OPSI Client (Windows):</strong> This is the target machine (VM or physical) where the software will be installed.</li></ul><p><strong>Why two machines?</strong> OPSI functions by having a “Service” (the OPSI-Client-Agent) running on the Windows machine that “calls home” to the Linux server to check for new tasks. You cannot test deployment on the same machine that hosts the server because the installation environment must be isolated.</p><h3>Part 1: Network Bridging (WSL2 to Local Network)</h3><p>Because WSL2 runs on a virtualized network, your physical Windows machine (and other clients) cannot see the OPSI server by default. You must find your server’s internal IP address and proxy the OPSI port (<strong>4447</strong>).</p><h4>1. Get your Server IP</h4><p>On your Ubuntu terminal, run the following to identify your current IP address:</p><pre>hostname -I | awk &#39;{print $1}&#39;</pre><h4>2. Map the Port in Windows</h4><p>Run these commands in <strong>Windows PowerShell (Admin)</strong>, replacing YOUR_SERVER_IP with the address found in the previous step:</p><pre>netsh interface portproxy add v4tov4 listenport=4447 listenaddress=0.0.0.0 connectport=4447 connectaddress=YOUR_SERVER_IP<br>New-NetFirewallRule -DisplayName &quot;OPSI Server WSL&quot; -Direction Inbound -LocalPort 4447 -Protocol TCP -Action Allow</pre><p><strong>Note on WSL2 Persistence:</strong> Every time you restart Windows or WSL2, your internal IP may change. If the Admin UI stops loading, re-run hostname -I and update the connectaddress in the PowerShell netsh command above to match the new IP.</p><h3>Part 2: The Ideal OPSI Server Installation</h3><p>Under standard conditions on a native Linux machine, the installation is straightforward.</p><h4>1. Repository and Package Install</h4><pre>curl -fsSL https://download.opensuse.org/repositories/home:/uibmz:/opsi:/4.3:/stable/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/opsi-archive-keyring.gpg &gt; /dev/null<br>echo &quot;deb [signed-by=/usr/share/keyrings/opsi-archive-keyring.gpg] https://download.opensuse.org/repositories/home:/uibmz:/opsi:/4.3:/stable/xUbuntu_24.04/ /&quot; | sudo tee /etc/apt/sources.list.d/opsi.list<br>sudo apt update &amp;&amp; sudo apt install opsi-server redis-stack-server</pre><h4>2. Initialization</h4><pre>sudo opsiconfd setup</pre><h3>Part 3: Real-World Workarounds (WSL2 &amp; Ubuntu 24.04)</h3><p>If the ideal setup fails due to package unavailability or service protocol errors, use these verified workarounds.</p><h4>Workaround A: Manual Redis &amp; TimeSeries Installation</h4><p>If redis-stack-server is missing, install the core components and the required OPSI module separately.</p><pre>sudo apt install -y redis-timeseries redis-server</pre><p><strong>Crucial Fix:</strong> Edit /etc/redis/redis.conf and set supervised no and daemonize yes. Then start it manually:</p><pre>sudo redis-server /etc/redis/redis.conf --daemonize yes</pre><p><strong>Verify Redis is Alive:</strong> Before touching OPSI, ensure the Redis backend is responding. If this fails, OPSI cannot start. Response should be pong.</p><pre>redis-cli ping</pre><h4>Workaround B: Fixing the Hostname Identity</h4><p>OPSI 4.3 requires an <strong>FQDN</strong> (e.g., guman.opsi.internal). If your WSL2 hostname is capitalized or keeps resetting, force it to lowercase to match the OPSI database.</p><pre>sudo hostnamectl set-hostname guman</pre><p>After updating the hosts file, verify that /etc/opsi/opsi.conf matches exactly. Open the file: sudo nano /etc/opsi/opsi.conf Ensure the line reads: id = &quot;guman.opsi.internal&quot; (all lowercase). If there is a case mismatch (e.g., &quot;Guman&quot;), the opsiconfd service will crash on startup.</p><h3>Part 4: Permissions and Authorization</h3><p>Before the server can function, you must define administrative rights and register the storage depot. We use a dedicated <strong>adminuser</strong> account rather than the default root to adhere to security best practices and ensure OPSI service groups manage the file system correctly.</p><h4>1. <strong>Create the Admin User:</strong></h4><pre>sudo adduser adminuser</pre><h4>2. Granting Administrative Permissions</h4><p>Add your user to the OPSI management groups to ensure you can manage files and configurations.</p><pre>sudo usermod -aG opsiadmin,opsifileadmins adminuser</pre><h4>3. Setting the Admin Password</h4><p>Sync the internal OPSI database with your chosen credentials.</p><pre>sudo opsiconfd setup --admin-user adminuser --admin-password YOUR_PASSWORD</pre><h4>4. Registering the Depot</h4><p>This links the server’s “brain” to its “storage.” To avoid a recursive network deadlock on WSL2, you must ensure the server identifies as a <strong>Master (Configserver)</strong>, not a subordinate depot. Run the setup command:</p><pre>sudo opsiconfd setup<br>OR<br>sudo opsiconfd setup --skip-setup all --register-depot </pre><p><strong>The Critical Choice:</strong> When the prompt asks: Do you want to register this server as a depotserver? [y/n] <strong>Type </strong><strong>n and hit Enter.</strong></p><p><em>Why?</em> Selecting y tells OPSI to look for an external Master. Since you are the only server, it will try to call itself before the service is even running, resulting in a permanent &quot;Connection Refused&quot; loop.</p><ul><li><strong>Service URL:</strong> <a href="https://localhost:4447/rpc">https://localhost:4447/rpc</a></li><li><strong>Username:</strong> adminuser</li><li><strong>Depot ID:</strong> guman.opsi.internal (Accept default)</li><li><strong>Description:</strong> Enter a name for your storage, e.g., Main OPSI Depot.</li></ul><h3>Part 5: Health Verification</h3><p><strong>Mandatory Step:</strong> Never proceed to packaging software until the server reports a healthy state. Verify your progress with:</p><pre>sudo opsiconfd health-check</pre><p><strong>Verification Checklist:</strong></p><ul><li><strong>Redis:</strong> Must show <strong>OK</strong>.</li><li><strong>MySQL:</strong> Must show <strong>OK</strong>.</li><li><strong>Web Server:</strong> Port 4447 must be listening.</li><li><strong>Admin UI:</strong> Open https://YOUR_SERVER_IP:4447/admin in your browser. If you see the login page, the server is ready.</li></ul><h3>Part 6: Creating the VS Code Product (Manual vs. Automated)</h3><p>Once your server is healthy, the final phase is to create the software “recipe” that OPSI will use to install Visual Studio Code. You have two ways to do this: the automated interactive wizard or manual folder creation.</p><h4>Option A: Automated Creation (The Wizard)</h4><p>Navigate to the OPSI workbench and launch the tool:</p><pre>cd /var/lib/opsi/workbench<br>sudo opsi-newprod</pre><h4>Option B: Manual Creation (The Expert Way)</h4><p>If you prefer not to use the wizard, you must manually create a specific directory structure. OPSI requires a folder named after your <strong>Product ID</strong> (e.g., vscode) containing two mandatory subdirectories:</p><ul><li><strong>CLIENT_DATA/</strong>: This is the &quot;Storage Box.&quot; It must contain the actual installation files (e.g., VSCodeSetup.exe) and any icons or local resources.</li><li><strong>OPSI/</strong>: This is the &quot;Brain.&quot; It must contain a control.toml file (metadata) and your .opsiscript files (the logic).</li></ul><h3>The Interactive Wizard Steps</h3><p>If using <strong>opsi-newprod</strong>, follow these screens exactly:</p><h4>Step 1: Selecting the Product Type</h4><ul><li><strong>Selection:</strong> localboot</li><li><strong>Why?</strong> This is the standard for software like VS Code that installs on an existing Windows OS. The alternative, netboot, is only used for installing entire Operating Systems from scratch.</li></ul><h4>Step 2: Product Identification and Metadata</h4><ul><li><strong>Product ID (Mandatory):</strong> vscode — This must be lowercase with no spaces. It serves as the unique database key and folder name.</li><li><strong>Product Name (Mandatory):</strong> Visual Studio Code — The human-friendly name displayed in the Admin UI.</li><li><strong>Description (Optional):</strong> Silent installation for Windows 10 — A brief note for other admins.</li><li><strong>Advice (Optional):</strong> Leave blank or add internal notes.</li><li><strong>Product Version (Mandatory):</strong> 1.0 — Matches the version of the software.</li><li><strong>Package Version (Mandatory):</strong> 1 — Internal versioning. Increment this if you change the script but keep the same software.</li><li><strong>License Required (Optional):</strong> False — Only set to True if using paid software requiring OPSI License Management.</li><li><strong>Priority (Optional):</strong> 0 — Determines installation order; higher numbers install first.</li></ul><h4>Step 3: Defining the Script Paths</h4><p>This screen tells OPSI which files to execute for different client events.</p><ul><li><strong>Setup script:</strong> setup.opsiscript — <strong>(Mandatory)</strong> The main file containing your installation logic.</li><li><strong>Uninstall script:</strong> uninstall.opsiscript — <strong>(Recommended)</strong> The script to cleanly remove the software.</li><li><strong>Update script:</strong> Used specifically for minor patches or configuration changes between main versions.</li><li><strong>Always script:</strong> Runs every time the client boots, regardless of whether the software is already installed.</li><li><strong>Once script:</strong> Runs exactly one time and then sets the product status to “installed.”</li><li><strong>Custom script:</strong> A flexible slot for specialized administrative tasks not covered by standard events.</li><li><strong>User login script:</strong> Used if you need to perform actions within the context of a specific Windows user profile (like adding desktop shortcuts or registry keys for that user) after they log in.</li></ul><blockquote><strong><em>Note:</em></strong><em> For this VS Code tutorial, leave everything except </em><strong><em>Setup</em></strong><em> and </em><strong><em>Uninstall</em></strong><em> blank.</em></blockquote><h4>Step 4: Dependencies and Properties</h4><ul><li><strong>Create product dependency?</strong> Select <strong>No</strong>. VS Code is standalone and doesn’t require us to link it to other OPSI products.</li><li><strong>Create product property?</strong> Select <strong>No</strong>. Properties are variables (like Install_Extensions=True) that can be toggled from the dashboard. We will keep it simple for now.</li></ul><h4>Step 5: Maintainer Information</h4><ul><li><strong>Maintainer Name:</strong> Guman</li><li><strong>Maintainer e-mail:</strong> your-email@example.com</li></ul><h3>Part 7: Finalizing the Package Files</h3><p>Once you click <strong>OK</strong> in the wizard, OPSI creates the directory structure at /var/lib/opsi/workbench/vscode. To transform this skeleton into a deployable package, you must populate the folders with the installer and the logic.</p><h4>1. Populate the Installer (CLIENT_DATA)</h4><p>You need the actual VS Code “engine” inside the CLIENT_DATA folder. There are three common ways to get it there:</p><ul><li><strong>The WSL Direct Copy:</strong> If you already downloaded the “System Installer” on Windows:</li></ul><pre>sudo cp /mnt/c/Users/YourUser/Downloads/VSCodeSetup-x64.exe /var/lib/opsi/workbench/vscode/CLIENT_DATA/</pre><ul><li><strong>The Wget Method (Recommended for Automation):</strong> Download it directly into the server folder:</li></ul><pre>cd /var/lib/opsi/workbench/vscode/CLIENT_DATA <br>sudo wget -O VSCodeSetup-x64.exe &quot;https://update.code.visualstudio.com/latest/win32-x64-system/stable&quot;</pre><ul><li><strong>The Shared Folder Method:</strong> Moving files via a network share (Samba) if you have configured OPSI’s opsi_workbench share.</li></ul><h4>2. The Metadata Configuration (control vs. control.toml)</h4><p>In OPSI 4.3, the metadata format has evolved. While older versions used a plain control file, the modern standard is control.toml.</p><ul><li><strong>The Difference:</strong> The .toml format is more structured and human-readable. If you used the <strong>Option A (Wizard)</strong>, this file was generated for you. If you are using <strong>Option B (Manual)</strong>, you can refer to the <a href="https://docs.opsi.org/opsi-docs-en/4.3/clients/linux-client/softwareintegration.html#opsi-setup-detector-support_custom_directory">OPSI Custom Directory Guide</a> for exact syntax.</li><li><strong>The License Trap:</strong> By default, the UI tool might set licenseRequired = true. <strong>You must change this to </strong><strong>false</strong> for VS Code, or the installation will fail on the client due to a &quot;missing license pool.&quot;</li></ul><h4>3. Writing the Logic (setup.opsiscript &amp; uninstall.opsiscript)</h4><p>Now, create the scripts in the OPSI folder. For a deep dive into the scripting language, refer to the <a href="https://docs.opsi.org/opsi-docs-en/4.3/opsi-script-manual/opsi-script-script.html">Official OpsiScript Manual</a>.</p><p><strong>The Setup Script </strong>(/var/lib/opsi/workbench/vscode/CLIENT_DATA/setup.opsiscript):</p><pre>[Actions]<br>Message &quot;Installing Visual Studio Code...&quot;<br>Winbatch_install<br>sub_check_exitcode<br><br>[Winbatch_install]<br>; Since the EXE is in the same folder as this script, we call it directly<br>&quot;%ScriptPath%\VSCodeSetup-x64.exe&quot; /VERYSILENT /NORESTART /MERGETASKS=!runcode<br><br>[sub_check_exitcode]<br>if (getLastExitCode = &quot;0&quot;)<br>    comment &quot;Success&quot;<br>else<br>    isFatalError<br>endif</pre><p><strong>The Uninstall Script</strong> (/var/lib/opsi/workbench/vscode/CLIENT_DATA/uninstall.opsiscript):</p><pre>[Actions]<br>Message &quot;Uninstalling Visual Studio Code...&quot;<br>Winbatch_uninstall<br><br>[Winbatch_uninstall]<br>; This calls the local Windows uninstaller created during the setup phase<br>&quot;C:\Program Files\Microsoft VS Code\unins000.exe&quot; /VERYSILENT</pre><h4>4. Build and Install (The Makepackage Phase)</h4><p>Navigate back to the <strong>root</strong> of your product folder (/var/lib/opsi/workbench/vscode). Before running opsi-makepackage, your tree should look like this:</p><pre>vscode/<br>├── OPSI/<br>│   └── control.toml       &lt;-- Metadata (ID, Version, Script names)<br>└── CLIENT_DATA/<br>    ├── setup.opsiscript   &lt;-- Logic moved here<br>    ├── uninstall.opsiscript &lt;-- Logic moved here<br>    └── VSCodeSetup-x64.exe &lt;-- Payload</pre><p><strong>Pro Tip: Optimizing the Build</strong> By default, opsi-makepackage command creates three files: the .opsi package, an .md5 checksum, and a .zsync file for delta-transfers. To speed things up or skip unnecessary files for a simple lab, use:</p><pre>sudo opsi-makepackage --no-md5 --no-zsync</pre><ul><li><strong>Why?</strong> Skipping these ensures you get <em>only</em> the .opsi file, which is all you need for basic deployment.</li></ul><p><strong>Final Installation:</strong> Push the package into the OPSI depot:</p><pre>sudo opsi-package-manager -i vscode_1.0-1.opsi</pre><h3>Part 8: Deploying Products to the Client</h3><p>Once your VS Code package is on the OPSI server, there are exactly four ways to trigger the installation on your Windows client:</p><ol><li><strong>The “Push” Method (Admin UI / Java UI):</strong> You go into the “Product Configuration” tab, select the client, and set the vscode product to the &quot;setup&quot; action. The next time the client starts up or the OPSI service checks in, it will automatically download and install the package.</li><li><strong>The “Event” Method (Reboot/Timer):</strong> The OPSI client on Windows is programmed to look for new tasks during specific “Events” like a computer reboot or a user login. If you have already set the product to “setup” in the database, the client will “pull” the installation the moment the PC restarts.</li><li><strong>The “On-Demand” Method (CLI):</strong> You can force the client to install immediately without waiting for a reboot by using the following command:</li></ol><pre>sudo opsi-admin -d method fireEvent &quot;gui_startup&quot; &quot;client_id&quot;</pre><ol><li><strong>The “Kiosk” Method (Self-Service):</strong> If enabled, the user can open a small app on their Windows desktop, see VS Code in a list, and click “Install” themselves.</li></ol><p>For this guide, we are doing a demo using two different methods to ensure you see the full power of the system.</p><h3>1. Install the OPSI Client Agent on Windows</h3><p>Your OPSI server cannot “force” itself onto a Windows machine; the Windows machine must “check in.”</p><ul><li>In your Windows browser, go to: https://&lt;YOUR_WSL2_IP&gt;:4447/public.</li><li>Navigate to the opsi-client-agent folder.</li><li><strong>Troubleshooting: The Missing .exe Issue:</strong> If you don’t find the installer here, it means the server downloaded the package but didn’t “activate” it. We can solve this by finding the file in the repository and forcing the manager to install it manually:</li></ul><pre>sudo opsi-package-manager -i /var/lib/opsi/repository/opsi-client-agent_*.opsi --force</pre><ul><li>(While you could use Samba or SCP to move files manually, you <strong>must</strong> run this command to generate the customized .exe for your specific server).</li><li><strong>Management Tool:</strong> If you need the Java interface, look under the <strong>Links</strong> section on the main OPSI page and download the opsi-configed (Windows) installer. If it&#39;s missing from the links, run:</li></ul><pre>sudo opsi-package-updater -v install opsi-configed</pre><p>Now, run the downloaded opsi-deploy-client-agent.exe and enter these details:</p><ul><li><strong>Client ID:</strong> Your Windows computer name (Verify this by running hostname in CMD).</li><li><strong>OPSI Service URL:</strong> https://&lt;YOUR_WSL2_IP&gt;:4447 (Verify your IP in WSL with hostname -I).</li><li><strong>Username &amp; Password:</strong> Use the admin credentials you created earlier.</li></ul><p>Click <strong>Install</strong>. This registers the “handshake” between your Windows OS and your WSL2 server.</p><h3>2. Set the “Setup” Action (Java UI Method)</h3><p>Now that the Windows machine is visible in your OPSI list, we will use the Java-based opsi-configed tool:</p><ul><li>Open the Java UI and log in using your server IP.</li><li>Go to the <strong>Clients</strong> tab; your Windows machine should now appear there.</li><li>Click on your client, then go to the <strong>Product Configuration</strong> tab.</li><li>Find your vscode product. Under the <strong>Requested Action</strong> column, change &quot;none&quot; to <strong>&quot;setup&quot;</strong>.</li><li>Click the <strong>Checkmark (Save)</strong> icon at the top to commit the change to the database.</li></ul><h3>3. Trigger the Installation</h3><p>On the Windows machine, you don’t have to wait for a reboot.</p><ul><li>Find the <strong>opsi-client-agent</strong> in the Windows Start Menu or System Tray.</li><li>Click <strong>“Check for OPSI Events”</strong> or <strong>“On Demand”</strong>.</li><li>A window will pop up on your Windows desktop saying <strong>“Installing Visual Studio Code…”</strong> — this confirms your script is running!</li></ul><h3>4. The Final Verification</h3><p>Once the progress bar finishes, check your Windows C:\Program Files\Microsoft VS Code folder. In the OPSI management interface, the status for the vscode product should change from a red/yellow &quot;setup&quot; to a <strong>green &quot;installed&quot;</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=742f4a1b9c2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to configure PM2 on Cloudways]]></title>
            <link>https://thakurguman.medium.com/how-to-configure-pm2-on-cloudways-9c35be2e5acb?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c35be2e5acb</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Sat, 13 Jul 2024 11:42:14 GMT</pubDate>
            <atom:updated>2024-07-13T11:42:14.116Z</atom:updated>
            <content:encoded><![CDATA[<p>When deploying NodeJS applications, managing their lifecycle becomes crucial for uninterrupted operation. Traditional execution in the terminal poses challenges, as terminating the terminal session leads to the application shutting down. To overcome this limitation and ensure continuous availability, PM2 (Process Manager 2) comes into play.</p><ul><li><strong>Installation: </strong>To simplify the installation of PM2, you can use the following script. This script not only installs PM2 but also sets it up to run on system startup:</li></ul><pre>curl -s https://raw.githubusercontent.com/ThakurGumansingh/scripts/main/pm2.sh | bash</pre><ul><li><strong>Verification: </strong>Confirm the successful installation of PM2 by checking its version:</li></ul><pre>pm2 --version</pre><ul><li><strong>Start Your NodeJS Application: </strong>Use PM2 to start your NodeJS application. Replace app.js with your application&#39;s entry file or command:</li></ul><pre>pm2 start app.js<br>or <br>pm2 start &quot;npm run start&quot;</pre><ul><li><strong>Additional PM2 Commands: </strong>Familiarize yourself with common PM2 commands for tasks like restarting, stopping, or deleting a process:</li></ul><pre>pm2 status<br>pm2 restart app<br>pm2 stop app<br>pm2 delete app<br>pm2 delete {process_id}<br>pm2 delete all</pre><h4>Conclusion</h4><p>So in this tutorial, you have successfully learned how to configure PM2 on Cloudways. Please let me know in the comments if this guide was useful for you or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c35be2e5acb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to change Node version on Cloudways]]></title>
            <link>https://thakurguman.medium.com/how-to-change-node-version-on-cloudways-0c547526866d?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c547526866d</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Sat, 13 Jul 2024 11:29:15 GMT</pubDate>
            <atom:updated>2024-07-13T11:55:36.096Z</atom:updated>
            <content:encoded><![CDATA[<p>If you encounter NodeJS version compatibility issues, you can resolve them by leveraging the Node Version Manager (NVM). Follow these steps to ensure a seamless NodeJS version management experience:</p><ul><li><strong>Accessing the Home Directory: </strong>Navigate to your home directory using the following command:</li></ul><pre>cd ~</pre><ul><li><strong>Running NVM Installation Script: </strong>Execute the command below to run the NVM installation script:</li></ul><pre>curl https://gist.githubusercontent.com/cloudways-haider/f7cb6627f6674c263624589d360e12b4/raw/9d0b2c78ace5b7b2dedb411e9d676129e34b470a/nvm_install.sh | bash</pre><ul><li><strong>Refreshing Bash Environment: </strong>Update your Bash environment by sourcing the .bashrc file:</li></ul><pre>source ~/.bashrc</pre><ul><li><strong>Installing Latest LTS NodeJS Version: </strong>Use NVM to install the latest LTS (Long Term Support) version of NodeJS:</li></ul><pre>nvm install --lts<br>nvm use --lts</pre><ul><li><strong>Installing custom NodeJS Version: </strong>Use NVM to install the custom version of NodeJS:</li></ul><pre>nvm install 18.0<br>nvm use 18.0</pre><ul><li><strong>Restarting Bash Shell: </strong>Restart your Bash shell to apply the changes:</li></ul><pre>exec bash</pre><ul><li><strong>Verifying NodeJS and NPM Installation: </strong>Confirm the successful installation of the desired NodeJS version:</li></ul><pre>node --version<br>npm --version</pre><h3>Conclusion</h3><p>In this guide, you’ve learned how to change the NodeJS version on Cloudways using NVM. By following these steps, you can easily switch between NodeJS versions to resolve compatibility issues and ensure your applications run smoothly. If you found this guide helpful, please let me know in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c547526866d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host a NextJS App on Cloudways]]></title>
            <link>https://thakurguman.medium.com/how-to-host-a-nextjs-app-on-cloudways-7ed8316b2e5b?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ed8316b2e5b</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Sat, 13 Jul 2024 07:03:37 GMT</pubDate>
            <atom:updated>2024-07-13T11:45:42.194Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>NextJS is a powerful framework built on top of NodeJS for server-side rendering and generating static websites. It’s excellent for building web applications with enhanced performance and SEO capabilities. However, deploying NextJS (or other NodeJS frameworks like NestJS or React) on managed hosting platforms like Cloudways can present challenges due to default port configurations.</p><h4>Challenges</h4><p>NodeJS applications, including frameworks like NextJS , NestJS, and others, typically run on specific ports such as 3000, 4000, or another chosen port. Cloudways, for security reasons, restricts access to only essential web traffic ports (80 and 443). This limitation necessitates rerouting traffic from these default ports to the port where your app is running.</p><h4>Resolution</h4><p>To resolve this, we’ll reroute traffic from the default ports (80 or 443) to the port where your app is running (e.g., port 3000) using the Apache mod_proxy module. This redirection allows your NextJS application to be accessible while adhering to Cloudways’ security measures.</p><p>If you are confused with my statement above, then this figure below will help you in building your concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qMa_Pj4z2snBq3rL.png" /></figure><p>So are you ready to get started then let’s go.</p><h4>User Selection</h4><p>When working with the application user on Cloudways, their access is restricted to the app’s public_html folder, which serves as the web root. This limited access prevents the application user from reaching other directories essential for NodeJS operations, such as installing modules like PM2 or accessing configuration files like .bashrc, which are typically located outside the public_html directory. Therefore, to perform these tasks effectively and ensure all necessary directories and configurations are accessible, it&#39;s crucial to use the<strong> master user</strong>, who has broader permissions and can interact more comprehensively with the server environment.</p><h4>Step 1: Launch a PHP Application</h4><p>First of all, let’s install a PHP app on Cloudways, you can refer to the official <a href="https://support.cloudways.com/en/articles/5124126-how-to-add-an-application-on-the-cloudways-platform"><strong><em>guide</em> </strong></a>which explains how to add a new app on your existing Cloudways servers.</p><p>Upon installing a PHP application, navigate to the application’s “public_html” directory. To upload your NodeJS project, you have a couple of options:</p><ol><li><strong>Using SSH or FileZilla:</strong> You can upload your NodeJS project via SSH or FileZilla. For detailed instructions, please refer to the official <a href="https://support.cloudways.com/en/articles/5119485-guide-to-connecting-to-your-application-using-ssh-sftp"><strong><em>guide</em> </strong></a>provided by Cloudways. This guide explains how to add, upload, or modify files on the server.</li><li><strong>Integrating Git(optional):</strong> Alternatively, you can integrate Git to manage your project and pull changes from your GitHub repository. For step-by-step instructions, you can follow this <a href="https://support.cloudways.com/en/articles/5124087-deploy-code-to-your-application-using-git"><strong><em>guide</em></strong></a><em>.</em></li></ol><p>These methods offer flexibility and convenience in uploading and managing your NodeJS project within your PHP application on Cloudways.</p><h4>Step 2: Setup your NextJS App</h4><p>After successfully uploading the files to the server, you can access the server using SSH and follow these steps to install the NextJS modules:</p><ul><li>Connect to the server using SSH. Once you’re connected, navigate to the directory where your NextJS project is located using the cd command. For example:</li></ul><pre>cd /home/master/applications/$dbname/public_html/project_dir</pre><p>Replace $dbname with the database name which you will find under your application name and project_dir with the folder in which you have uploaded the content of your project, if you have directly uploaded the content to public_html you can skip looking for any other folder inside the public_html.</p><ul><li>Run the following command to install the NextJS modules using npm:</li></ul><pre>npm install</pre><p>This will download and install all the required NextJS modules and dependencies for your project on the server. Make sure you are in the correct directory containing your NextJS project when running the npm install command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*DRKj5n-OjtpLawPn.jpg" /></figure><p>This is the part where you have deployed your app successfully on Cloudways but you can’t access it as port 3000 is blocked from the firewall.</p><p><strong>Permission Issues:</strong> If you face the permissions issue while installing packages, please refer to this <a href="https://support.cloudways.com/en/articles/5126387-how-can-i-reset-file-and-folder-permissions">guide</a> to reset the permissions to master user from the Cloudways platform.</p><h4>Step 3: Cloning a NextJS Repository</h4><p>For demonstration purposes, clone a NextJS repository from GitHub. Navigate to the public_html directory and run:</p><pre>git clone https://github.com/Abdullah-moiz/Job-Portal.git</pre><p>The data will be cloned into the Job-Portal folder. You have two options:</p><ul><li>Move the data to public_html</li><li>Setup job-portal as your webroot.</li></ul><ol><li><strong>Move the Data</strong> to public_html:</li></ol><pre>cd Job-Portal<br>mv * ../<br>mv .[^.]* ../   # To move hidden files as well<br>cd ..<br>rm -rf Job-Portal</pre><p>2. <strong>Change the Web Root</strong>: Set the web root of the application under Cloudways platform:</p><ul><li>Go to <strong>Applications</strong> &gt;&gt; <strong>ApplicationName</strong> &gt;&gt; <strong>Application Settings</strong> &gt;&gt; <strong>General</strong> &gt;&gt; <strong>Webroot</strong>.</li><li>Change the webroot to Job-Portal or rename the folder to a desired name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YlN4jmHKL8V74emQ0LvthQ.png" /><figcaption>Chnaging webroot.</figcaption></figure><h4>Step 4: Check the Port Configuration</h4><p>Check the port your app is running on. Look in the main file, package.json, or an environment file. If not specified, run:</p><pre>npm start<br>or <br>npm run start</pre><h4>Step 5: Adding redirection rules to htaccess file</h4><p>You can follow these steps to add the necessary rules in your .htaccess file:</p><ul><li>Access your server via SSH as mentioned earlier.</li><li>Navigate to your project’s root directory, which is typically the “public_html” directory. You can use the following command to go to that directory:</li></ul><pre>cd /home/master/applications/$dbname/public_html</pre><p>Replace $dbname with your actual database name.</p><ol><li>Open the .htaccess file for editing using a text editor like nano: nano .htaccess</li><li>Paste the following code inside the .htaccess file:</li></ol><pre># Redirect traffic to your port 3000<br>RewriteEngine On<br>RewriteBase / <br>RewriteRule ^(.*)?$ http://127.0.0.1:3000/$1 [P,L]</pre><p>These rules will redirect traffic to port 3000, enabling you to run your NodeJS application on that port while taking advantage of mod_proxy to handle the redirection.</p><h4>Setup mod_proxy</h4><p>It’s important to note that Cloudways servers have mod_proxy disabled by default. So if you incur the following error:</p><pre>No protocol handler was valid for the URL /favicon.ico (scheme &#39;http&#39;). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.</pre><p>You can contact Cloudways support to request enabling mod_proxy for your application. Mod_proxy is required to be enabled only once, so if you have this already enabled, then you are good to go…</p><h4>Step 6: Install and Start NextJS</h4><p>To start the NextJS app, run the command:</p><pre>npm start<br>or <br>npm run start</pre><h4><strong>Build the Code</strong></h4><p>Building the application is a crucial step for production deployment. During the build process, NextJS optimizes your application by minifying JavaScript, optimizing images, and generating static HTML for pages where possible. This process improves the performance and speed of your application, making it ready for production use. If you get error like following, it means that the build has not been created, which is necessary for running the app in production mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3FvOeS8VI2Fq8al11xPDQ.png" /><figcaption>NextJS build error</figcaption></figure><pre>npm run build</pre><p>If the build fails, ensure you are using a compatible NodeJS version (Node 18 or higher). If needed, you can change the node version following this <a href="https://thakurguman.medium.com/how-to-change-node-version-on-cloudways-0c547526866d"><strong><em>guide</em></strong></a><strong><em>.</em></strong></p><h4>Step 7: Testing the Configuration</h4><p>Visit your application like<em> </em><a href="https://yourdomain.com/"><em>https://yourdomain.com</em></a> or your Cloudways default URL which will be like <a href="https://phpstack-xxxxxx-xxxxxx.cloudwaysapps.com/"><em>https://phpstack-XXXXXX-XXXXXX.cloudwaysapps.com/</em></a><em>. </em>If successful, you should see the output on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xN60QNbioyBIuLyoswZwlw.png" /><figcaption>Final output of the cloned Github repo</figcaption></figure><h4>Configure PM2 on the app(optional)</h4><p>To configure PM2 on your app, follow the steps to ensure continuous operation and efficient process management. For a detailed information, refer to this <a href="https://thakurguman.medium.com/how-to-configure-pm2-on-cloudways-9c35be2e5acb"><strong><em>guide</em></strong></a><em>.</em></p><h4><strong>Addressing 404 Errors on Internal Pages in NextJS App</strong></h4><p>When deploying NextJS applications, particularly those with dynamic routes or special characters in file names, you may encounter 404 errors on internal pages. This issue often arises because NextJS expects to find its optimized production build in a .next directory by default. However, due to deployment configurations or manual interventions, the build might be located in a directory named _next instead. This discrepancy causes NextJS to fail in locating its required assets for serving internal pages, leading to 404 errors.</p><p><strong>Resolution Steps: </strong>Navigate to the next.config.js file in your NextJS project and adjust the distDir property to specify the correct build directory.</p><pre>module.exports = {<br>// Set the directory name for client build.<br>    distDir: &#39;_next&#39;,<br>};<br><br>//now create the build again and restart the app<br>npm run build</pre><h4>Conclusion</h4><p>So in this tutorial, you have successfully learn how you can run a NextJS app on Cloudways, please let me know in the comment section if this guide was useful for you or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ed8316b2e5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy a Vite App with React and JavaScript on Cloudways]]></title>
            <link>https://thakurguman.medium.com/deploying-vite-with-react-and-javascript-typescript-on-cloudways-7177361bbdae?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/7177361bbdae</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 09:36:09 GMT</pubDate>
            <atom:updated>2024-07-13T12:04:43.779Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p>In this guide, we’ll go through the steps of setting up a Vite project with React and JavaScript/TypeScript on Cloudways. We’ll cover connecting to your Cloudways server via SSH, updating Node.js to version 18 using NVM, installing Vite boilerplate or cloning a repository from GitHub, and addressing Vite’s default IPv6 behavior.</p><h4><strong>Step 1: Connect to Cloudways Server via SSH:</strong></h4><p>Follow Cloudways’ SSH guide at <a href="https://support.cloudways.com/en/articles/5119485-guide-to-connecting-to-your-application-using-ssh-sftp">Connecting to Your Application Using SSH/SFTP</a>. Once connected, navigate to the public_html folder using the following command:</p><pre>cd /home/master/applications/dbname/public_html</pre><p>Replace the dbname with the database name of your application, which you can find under the Access Details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*xE19IZv5OGA9stX11iWieg.png" /></figure><h4><strong>Step 2: Check Node version</strong></h4><p>To run a Vite app, you need Node version 18 or higher. Check your Node version with the command node -v or node --version. If your Node version is less than 18, follow this <a href="https://thakurguman.medium.com/how-to-change-node-version-on-cloudways-0c547526866d"><strong><em>guide </em></strong></a>to update it.</p><h4><strong>Step 3: Install Vite or Clone Repository, and Install Dependencies:</strong></h4><ul><li><strong>Install Vite boilerplate using either of the following commands:</strong></li></ul><pre>npm create vite@latest <br># OR <br>yarn create vite</pre><p>Enter the project name when prompted or press Enter to set the default name to “vite-project”. Next, I will be choosing React here, you may choose any preferred Framework you like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*MP5UO5rDK7oAy-tIN8W8rA.png" /><figcaption>Framework prompt</figcaption></figure><p>Then choose the Variation, I will choose JavaScript here, you may select TypeScript or any other:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*qaoqC1kdS7PvXYMTNs0WbA.png" /><figcaption>Variation prompt</figcaption></figure><p>Once done, you will have a folder created with your project name, default would be “vite-project”.</p><ul><li><strong>Navigate to the repository directory:</strong></li></ul><pre>cd project-name<br># OR <br>cd vite-project</pre><ul><li><strong>Move the repository files to the parent directory:</strong></li></ul><pre>mv * ../</pre><ul><li><strong>If you have an existing repository, clone it from GitHub:</strong></li></ul><pre>git clone [repository_URL]</pre><ul><li><strong>Navigate to the repository directory:</strong></li></ul><pre>cd repository_name</pre><ul><li><strong>Move the repository files to the parent directory:</strong></li></ul><pre>mv * ../</pre><ul><li><strong>Install project dependencies:</strong></li></ul><p>Regardless of whether you’ve installed the default boilerplate or cloned the repository, at this stage, we’ve moved the files to the “public_html” folder. Afterward, install the dependencies. If you prefer setting the web_root as the project_name or repository_name, you can omit moving the files to “public_html” and update the web_root in the application settings.</p><pre>npm install</pre><h4><strong>Step 4: Adjust Vite for IPv4 and Create .htaccess:</strong></h4><ul><li><strong>Open the </strong><strong>package.json file and modify the &quot;dev&quot; script to include </strong><strong>--host 127.0.0.1:</strong></li></ul><pre>&quot;scripts&quot;: {   &quot;dev&quot;: &quot;vite --host 127.0.0.1&quot; }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*kUn9jzWhlSbgPmy_rO2DMA.png" /><figcaption>Configuring the host value in the package.json file</figcaption></figure><ul><li><strong>Create an </strong><strong>.htaccess file and add the following rules:</strong></li></ul><pre>DirectoryIndex disabled <br>RewriteEngine On RewriteBase / <br>RewriteRule ^(.*)?$ http://127.0.0.1:4173/$1 [P,L]</pre><h4><strong>Conclusion:</strong></h4><p>You’ve now successfully set up Vite with React and JavaScript on Cloudways. Whether you’re starting a new project or working with an existing repository, these steps ensure a smooth deployment. Feel free to explore further optimizations based on your project requirements. If you face any issue with Vite deployment, you can check this Vite troubleshooting guide: <a href="https://medium.com/@thakurguman/resolving-vite-issues-on-cloudways-a-comprehensive-troubleshooting-guide-dca7ae8889ce">Resolving Vite Issues on Cloudways: A Comprehensive Troubleshooting Guide</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7177361bbdae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving the “Uncaught Error: Class ‘WP_Upgrader_Skin’ not found” on Cloudways]]></title>
            <link>https://thakurguman.medium.com/resolving-the-uncaught-error-class-wp-upgrader-skin-not-found-on-cloudways-c9f43e71d076?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9f43e71d076</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 07:34:30 GMT</pubDate>
            <atom:updated>2024-01-04T07:52:01.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1-KVsfSHDAd-yfWEjfnNg.png" /></figure><p>Are you encountering the frustrating “Uncaught Error: Class ‘WP_Upgrader_Skin’ not found” issue in your WordPress site? Fear not, as I’ve got a straightforward solution for you.</p><p>Follow these steps to banish the error and get your WordPress site back on track:</p><ol><li><strong>Login to Your WordPress Admin:</strong> Start by logging in to your WordPress admin panel. This is your gateway to resolving the issue efficiently.</li><li><strong>Navigate to the Plugins Section:</strong> Once inside the admin, head over to the Plugins section. Here’s where we’ll make a crucial addition to tackle the error.</li><li><strong>Install the “WP Crontrol” Plugin:</strong> Search for and install the “WP Crontrol” plugin. This tool will give you the control you need to manage cron events effectively.</li><li><strong>Access the Cron Events via Tools:</strong> After installing the plugin, go toTools → Cron Events. This is where you’ll find the magic wand to fix the error.</li><li><strong>Identify and Remove the Culprit Event:</strong> In the Cron Events section, look for an event named “breeze_after_update_scheduled_hook”. This is the troublemaker causing the error. Select it and remove it from the list.</li><li><strong>Happy Hacking:</strong> With the problematic cron event eliminated, you’re all set! Your WordPress site should now be free from the “Uncaught Error: Class ‘WP_Upgrader_Skin’ not found” issue. Happy hacking and enjoy a smoothly running website.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9f43e71d076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host a NodeJS App on Cloudways]]></title>
            <link>https://thakurguman.medium.com/how-to-host-a-nodejs-app-on-cloudways-120daa55e7fa?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/120daa55e7fa</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 07:07:20 GMT</pubDate>
            <atom:updated>2024-08-07T07:03:57.673Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>NodeJS is a server-side JavaScript environment that’s great for web apps. It comes with a handy package manager called NPM for managing dependencies. However, NodeJS apps typically don’t run on the default web server ports (80 or 443), which can be a challenge on managed hosting platforms like Cloudways with strict security rules.</p><h4>Challenges</h4><p>NodeJS applications typically run on specific ports such as 3000, 4000, or any other chosen port. However, when utilizing Cloudways, for security purposes, default configurations restrict access to specific ports, allowing only essential ports such as 80 and 443 for web traffic. This can pose a challenge when you want to run a NodeJS application on a different port.</p><h4>Resolution</h4><p>To address this, we’ll reroute traffic from the default ports (i.e., 80 or 443) to the port where your app is running (let’s assume port 3000 for this tutorial) using the Apache mod_proxy module. This redirection allows your NodeJS application to be accessible while adhering to Cloudways’ security measures.</p><p>If you are confused with my statement above, then this figure below will help you in building your concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qMa_Pj4z2snBq3rL.png" /></figure><p>So are you ready to get started then let’s go.</p><h4>User Selection</h4><p>Begin by consistently accessing the server with the master user instead of the application user. The application user’s restricted privileges may lead to permission issues, so opting for the master user ensures a smoother and more comprehensive server interaction.</p><h4>Step 1: Launch a PHP Application</h4><p>First of all, let’s install a PHP app on Cloudways, you can refer to the official <a href="https://medium.com/r?url=https%3A%2F%2Fsupport.cloudways.com%2Fhow-to-add-an-application-to-an-existing-server%2F"><strong><em>guide</em></strong></a><strong><em> </em></strong>which explains how to add a new app on your existing Cloudways servers.</p><p>Upon installing a PHP application, navigate to the application’s “public_html” directory. To upload your NodeJS project, you have a couple of options:</p><ol><li><strong>Using SSH or FileZilla:</strong> You can upload your NodeJS project via SSH or FileZilla. For detailed instructions, please refer to the official <a href="https://support.cloudways.com/en/articles/5119485-guide-to-connecting-to-your-application-using-ssh-sftp"><strong><em>guide</em></strong></a><strong><em> </em></strong>provided by Cloudways here. This guide explains how to add, upload, or modify files on the server.</li><li><strong>Integrating Git:</strong> Alternatively, you can integrate Git to manage your project and pull changes from your GitHub repository. For step-by-step instructions, you can follow the <a href="https://support.cloudways.com/en/articles/5124087-deploy-code-to-your-application-using-git"><strong><em>guide</em></strong></a><strong><em>.</em></strong></li></ol><p>These methods offer flexibility and convenience in uploading and managing your NodeJS project within your PHP application on Cloudways.</p><h4>Step 2: Setup your NodeJS App</h4><p>After successfully uploading the files to the server, you can access the server using SSH and follow these steps to install the NodeJS modules:</p><ul><li>Connect to the server using SSH. Once you’re connected, navigate to the directory where your NodeJS project is located using the cd command. For example:</li></ul><pre>cd /home/master/applications/$dbname/public_html/project_dir</pre><p>Replace $dbname with the database name which you will find under your application name and project_dir with the folder in which you have uploaded the content of your project, if you have directly uploaded the content to public_html you can skip looking for any other folder inside the public_html.</p><ul><li>Run the following command to install the NodeJS modules using npm:</li></ul><pre>npm install</pre><p>This will download and install all the required NodeJS modules and dependencies for your project on the server. Make sure you are in the correct directory containing your NodeJS project when running the npm install command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*DRKj5n-OjtpLawPn.jpg" /></figure><p>This is the part where you have deployed your app successfully on Cloudways but you can’t access it as port 3000 is blocked from the firewall.</p><p><strong>Permission Issues:</strong> If you face the permissions issue while installing packages, please refer to this <a href="https://support.cloudways.com/en/articles/5126387-how-can-i-reset-file-and-folder-permissions"><em>guide</em></a><em> </em>to reset the permissions to master user from the Cloudways platform.</p><h4>NodeJS version Issues</h4><p>If you encounter NodeJS version compatibility issues, you can resolve them by leveraging the Node Version Manager (NVM). Follow this <a href="https://thakurguman.medium.com/how-to-change-node-version-on-cloudways-0c547526866d"><strong><em>guide</em></strong></a><strong><em> </em></strong>to change node version using NVM.</p><h4>Step 3: Setup mod_proxy</h4><p>It’s important to note that Cloudways might have mod_proxy disabled by default. In such cases, you can contact Cloudways support to request enabling mod_proxy for your application.</p><h4>Step 4: Adding redirection rules to htaccess File</h4><p>You can follow these steps to add the necessary rules in your .htaccess file:</p><ul><li>Access your server via SSH as mentioned earlier.</li><li>Navigate to your project’s root directory, which is typically the “public_html” directory. You can use the following command to go to that directory:</li></ul><pre>cd /home/master/applications/$dbname/public_html</pre><p>Replace $dbname with your actual database name.</p><ol><li>Open the .htaccess file for editing using a text editor like nano: nano .htaccess</li><li>Paste the following code inside the .htaccess file:</li></ol><pre># Redirect traffic to your port 3000<br>RewriteEngine On<br>RewriteBase / <br>RewriteRule ^(.*)?$ http://127.0.0.1:3000/$1 [P,L]</pre><p>These rules will redirect traffic to port 3000, enabling you to run your NodeJS application on that port while taking advantage of mod_proxy to handle the redirection.</p><h4>Step 5: Testing the Configuration</h4><p>To verify that your setup is functioning correctly, follow these steps to create an index.js file and add a simple “Hello World” code:</p><ul><li><strong>Navigate to root Directory: </strong>Ensure you are in your project’s root directory using the SSH commands mentioned earlier:</li></ul><pre>cd /home/master/applications/$dbname/public_html</pre><ul><li><strong>Create index.js File: </strong>Use a text editor to create a new file named “index.js”. You can use commands like:</li></ul><pre>nano index.js</pre><p>This opens the nano text editor. Alternatively, you can use other editors like vi or vim.</p><ul><li><strong>Add “Hello World” Code: </strong>Insert the following basic “Hello World” code into your index.js file:</li></ul><pre>const http = require(&#39;http&#39;);<br><br>const server = http.createServer((req, res) =&gt; {<br>  res.writeHead(200, {&#39;Content-Type&#39;: &#39;text/plain&#39;});<br>  res.end(&#39;Hello World!\n&#39;);<br>});<br><br>const PORT = 3000;<br>server.listen(PORT, () =&gt; {<br>  console.log(`Server running at http://localhost:${PORT}/`);<br>});</pre><ul><li><strong>Save and Exit: </strong>Save the changes made to the file and exit the text editor (in nano, you can press Ctrl + X, then confirm with Y).</li><li><strong>Test the Setup: </strong>Execute your NodeJS script to ensure everything is working as expected:</li></ul><pre>node index.js</pre><p>Visit your application like<em> </em><a href="https://yourdomain.com/"><em>https://yourdomain.com</em></a> or your Cloudways default URL which will be like <a href="https://phpstack-xxxxxx-xxxxxx.cloudwaysapps.com/"><em>https://phpstack-XXXXXX-XXXXXX.cloudwaysapps.com/</em></a><em>. </em>If successful, you should see the “Hello World!” message printed in the terminal.</p><p>If you’ve added your own project to this directory, be sure to delete the index.js file after testing. This precautionary measure helps prevent any potential conflicts with your actual code files.</p><h4><strong>Installing PM2 for Process Management</strong></h4><p>When deploying Node.js applications, managing their lifecycle becomes crucial for uninterrupted operation. Traditional execution in the terminal poses challenges, as terminating the terminal session leads to the application shutting down. To overcome this limitation and ensure continuous availability, PM2 (Process Manager 2) comes into play. Please follow this <a href="https://thakurguman.medium.com/how-to-configure-pm2-on-cloudways-9c35be2e5acb"><strong><em>guide</em></strong></a><strong><em> </em></strong>to configure PM2 on your server.</p><h4>Conclusion</h4><p>So in this tutorial, you have successfully learn how you can run a NodeJS app on Cloudways, let me know in the comment section if this guide was useful for you or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=120daa55e7fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving Vite Issues on Cloudways: A Comprehensive Troubleshooting Guide]]></title>
            <link>https://thakurguman.medium.com/resolving-vite-issues-on-cloudways-a-comprehensive-troubleshooting-guide-dca7ae8889ce?source=rss-144b78d4a917------2</link>
            <guid isPermaLink="false">https://medium.com/p/dca7ae8889ce</guid>
            <dc:creator><![CDATA[Thakur Gumansingh]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 06:48:36 GMT</pubDate>
            <atom:updated>2024-01-11T08:44:10.816Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>Vite, a blazing-fast web development build tool, occasionally poses challenges during development and deployment. In this guide, we’ll explore common issues and provide step-by-step solutions to ensure a smooth Vite experience.</p><h4>User Selection:</h4><p>Begin by consistently accessing the server with the master user instead of the application user. The application user’s restricted privileges may lead to permission issues, so opting for the master user ensures a smoother and more comprehensive server interaction.</p><h4>Use Two Terminals:</h4><p>Leverage two terminals for efficient management. In one terminal, execute your commands, and in the other, use netstat -tlpn to verify whether the application is utilizing IPv4 or IPv6. Check for ‘tcp6’ at the start, indicating IPv6 usage, and note that ‘::1’ signifies IPv6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*bsEExGUag6XSm0Xuj0Xb6Q.png" /><figcaption>Verifying if the Vite is using IPv6 address</figcaption></figure><p>If IPv6 is detected, specify ‘ — host 127.0.0.1’ in the package.json file for both ‘vite dev’ and ‘preview’ commands to ensure proper configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*rE3L1o5Cex_4be3BXWwwSA.png" /><figcaption>Configuring the host value in the package.json file</figcaption></figure><h4>Building and Previewing:</h4><p>Execute ‘npm run build’ to create a build of your site. Follow up with ‘npm run preview’ and access the URL. Note that the preview runs on port 4173 by default; adjust this in the .htaccess file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*3rT2MlFrTXQ-O8e-5pvSgA.png" /><figcaption>Adding the preview port in htaccess file</figcaption></figure><h4>Changing Ports for npm run Start:</h4><p>If the preview works fine, change the port to 5173 in the .htaccess file and access the URL after running ‘npm run start’.</p><h4>How to set a custom port for Vite:</h4><ul><li>Open your package.json file.</li><li>Locate the “scripts” section and find the script that starts your Vite development server.</li><li>Add the --port flag with your desired port number. For example:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*u7bUCVgBjVYGLiBLoh6ntQ.png" /><figcaption>specifying custom port in package.json file</figcaption></figure><ul><li>Update the port in htaccess file as well:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*0-knbVkfWckz9gupNilDGA.png" /><figcaption>Updating the port 3000 in htaccess file</figcaption></figure><h3>Troubleshooting:</h3><ol><li><strong>Check Apache Error Logs: </strong>Start troubleshooting by examining Apache error logs. Look for proxy errors and enable ‘mod_proxy’ if necessary.</li><li><strong>Connection to Backend Failed:</strong> If there’s a connection to the backend failure, it might be due to IPv6. Define the host (127.0.0.1) in the package.json file to ensure proper communication.</li><li><strong>403 Forbidden Error:</strong> Investigate the console and network tabs for the specific URL causing a 403 error. This often requires a build, so create one with npm run buildcommand and run the preview again.</li><li><strong>Internal Server Error: </strong>In order to ensure proper file fetching from the build directory, locate the index.html file in the root directory of your project. Within this file, identify the &lt;script type&gt; tag referencing the main JavaScript file, and adjust the src attribute from its current absolute path (&quot;/src/main.jsx&quot;) to a relative path (&quot;./src/main.jsx&quot;). This modification ensures the correct linkage to files in the build directory.</li></ol><h3>Conclusion:</h3><p>By following these steps, you can navigate and resolve common Vite issues on Cloudways efficiently. Keep your development environment up-to-date, use two terminals for effective management, and troubleshoot methodically for a seamless Vite experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dca7ae8889ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>