I am new in reactjs and nodejs.I made an application with react frontend and express backend. There are axios post and get requests for get data from mssql database via express.
When the project in production level, I write the IPv4 address and port for access dashboard from another device in local network. After build,when I use for example localhost:5000 for requests, I can see all datas which are come from database in the device which react project running but with this I cant see datas from android phone in local network.
What should I do? Isn't there any other way than writing a static IP address? This project can be run different machines.
I am sorry for my spelling mistakes.
It's my first time here so please bear with me :)
Basically i developped a full stack MERN web application on my windows 10 machine (node js, express js and Mongodb in the backend + database and react js for the frontend), to run each one of them for now i use vscode (nodemon server for the backend and npm start for the front) all are running on my localhost on different ports.
what i need to do is to move that MERN app to an ubuntu machine and make it accessible via LAN network of that ubuntu continuously.
i guess i need to use git to move the app from windows to ubuntu? (correct me if i'm wrong) but how to make it run correctly there? and should i install a specific server to run it all on the LAN?
Thank you for the help in advance !
I am trying to upload my site. it's a node.js repo on a linux instance on amazon light sail services.
I uploaded my source code repository to my Virtual Server Instance with static IP using FileZilla through a SSh pem key(all fine i guess..), also I modified the file for the apache server as mentioned in the walk-though tutorial but, I am not able to make it show when I write http://54.87.121.120/spanishwithalex/server/
Before I upload my repo I tried with a simple app that worked perfectly,but now i don't know why it doesn't work. I tried various ports, different locations and various forms but I think I am walking in circles.
I attached some pictures to show where I located my files and the error messages.
I hope it's some how clear.
Thanks
location in my instance
structure repo
error message
apache conf
I'm not great on apache config, but I walked through this enough to get you going:
SFTP or SCP your code to a new folder called /opt/bitnami/apache2/spanishwithalex
Edit /opt/bitnami/apache2/conf/bitnami/bitnami.conf using VIM or whatever and replace every line that has this /opt/bitnami/apache2/htdocs
with this: /opt/bitnami/apache2/spanishwithalex
Restart Apache:
sudo /opt/bitnami/ctlscript.sh restart apache
Let me know if that gets it working for you.
I am trying to build a hybrid app, I am using jquery mobile. The app is supposed to be installed on the mobile and not a web-app. I tried doing some research but still couldn't understand how to accomplish what I want.
I want to insert a form for the user to fill (such as: mail, name, telephone, text) and I want that when submitted the fields will be mailed to myself.
I understand that it isn't possible to insert php to jquery mobile because it doesn't support it or something like that. However, I saw that it's possible to call a php script through AJAX. But I don't get how it's done because PHP is server side it has to be hosted somewhere right?
So I need to host on the web a php file and call it through the app by it's URL?
I have found a php script that does exactly what I want but I don't understand if it's useable through hybrid app.
I also read that javascript can't mail something straight to my email address, it only has the mailto function which opens a mail form.
I couldn't find an answer to that, and I would really appreciate if someone could explain to me how it works and if it's even possible.
Its very easy, but for a beginner it may be a daunting task to set up so ill write Plenty of Notes and Installation tasks to get you started.
Prerequisites for a Home Setup with PHP and EMAIL Capabilities. For Remote Hosting Setup I guess everything is Installed for you but may require some Cost, so for Home use and doing it by yourself the bonus is that its Free.
1) A Spare Computer with at least 1gig of ram and 10gigs of hard disk. if you don't have a spare one or cant afford one at he moment you may be able to Virtualize one on top of your current computer using something like Virtual box which is free. If you want 100% live service the computer must be on all the time and connected to the Internet.
2) A Server OS preferably Linux one. In this example will use UBUNTU Server. Why? Because its Very easy to setup and install extra utilities, frameworks and programs, easy to manage and has all the features you will ever need and its Fast.
3) A Mail Account. GMAIL as an example for sending emails.
4) an Internet Connection.
5) A network Cable to connect the computer to your Router. Even if you choose Wireless over a Network Cable to connect you may need to download additional drivers to get your Wireless card Working and Connecting Most likely you will need a Net Cable first. It is advisable not to use Wireless for Such Setup for a number of Reasons such as Security, Loss of Connection (Weak Signal) etc
That's it. Total Installation time About 35 minutes. 25 mins for installing the OS and 10 mins for the rest of setup so you can send emails Via PHP.
The Setup
1) Install UBUNTU Server Visit Ubuntu to Download the Latest Version.
Server not the Desktop Version as its a bit slower than the Server version. However the downside to using the Server version is that you need to learn some basic commands on how to edit, copy, move, delete, change permissions of files around the server via command line. But its not rocket science.
On the good side hosting websites on Linux Server which may hold 100's of files of scripts, CSS, and Web pages, what you can do is install SAMBA server which enables you to share your web folder(s) or any folder for that matter over your Local Network or from Outside so on another PC using Lets say Windows can connect to that folder and will enable you to use all your favorite software on windows for editing and Saving those files on your Linux Server which is easier rather than using editing utilities directly on the server. takes about a minute to install and setup a Samba server. I will add that to the bottom of this Guide.
once that's done
2) Install LAMP Server
This will Install
Apache Web Server, Mysql Database, and PHP
Pretty much all you need to start hosting websites (Apache), have databases (Mysql) for web uses and a server side language to handle all the work (PHP).
command
(sudo is required in ubuntu in front of commands so you can run them in admin mode which is more Secure. It will ask you for your account password, before running the rest of the command)
sudo tasksel install lamp-server
Let it run, It will Auto download the required files so make sure you are connected to the internet. The only question you will be asked is type in a password for the root access of Mysql database.
Apache, Mysql, PHP can be further configured so there is some basic learning curve for the future.
I never had to configure Mysql, for Apache configuration i usually change the Path to where my website is and some Security settings. The default directory where your web related files go into is (/var/www/html). This html directory is where all the PHP, HTML files go into. However, there's no Reason why you cant rename this folder and reconfigure apache to directly use it as your root web folder. Ill explain how to do this near the end of this guide. For PHP configuration, you may need at some point to install extra extensions such as php5-imagick which is a library for editing images using PHP. There are many extensions that can enable PHP to do many things.
Halfway there
Email Setup using Postfix which is a way to send emails
command
sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
After a few moments it will Present You with Some Options In setting Up Mail.
You want (Internet Site) i think its the 3rd option Down. Choose this
You will then see your hostname. No action Required here, Continue
That's the Mail Done, but we need to configure some bits to it so it knows about the mail configuration
open your postfix config file
command
sudo nano /etc/postfix/main.cf
add the following in the file, you can put it add the end of the file
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
you may see (relayhost =) already in the file. what you can do is delete that line and add all the above there.
nano is a text editor, so freely move with the cursor keys up down, delete, type etc. When you finish editing. do CNTRL X and press Y (Yes) to write and exit the file. If you made a mistake in the file press N (No) to just exit without writing to the file.
Almost there
edit the Postfix email Account Information file and insert (In our example Gmail account) logging information.
command
sudo nano /etc/postfix/sasl_passwd
should be a blank file, so insert
[smtp.gmail.com]:587 USERNAME#gmail.com:PASSWORD
change USERNAME#gmail.com to your email account and PASSWORD to the emails password. It needs this info so Postfix can connect to Gmail and send mails
I suggest creating a new fresh email account with your App's Name.
my_app_name#gmail.com so you have a distinguished account name for sending emails through your app.
CNTRL X and Y to save and exit the file
Now we fix some permissions to the files
Fix permission and update postfix config to use sasl_passwd file:
commands
sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
Next, validate certificates. You say what??? Just run the following command, Do you see a bunch of Random characters about 200 of them? If so that's your servers Certificate for sending Mails.
command (no further action is required as cat is the command to just list a file on screen)
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
ALL DONE You can send mails now, However we made some changes to the files above so lets reload Postfix first to take in the changes.
command
sudo /etc/init.d/postfix reload
Do a test
command to send an email from the server
echo "This is my first test mail from my server" | mail -s "From Me" myemail#gmail.com
Check did you get the mail?
If yes then you are able to send mails directly from the server
Ok now that you can send emails from your web server you need to use Ajax Post to post the form data in your java script files over to a PHP file on your web server and compose the email and send it.
Before you consider buying a domain name (mywebsitename.com) you can start testing using the WAN address of your home router.
If you don't know the current address open a browser and type (What is my WAN address)
eg.
http://wanip.info/
this will show your WAN address. xxx.xxx.xxx.xx
this is the number you put in to your AJAX requests
example
$.ajax({
method: "POST",
url: "http://xxx.xxx.xxx.xxx/some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
More info about Ajax here
http://api.jquery.com/jquery.ajax/
But first we finish off completing some minor tasks
You router needs to know your webeservers IP address so it can send HTTP requests and Data to it.
How to find the Webserver IP and Routers IP addresses using Linux
command
ifconfig
you will something like this
eth0 Link encap:Ethernet HWaddr 08:00:27:87:35:25
inet addr:192.168.2.15 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe87:3525/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:861 errors:0 dropped:0 overruns:0 frame:0
TX packets:549 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:125639 (125.6 KB) TX bytes:63563 (63.5 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:56 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3360 (3.3 KB) TX bytes:3360 (3.3 KB)
You are Interested in the Ethernet Network Card eth0 (if you have installed more than one network card you may also see (eth1, eth2 etc) and this inet addr:192.168.2.15 is your servers address. Not Static Yet
command
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
this 192.168.2.1 (under the Gateway next to 0.0.0.0) is the Routers Local Address
Please note, yours may be different
open a browser and type that in
http://192.168.2.1
you will be presented with your routers home page. Log in and find Virtual Servers settings. Should be in the General Firewall Options.
You should see a Table like this
Depending on your routers model you should see something similar. Use the drop down menu and choose WEB HTTP. Click add. The 80 80 .. that's the ports the firewall will open for WEB communication. Enter the last 2 digits of your web servers address and click Save. Your router may reboot to save the changes.
Lets install SAMBA server so you can share your web folder to your Local Network so you can access it from a local PC. In this example we use Windows.
command
sudo apt-get install samba
After it has finished Installing edit the samba configuration file so we can add the folder we want to share in our case /var/www/
command
sudo nano /etc/samba/smb.conf
go to the bottom of the file and add
[share]
comment = Ubuntu File Server Share
path = /var/www/
browsable = yes
guest ok = yes
read only = no
create mask = 0777
CNTRL X and Y to save and exit the file
i suggest checking the net for samba share configuration as the above setup does not have much security in mind. You can do much more like request a password to connect, disable guests, etc.
we change the Permissions of the web Folders to full. Although not recommended, as you have a blank web folder you should inherit normal user permissions as you create files and when you learn about changing permissions of files and directories on Linux in the future you change them.
command
sudo chmod -R 777 /var/www/
basically the 777 is spread into 3 levels of permissions and it represents binary 111/ 111/111 -- binary number (111) is in the real world 7 so READ(1), WRITE(1), EXECUTE(1) are all turned on for those 3 levels which its not very secure. I suggest you read more about the chmod command and file permissions to get a better understanding about its use.
It's time to give the server a Reboot
sudo shutdown -r now
Now The Reboot is done, Lets connect to that shared Web Folder
Assuming you have a PC running windows connected to the same Local Network as the web server (Mac should be something similar but check on how to connect to a shared drive)
Open Computer, choose Map Network Drive type in the web servers IP address e.g \\192.168.2.23\ - click Browse You should see the folder we shared in the SAMBA configuration file. Connect to it.
Treat that drive like any drive to save your files only this one is the root folder of your web server website(s) folder.
However on the webserver if you don't want the default html folder eg you want a custom name for your website, on windows right click on the folder and rename it.
If you do rename it you need to let Apache know by doing the following
command
sudo nano /etc/apache2/sites-enabled/000-default.conf
change DocumentRoot /var/www/html to DocumentRoot /var/www/thenewname
CNTRL X and Y to exit nano
restart apache webserver to take in the change
sudo /etc/init.d/apache2 restart
do a test page
write a simple index.html webpage or index.php php page and save it in the web folder
open a browser and type in your WAN adress
here is a link on how to compose and send an email with PHP
https://css-tricks.com/sending-nice-html-email-with-php/
Ok last note
You have everything running, but Home Routers Have Reserve IP address that give each local PC automatically when they connect to the network. Not a big issue, but its best to give the web server a static IP address
Log in to your router again and go to your Lan Setup specifically we want to check the DHCP Server IP Pool Settings. Dhcp is responsible for giving out IP address automatically to each PC in a local network so it reserves around 100 of these out of possible 253 address on a home router. We need to check the range and choose one above that range.
You should see something like this. From 192.168.2.2 to 192.168.2.100 are reserved by the Dhcp service. So logic has it we can choose 192.168.2.101 as an address for the server as this is not used by the Dhcp service. In fact 192.168.2.101 to 192.168.2.254 are free as the complete range of a routers IP address are from 2 to 254 the 0, 1 and 255 are used by the router.
edit the network file on your webserver
command
sudo nano /etc/network/interfaces
Copy what you see below, (without the //remarks) and delete the existing setup in the configuration file for eth0 which is the Ethernet card 0.
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.2.101 //the chosen IP address for the webserver
gateway 192.168.2.1 // the routers address
netmask 255.255.255.0 // leave this as is
network 192.168.2.0 // change x.x.2.x if you are on the 1 network. ie 192.168.1.0 some routers are on the 1 network
broadcast 192.168.2.255 // same as above
dns-nameservers 8.8.8.8 //check below
CNTRL X and Y to exit nano
Just to clarify dns-nameservers 8.8.8.8 uses a Google Public DNS server to translate web address to IP addresses. Its a general use one. You can change that to any Public DNS Address you know, but it is required because we now have manual settings for the webserver.
Reboot the server again to load in the changes to the network and lastly log in to your router and change the IP number for your Virtual server to send HTTP Requests as shown in the above Step we did earlier.
I hope this guide helps you
This question already exists:
How to run d3 Javascript
Closed 8 years ago.
I am trying to set up d3 Javascript by following this link:
https://github.com/mbostock/d3/wiki . I am currently using Eclipse Juno and Tomcat in Mac 10.5.8. basically I am trying to run a simple Force-Directed graph example that was taken from the following link:
https://gist.github.com/mbostock/4062045
I have been recommended to insert the command below into the Terminal in order to get d3 run:
python -m SimpleHTTPServer 8888 &
With the Web Browser (Firefox in my case), I can insert:
http://localhost:8888/
. When I do this, I get the following message in the browser:
If you can see this, it means that the installation of the Apache web server software
on this system was successful. You may now add content to this directory and replace this page.
Seeing this instead of the website you expected?
This page is here because the site administrator has changed the configuration of this
web server. Please contact the person responsible for maintaining this server with questions.
The Apache Software Foundation, which wrote the web server software this site
administrator is using, has nothing to do with maintaining this site and cannot help resolve configuration issues.
The Apache documentation has been included with this distribution.
You are free to use the image below on an Apache-powered web server. Thanks for using Apache!
What that message means and why am I getting this type of message? How can I get the d3 run so long as I am getting this message?
It looks like that Apache and python are competing for the same port and since you start python in the background mode, it is not reporting the errors correctly.
Try starting python -m SimpleHTTPServer without an argument. It should start on port 8000 and serve the files from the folder it is started from.
The next steps would be to move the html file and the json file in the same folder where you started the server from. Then point your browser to http://localhost:8000/<name-of-your-html-file>.html.