OpenLiteSpeed NodeJS
Jun 28, 2024
Listeners, and add Your Domain to HTTP/HTTPS. Step 3. Certbot Once the DNS records are set up, you can generate the SSL certi cate. Be sure to substitute the correct domain name in the following command: certbot certonly --webroot -w /var/www/html/ -d example.com -d www.exampl If certi cate veri cation is a success, you should nd your certi cate les stored in /etc/letsencrypt/ Step 4. Set SSL for HTTPS Navigate to OpenLiteSpeed Web Server WebAdmin > Listeners > SSL, and edit the following three items: /Private Key File = /etc/letsencrypt/live/example.com/privkey.pem Certi cate File = /etc/letsencrypt/live/example.com/fullchain.pem Chained Certi cate = Yes Save and perform a Graceful Restart. Now your server should support TLS1.1, TLS 1.2, and TLS 1.3. Step 5. Redirect HTTP to HTTPS HTTPS traf c on port 443 is already allowed through the rewall. After you set up HTTPS, you can optionally rewrite all HTTP traf c to HTTPS. Add the following rules to OpenLiteSpeed Web Server WebAdmin > Virtual Hosts > Rewrite > Rewrite Rules RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R,L] Method for Uploading Files You can serve les from the web server by adding them to the web root using SFTP or other tools. Frequently Asked Questions How do I Reset my Web Server WebAdmin Password? If you forget your password, you may run the following command to reset it: //usr/local/lsws/admin/misc/admpass.sh It will ask for the WebAdmin username, which should be admin . Then, enter your new password. How do I Create Additional Virtual Hosts? Auto Setup via Script This method will automatically set up Listener/VirtualHost/Force SSL/Let''s Encrypt/WordPress. Interactive mode wget https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh chmod +x vhsetup.sh bash vhsetup.sh Or just run the script without downloading it: /bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh ) CLI mode wget https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh chmod +x vhsetup.sh bash vhsetup.sh -d www.example.com -le admin@example.com -f -w Or just run the script without downloading it: /bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud- image/master/Setup/vhsetup.sh ) -d www.example.com -le admin@example.com -f -w Please be sure that your domain is already pointing to the server when using -le YOUR_EMAIL Please be sure that your environment has php/sql service/sql root password when using -w Manual Setup By default, OpenLiteSpeed has an example virtual host already created. You can create more virtual hosts if you like. See Create Virtual Hosts on OpenLiteSpeed. How do I Create Additional Apps by Context? /How do I Change the Node.js Startup File? If you want to change the default startup le name from app.js to node.js , just update the Context and set Startup File = node.js . How do I upgrade NodeJS to latest stable version Install NodeJS by using n module sudo n stable install : node-vX.X.X mkdir : /usr/local/n/versions/node/X.X.X fetch : https://nodejs.org/dist/vX.X.X/node-vX.X.X-linux-x64.tar.g ######################################################################### installed : vX.X.X Setup binary link ln -sf /usr/local/n/versions/node/X.X.X/bin/node /usr/bin/node How do I use an Express app on this image? Setting up an Express app is easy. First, install the Express.js module: npm install express --save Then, change your startup le ( app.js ) from a NodeJS program to an Express JS program: const express = require(''express'') const app = express() const port = 3000 app.get(''/'', (req, res) => res.send(''Hello World from OpenLitespeed Expre app.listen(port, () => console.log(`Example app listening on port ${port} Finally, restart OpenLiteSpeed: /service lsws restart And you''re done! /">