server

Express.js - app.listen vs server.listen

拈花ヽ惹草 提交于 2019-11-26 03:46:19
问题 This may be a very basic question but I simply don\'t get it. What is the difference between creating an app using Express.js and starting the app listening on port 1234, for example: var express = require(\'express\'); var app = express(); //app.configure, app.use etc app.listen(1234); and adding an http server: var express = require(\'express\'); var http = require(\'http\'); var app = express(); var server = http.createServer(app); //app.configure, app.use etc server.listen(1234); What\'s

How to make a node.js application run permanently?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 03:31:45
问题 On a Debian server, I installed Node.js. I understand how to launch an app from putty with this command line: node /srv/www/MyUserAccount/server/server.js and get to it on the address 50.51.52.53:8080 (IP and port). But as soon as I close putty, then I cannot reach the address 50.51.52.53:8080 anymore. How to make a Node.js application run permanently? As you can guess, I am a beginner with Linux and Node.js. 回答1: Although the other answers solve the OP's problem, they are all overkill and do

Apache2: 'AH01630: client denied by server configuration'

巧了我就是萌 提交于 2019-11-26 01:48:38
问题 I get this error when trying to access localhost via a browser. AH01630: client denied by server configuration I checked my site folder permissions using: sudo chmod 777 -R * Here is my configuration file: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/user-name/www/myproject <Directory /> Options FollowSymLinks AllowOverride all Allow from all </Directory> <Location /> Allow from all Order Deny,Allow </Location> <Directory /home/user-name/www/myproject/> Options

Getting the screen resolution using PHP

此生再无相见时 提交于 2019-11-26 01:22:54
问题 I need to find the screen resolution of a users screen who visits my website? 回答1: You can't do it with pure PHP. You must do it with JavaScript. There are several articles written on how to do this. Essentially, you can set a cookie or you can even do some Ajax to send the info to a PHP script. If you use jQuery, you can do it something like this: jquery: $(function() { $.post('some_script.php', { width: screen.width, height:screen.height }, function(json) { if(json.outcome == 'success') { /

How to configure port for a Spring Boot application

好久不见. 提交于 2019-11-26 00:29:33
问题 How do I configure the TCP/IP port listened on by a Spring Boot application, so it does not use the default port of 8080. 回答1: As said in docs either set server.port as system property using command line option to jvm -Dserver.port=8090 or add application.properties in /src/main/resources/ with server.port=8090 For random port use server.port=0 回答2: There are two main ways to change the port in the Embedded Tomcat in a Spring Boot Application. Modify application.properties First you can try

Using node.js as a simple web server

谁说胖子不能爱 提交于 2019-11-25 23:59:08
问题 I want to run a very simple HTTP server. Every GET request to example.com should get index.html served to it but as a regular HTML page (i.e., same experience as when you read normal web pages). Using the code below, I can read the content of index.html . How do I serve index.html as a regular web page? var http = require(\'http\'); var fs = require(\'fs\'); var index = fs.readFileSync(\'index.html\'); http.createServer(function (req, res) { res.writeHead(200, {\'Content-Type\': \'text/plain\

Apache2: &#39;AH01630: client denied by server configuration&#39;

≡放荡痞女 提交于 2019-11-25 23:30:38
I get this error when trying to access localhost via a browser. AH01630: client denied by server configuration I checked my site folder permissions using: sudo chmod 777 -R * Here is my configuration file: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/user-name/www/myproject <Directory /> Options FollowSymLinks AllowOverride all Allow from all </Directory> <Location /> Allow from all Order Deny,Allow </Location> <Directory /home/user-name/www/myproject/> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> ScriptAlias

How do I run a node.js app as a background service?

与世无争的帅哥 提交于 2019-11-25 23:12:47
问题 Since this post has gotten a lot of attention over the years, I\'ve listed the top solutions per platform at the bottom of this post. Original post : I want my node.js server to run in the background, i.e.: when I close my terminal I want my server to keep running. I\'ve googled this and came up with this tutorial, however it doesn\'t work as intended. So instead of using that daemon script, I thought I just used the output redirection (the 2>&1 >> file part), but this too does not exit - I