How to run my html file with apache2 - apache

Maybe it is not a right channel to ask this question but I donot know where to ask.
I want to know how to run html file with apache on my ubuntu. I have written program with javascript and a html file and I want to run it via apache. I could not find htdocs folder in to copy my files there beside that I do not have permission to do that in ubuntu. My apache is installed in /usr/share/apache2.
When I write http://localhost it says:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
but I do not know where to add the contents.
any help.

The default folder that it serves the HTML files from is /var/www.
For example, /var/www/test.html would be http://localhost/test.html.

In my case where I have installed and running the Apache 2 and if I type localhost/ into the browser it opens the Apache 2 Ubuntu default Page.
Now what I did was:
Suppose your HTML webpage Demo.html is located in the Website directory then copy the HTML page using one of the commands:
:~$ cp ~/Website/Demo.html /var/www/html
If this command does not work then try with the following command:
:~$ sudo cp ~/Website/Demo.html /var/www/html
And then open your browser and type this the browser search bar:
localhost/Demo.html
It will open the copied Demo.html.
Also if you want to access this hosted webpage from the outside of the machine where Apache 2 is running then use it's external IP address instead of localhost as follows:
ExternalIP/Demo.html

Related

Adding a Shared folder also as Document Root

I am running Apache 2.4.41 on Linux Mint 20.
My document root is home/www/.
I have a laptop also connected using Samba.
I would like to add a shared folder also (from the laptop) to the Document Root settings.
How do I do it without removing home/www/?
On your laptop, enable sharing of a folder. Lets say C:\LinuxShare.
On mint, install Samba to mount that folder. Mount it on /mnt/LinuxShare.
When that works...
Identify the user running your Apache. You can start is and do ps -ef | grep httpd, it will show you the user. Or look in httpd.conf, directive User.
Configure the permissions on /mnt/LinuxShare so that the user identified in 3) can read files under that directory. You could use a group, or others permissions (for home it's ok, for corporate network, do not use others!).
When you have validated that the Apache user can read files under /mnt/LinuxShare
In your VirtualHost, add Alias /wwwpc /mnt/LinuxShare
Also add a <Directory /mnt/LinuxShare> section to allow reading that directory.
Restart Apache
on the laptop, put an HTML file (lets say SOMEPAGE.html) in C:\LinuxShare. Make sure you can see it on mint under /mnt/LinuxShare.
on mint, start a browser and try http://localhost/wwwpc/SOMEPAGE.html. You should see the page.
on the laptop, start a browser and try http://THE_IP_OF_THE_MINT/wwwpc/SOMEPAGE.html. Remember that Apache runs on mint, so on the laptop you cannot access it via localhost.

Setting up Programm-o locally

After reading the installation guide for program-o http://blog.program-o.com/documentation-v2/installation/ I was wondering how I would go about doing step 2 locally and installing it without hosting an online server?
Just put your code in htdocs directory (inside xampp instalation directory).
Then You will be able to execute your code by typing 'localhost' in your browser.
Or if you want to use other domain instead of localhost, You have to edit your hosts file.
In Windows7 hosts file is located in:
%systemroot%\system32\drivers\etc
My hosts file for example:
127.0.0.1 domain.com
I can access my code by typing for example 'domain.com' instead of 'localhost'

Where to put website files in Bitnami LAMP Ubuntu server

Wheres the default folder in Bitnami LAMP? The server is running but I dont know where to put my html files? I mean in comparison with XAMPP and WAMP, the default is you put it on xampp/htdocs/ or wamp/www/.
I've tried using the /opt/bitnami/apache2/htdocs/ and it works but I don't know if thats the default folder to put my website files in LAMP.
Yes, that is the default folder for your HTML or PHP files. You can also add applications on top of Bitnami LAMP and they will be installed at /opt/bitnami/apps/ folder.
HTML and php files, Bitnami on Google Cloud Platform server are in
/opt/bitnami/apache/htdocs
Config file httpd.conf in
/opt/bitnami/apache/conf
HTML and program files on my AWS Bitnami server are in:
/home/bitnami/apps/wordpress/htdocs
Config file httpd.conf it's in:
/opt/bitnami/apache/conf

How to set which folder to load with apache2 server?

My friend introduce me Linode and register.com, so I am playing with it now. I already get a domain name, while on my Linode server I am trying to set up a basic webpage so I can start to use it for my personal website. I'm following http://library.linode.com/hosting-website#sph_web-server to set up.
Here's the question, I made a testsite folder on my linode server, and a /etc/apache2/sites-available/testsite file which can be called at sudo a2ensite testsite command. (All of these are part of the tutorial.) But when I wish to switch the content for that website, I created a testsite1 and a /etc/apache2/sites-available/testsite1, then I do sudo a2ensite testsite1, but I don't know how to let the apache read the content from my testsite1 folder instead of testsite folder. The way I did that is I try sudo a2dissite testsite, so then the content in testsite1 can be read. But I hope there is better way to do that. Also I've heard apache2 can handle multiple server at the same time. How to assign which server load which folder on my linux machine? (For example, if I have abc.net and efg.net, I already link both of them to my linode server, how can I let abc.net go to read the abc folder in my linux server, while the efg.net load my efg folder?) Thanks.
You need to edit the httpd.conf file usually found in /etc/apache2/conf. Then edit the httpd.conf file and look for "Document Root" setting in this file. Change it to /etc/apache2/sites-available/testsite1 and then restart apache: /etc/init.d/apache2 restart

jquery on localhost

I am using Linuxmint (= ubuntu linux 9.10)
I installed LAmp server which have apache,php mysql
and now i am trying to write jquery code
i made a file and it worked perfectly with this link : file:///var/www/jquery/jquery.html
but when i use this link, then it doesnt work anymore : http://localhost/jquery/jquery.html
the file jquery.min.js is in the same folder
and i already changed the src of it in source code to
<script type="text/javascript" src="/var/www/jquery/jquery.min.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
but none of them works (with localhost link)
using firebug I saw these errors:
The requested URL /var/www/jquery/jquery.min.js was not found on this server.
You don't have permission to access /jquery/jquery.min.js
on this server.
Apache/2.2.12 (Ubuntu) Server at localhost Port 80
so what do I have to do to make it run?
The second approach should work, if the apache server has read access to file /var/www/jquery/jquery.min.js.
If apache's user is wwwrun and the group is www, do the following:
chmod -R 0744 /var/www/
chown -R wwwrun:www /var/www/
This will ensure, that the apache user will have the rights to view, execute, etc. the files in your web-folder.
You also need to make sure your Apache configuration allows you to serve js files.
Try to access http://localhost/jquery/jquery.min.js and see if you can get the file.