How to run a html file on localhost (any port) - html

I am creating a website using HTML, CSS and js with java for server side. I need to run it on localhost.
Extra info: I am using mac os x 11 (el capitan)
I have already tried python and node.js but it clashes with java
So i need a technology that won't clash with java and will help me localhost on mac

IIRC macOS comes with PHP preinstalled, and PHP has built-in web-server which should be enough for serving static content.
So, open Terminal.app and then:
cd your/project/dir
php -S localhost:8080
After than you can navigate to http://localhost:8080/ and see your site in the browser (given you have index.html in your project, otherwise there will be "Not Found" message).
There are more advanced and/or less terminal-oriented ways, of course, but since you already tinkering with python and node, another terminal command should not be a problem.
BTW, you might want to look at that terminal window from time to time, as it outputs nice log of what things were requested from server. Good if you want to check for invalid references, 404 errors, etc. Here is a sample output:
$ php -S localhost:8080
PHP 7.3.6 Development Server started at Sat Jun 22 20:00:28 2019
Listening on http://localhost:8080
Document root is /private/tmp/test
Press Ctrl-C to quit.
[Sat Jun 22 20:00:32 2019] [::1]:51640 [200]: /
[Sat Jun 22 20:00:32 2019] [::1]:51641 [200]: /style.css
[Sat Jun 22 20:02:35 2019] [::1]:51670 [404]: /oops.html - No such file or directory
As you can see, root folder (/, which was translated to index.html in my case) and a stylesheet (style.css) were requested and successfully delivered (code is 200). But non-existent file oops.html resulted in error (code is 404).

You can use caddy
Install: brew install caddy
To serve static files from the current working directory, run:
caddy file-server --browse --listen :2015
Caddy's default port is 2015, so open your browser to http://localhost:2015.

Related

Configure Laravel using Virtualmin on Ubuntu 20.04

I have recently migrated to a new server, which now uses virtualmin. I'm trying to configure laravel on the new server, but am having trouble with it and cannot find any examples online.
I have downloaded the laravel-project from the old server and saved it in the following directory on the new server:
/home/domain/public_html/laravel-project
My DocumentRoot in /etc/Apache2/sites-available is:
DocumentRoot /home/domain/public_html/public
I have the following set up in /etc/host:
MYSQL server listening address (IP) laravel-project
My .env file is pointing to the same MySQL server listening address
My index.php file within /home/domain/public_html/laravel-project/public has the following line:
$app = require_once __DIR__.'/../bootstrap/app.php';
I have the following output in the error log:
[Wed Jun 02 13:26:44.163271 2021] [authz_core:error] [pid 1579245:tid 140072238184192] [client 141.101.98.53:14020] AH01630: client denied by server configuration: /home/domain/public_html/public
Any advice would be much appreciated.
I had the same problem i solved it with
try to upload the application via Virtualmin file manager (.zip) and check Extract Compressed.
move all the folders and files from laravel-project to the public_html folder so that it becomes public_html/app public_html/public etc.
No need to change .conf, you just need to change folder path in virtualmin->server configuration->website options and input your path to change website document sub-directory

UltraESB when run from netbeans IDE gives "service not found" error in ultraesb soa toolbox but works fine when run from cmd

The following is default proxy service in ultraesb file "ultra-unit.xml"
<u:proxy id="echo-proxy">
<u:transport id="http-8280"/>
<u:target>
<u:inSequence>
<u:class name="sample.SimpleJavaMediation1"/>
</u:inSequence>
<u:inDestination>
<u:address>http://localhost:9000/service/EchoService</u:address>
</u:inDestination>
<u:outSequence>
<u:java><![CDATA[
System.out.println("Reply payload : " + mediation.readPayloadAsString(msg));
]]></u:java>
</u:outSequence>
<u:outDestination>
<u:address type="response"/>
</u:outDestination>
</u:target>
</u:proxy>
I run ultraesb from Netbeans IDE and run toolbox.bat from command line (as there is no other way to run toolbox). When i send message to "http://localhost:8280/service/echo-proxy" using Ultraesb toolbox, it gives me following error
HTTP/1.1 404 Not Found
Date: Mon, 13 Jun 2016 07:34:40 GMT
Server: UltraESB/2.3.0 (GA)
Content-Length: 17
Content-Type: text/plain; charset=ISO-8859-1
Connection: close
Service not found
BUT when i run ultraesb.bat and toolbox.bat from commandline cmd....the service is perfectly accessed in toolbox and no error appears....
I really cant understand whats the issue...
Toolbox doesnt have log file whereas ultraesb log file exists which doesnt have any exception....no exception appears on Netbeans IDE console also. Please Help.
By looking at your description it seems like the proxy service has not been deployed over the 8280 transport listener, as there doesn't seem to be any error logs on the UltraESB log. This could happen if the deployment unit is not deployed. NetBeans IDE configuration on the standalone distribution of UltraESB ships with 2 run profiles of UltraESB one for the default server, another for the samples. If you are running the sample run profile it doesn't by default deploy the deployment units.
You got to either run the default server run profile or enable the deployment units in the environment bean of the ultra-root.xml. For more information on the NetBeans IDE setup please refer to the documentation

