I am newbie to Ubuntu and trying to migrate from Windows but there is something I can't understand in web developing.
In windows I just install the server and make a folder in the
www
folder orhtdoc
and this folder works as a site to me when I ask it through the browser I can access it in Ubuntu. I installedlamp
andphpmyadmin
and created the folder in/var/www
. After, I changed the permissions forwww
to777
so I can create the folder throughnetbeans
but still I can't access my site from the browser.I searched and I found weird instructions. From 10 steps why is that I am simply using the desktop version of Ubuntu 14.04 LTS. I don't want to make it a universal site for people. It is just for my testing propose only. Could anyone help me?
In order to define multiple sites you should define "Name-based virtual hosts".
Try to add in your apache configuration file this directive:
This configuration define two virtual hosts associated with any ip, port 80.
Now, to edit your
/etc/hosts
file, run this as a single command:/etc/hosts file is static table lookup for host names.
It is used to resolve names in the absence of dns server.
Finally restart apache server and verify
http://firstSite.localhost/
andhttp://secondSite.localhost/
I don't know about lamp and phpmyadmin but you can install an apache server and it's just as you described in Windows. The root directory in the latest version is now "/var/www/html" instead of "/var/www" and the "it works" page is "/var/www/html/index.html" .
You can directly edit the code in the "index.html" file (easiest) or you can specify another file to use by editing the conf file "/etc/apache2/apache2.conf" .
To reload apache after changing the "index.html" file, you can run the following command:
To access the page from a web browser, go to
http://localhost
,http://127.0.0.1
, or use the ip statically assigned or otherwise provided by DHCP.I recommend visiting the default index.html page before changing it as there is now some useful information beyond the typical "it works".
For even more info, visit the apache2 manual with the following command.
and
You do have to unzip this file.
UPDATE
In the most recent version of apache2 provided by ubuntu and unlike windows "the default document root is [now] located [in the] /var/www/html" archive (folder) instead of /var/www archive (folder) like it used to be. You can make virtual hosts in /var/www if you want to but if you "just want to access a folder or new website you created with a browser" you need to drop them in the /var/www/html/* directory instead of /var/www/ .
If you have another site (firstsite.html), drop it in "/var/www/html/firstsite.html"
To access this page from your browser, go navigate to the URL "
http://127.0.0.1/firstsite.html
" just as you would have done from windows.