CakePHP 3 - Enable SSL on development server [duplicate]

OS: Ubuntu 12.04 64-bit
PHP version: 5.4.6-2~precise+1
When I test an https page I am writing through the built-in webserver (php5 -S localhost:8000), Firefox (16.0.1) says "Problem loading: The connection was interrupted", while the terminal tells me "::1:37026 Invalid request (Unsupported SSL request)".
phpinfo() tells me:
Registered Stream Socket Transports: tcp, udp, unix, udg, ssl, sslv3,
tls
[curl] SSL: Yes
SSL Version: OpenSSL/1.0.1
openssl:
OpenSSL support: enabled
OpenSSL Library Version OpenSSL 1.0.1 14 Mar 2012
OpenSSL Header Version OpenSSL 1.0.1 14 Mar 2012
Yes, http pages work just fine.
Any ideas?
See the manual section on the built-in webserver shim:
http://php.net/manual/en/features.commandline.webserver.php
It doesn't support SSL encryption. It's for plain HTTP requests. The openssl extension and function support is unrelated. It does not accept requests or send responses over the stream wrappers.
If you want SSL to run over it, try a stunnel wrapper:
php -S localhost:8000 &
stunnel3 -d 443 -r 8080
It's just for toying anyway.
It's been three years since the last update; here's how I got it working in 2021 on macOS (as an extension to mario's answer):
# Install stunnel
brew install stunnel
# Find the configuration directory
cd /usr/local/etc/stunnel
# Copy the sample conf file to actual conf file
cp stunnel.conf-sample stunnel.conf
# Edit conf
vim stunnel.conf
Modify stunnel.conf so it looks like this:
(all other options can be deleted)
; **************************************************************************
; * Global options *
; **************************************************************************
; Debugging stuff (may be useful for troubleshooting)
; Enable foreground = yes to make stunnel work with Homebrew services
foreground = yes
debug = info
output = /usr/local/var/log/stunnel.log
; **************************************************************************
; * Service definitions (remove all services for inetd mode) *
; **************************************************************************
; ***************************************** Example TLS server mode services
; TLS front-end to a web server
[https]
accept = 443
connect = 8000
cert = /usr/local/etc/stunnel/stunnel.pem
; "TIMEOUTclose = 0" is a workaround for a design flaw in Microsoft SChannel
; Microsoft implementations do not use TLS close-notify alert and thus they
; are vulnerable to truncation attacks
;TIMEOUTclose = 0
This accepts HTTPS / SSL at port 443 and connects to a local webserver running at port 8000, using stunnel's default bogus cert at /usr/local/etc/stunnel/stunnel.pem. Log level is info and log outputs are written to /usr/local/var/log/stunnel.log.
Start stunnel:
brew services start stunnel # Different for Linux
Start the webserver:
php -S localhost:8000
Now you can visit https://localhost:443 to visit your webserver: screenshot
There should be a cert error and you'll have to click through a browser warning but that gets you to the point where you can hit your localhost with HTTPS requests, for development.
I've been learning nginx and Laravel recently, and this error has came up many times. It's hard to diagnose because you need to align nginx with Laravel and also the SSL settings in your operating system at the same time (assuming you are making a self-signed cert).
If you are on Windows, it is even more difficult because you have to fight unix carriage returns when dealing with SSL certs. Sometimes you can go through the steps correctly, but you get ruined by cert validation issues. I find the trick is to make the certs in Ubuntu or Mac and email them to yourself, or use the linux subsystem.
In my case, I kept running into an issue where I declare HTTPS somewhere but php artisan serve only works on HTTP.
I just caused this Invalid request (Unsupported SSL request) error again after SSL was hooked up fine. It turned out to be that I was using Axios to make a POST request to https://. Changing it to POST http:// fixed it.
My recommendation to anyone would be to take a look at where and how HTTP/HTTPS is being used.
The textbook definition is probably something like php artisan serve only works over HTTP but requires underlying SSL layer.
Use Ngrok
Expose your server's port like so:
ngrok http <server port>
Browse with the ngrok's secure public address (the one with https).
Note: Though it works like a charm, it seems an overkill since it requires internet and would appreciate better recommendations.

Setting up Ghost on Subdomain with Hidden Port - Windows Server 2008 with Apache

Before I start, I should say I am running XAMPP on Windows Server 2008 R2. I have node.exe allowed through my firewall, as well as port 2368. I have also been following the instructions here with no success.
I have my Ghost installed here.
As you can see, Ghost is only loading with the port as part of the web address.
If you try and load the site without the port like so, you get an Internal Server error.
My vHosts file for Ghost is:
<VirtualHost *:80>
ServerName blog.theobearman.com
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:2368/
</VirtualHost>
My config.js file is here. Please note that 198.37.105.108 in the config file is the IP of my server.
Error logs for the Internal Server error are as follows:
[Fri May 15 17:56:25.495296 2015] [proxy:warn] [pid 56352:tid 1580] [client 86.147.117.154:58787] AH01144: No protocol handler was valid for the URL /error/HTTP_INTERNAL_SERVER_ERROR.html.var. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://blog.theobearman.com/
I would appreciate it if somone could tell me what I need to do so that when you navigate to "http://blog.theobearman.com", Ghost will load without the need for the port as part of the web address.
Thanks in advance!
You likely need to enable the proxy module for Apache:
# Enable the modules.
a2enmod proxy_http
a2enmod proxy
# Restart Apache
service apache2 restart

Sublime Text 2 - There are no packages available for installation

So many Sublime Text 2 users get error (or) no action when they want to install any sublime text 2 package #via Package Control.
When I'm clicked on Package Control: Install Package from Ctrl+Shift+P.
I got this below error:
There are no packages available for installation
Note: Some times error message is not displayed and no action is happened.
When I'm tracing error report from console. I got this below error on console.
Package Control: Trying to execute command /usr/bin/curl --user-agent 'Sublime Package Control v2.0.0' --connect-timeout 30 -sSL --compressed --dump-header /tmp/tmpwQjJVT --header 'If-Modified-Since: Sun, 03 Aug 2014 12:10:13 GMT' --cacert /usr/lib/ssl/certs/ca-certificates.crt -v https://sublime.wbond.net/channel.json
Package Control: Curl HTTP Debug General
Hostname was NOT found in DNS cache
Trying 50.116.34.243...
Trying 2600:3c02:e000:42::1...
connect to 2600:3c02:e000:42::1 port 443 failed: Network is unreachable
Failed to connect to sublime.wbond.net port 443: Network is unreachable
Closing connection 0
Package Control: Error downloading channel. curl: (7) Failed to connect to sublime.wbond.net port 443: Network is unreachable downloading https://sublime.wbond.net/channel.json.
error: Package Control
There are no packages available for installation
How to solve this problem?
This error is happened with IPv6 problem. If your Internet Service
Provider (ISP) does not support for IPv6 you will get this error.
How to solve this on Unix (OSX/Linux/Ubuntu/CentOS/etc...):
Open terminal and run this below command line.
sudo echo "50.116.34.243 sublime.wbond.net" >> /etc/hosts
How to solve this on Windows:
Click on start button on your windows desktop and find cmd.
Now right click on Command Prompt option and select Run as administrator.
Run this below command line on CMD.
echo 50.116.34.243 sublime.wbond.net >> "C:\Windows\system32\drivers\etc\hosts"
Do not hard-code the current ip of sublime.wbond.net. This will not solve the problem, and will only break your machine's connection to Package Control in the near future.
If you are having trouble with ipv6, use the latest version from https://github.com/wbond/package_control. It has a fix for curl and wget when they encounter issues with computers that provide ipv6 via DNS, but can not actually access sites via ipv6.
If you are still having trouble with Package Control, follow the instructions at https://packagecontrol.io/docs/issues. Please be sure to include a debug log, otherwise I can't help.
Three stps to solve this problem on Mac in China.
add "0.116.34.243 sublime.wbond.net" into /etc/host
open Global Mode of Shadowsocks (needed only in China)
restart Sublime
I had the same problem today, and after a long search I found out that packagecontrol.io website was down!