I've shown previously how to install a LAMP server in Ubuntu. If the purpose of your LAMP installation was to set up your own web development environment, then you may want to do some further configuration to your system. This Apache howto is not intended to cover Apache configuration in depth. This is just some basic configuration to help you set up a web development environment in Linux. For more information, see the official Apache documentation.
Why Change the Apache Configuration?
By default, Apache is set up for your web site's files to be in the /var/www directory. This is fine if you only want to work on one website and access it through http://localhost/. But what if you want to work on several websites at the same time? Well, one solution is to create different directories under /var/www like /var/www/site1 and then access it through http://localhost/site1/. I prefer a more elegant solution.
I prefer to build websites in a directory under my own ID. I can then configure the Apache http server to point to the site directories with URLs like http://site1/, http://site2/, etc.
Creating a Web Development Directory
Lets start off by creating a folder structure for the development environment. You can do this from your file manager. I prefer the terminal.
mkdir webdev
cd webdev
mkdir site1 site2
We now have a directory called webdev under our home directory. Within the webdev directory are two directories called site1 and site2.
Create Some Test Files
Now we're going to create some basic test files so that we know our Apache configuration worked. Again, I'm going to use the terminal to create these files, but feel free to use your favorite text editor.
echo 'Site1 works!' > index.html
cd ../site2
echo 'Site2 works!' > index.html
Enable the Sites in Apache
OK, we're now ready to do the actual Apache configuration. Go to /etc/apache2/sites-available.
As root, copy the default file as site1.
Repeat the process to create a site2 file.
As root, edit the site1 configuration file.
Edit the file to look like this (the changes are in bold).
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName site1 DocumentRoot /home/yourID/webdev/site1/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/yourID/webdev/site1/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
Note: The line that changes AllowOverride None to AllowOverride All is required if you want to enable URL re-writes through a .htaccess file. You need this if you want to utilize pretty permalinks in WordPress.
You now need to enable your new site.
You should get a message telling you that you need to reload Apache to activate the new configuration. But first you need to edit your /etc/hosts file.
Edit the first line adding site1 to the end of the line so it looks something like this and save the file.
127.0.0.1 localhost site1
You can now reload Apache.
Site1 is now enabled. Check it by browsing to http://site1/. If everything worked right, you should see a web page that says "Site1 works!"
Repeat the procedure to enable site2, etc.
Edit 12-Dec-09
If you get an error like “apache2: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for localhost,” you can fix it with this command.
echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
Then, reload Apache to eliminate the error.
sudo /etc/init.d/apache2 reload
#
site site1 does not exiist ! i got this error when i tryed sudo a2ensite site1
#
Hello i want to change cacti default login page such as "please enter your cacti user name and password" this sentence do not contain login page , how do i change configuration file. please help me.
#
I've got:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.10 (Ubuntu) Server at borgauf.macsyma Port 80
Here's my conf file:
ServerAdmin webmaster@localhost
ServerName borgauf.macsyma
DocumentRoot /home/lawrence/webdev/borgauf.macsyma
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
Not sure what's wrong. Also did
chmod 775 webdev webdev/borgauf.macsyma
#
This is absolutely the best tutorial on setting up apache on the web. You did a wonderful job here and I am grateful to have found this and configured my server with the greatest o ease. Thank you!
#
Thanks. I'm glad you found it helpful.
#
thank for this post.
very good.
#
I have followed this tutorial to a Tee but everytime I enter either site1 or site2 it just loads the default apache page and NOT my Site1 works! index page? Can anyone help me, I'm using ubuntu 12.10 with all the latest updates and upgrades, It is a fresh install and have ONLY installed the lamp stack following the tutorial at the top of the page. please help
#
If you're using Firefox as your web browser, try clearing the browser cache. I can't tell you the number of times that Firefox has driven me crazy because of that. Alternatively, try installing Chromium and check your pages.
It could also be an issue with permissions on your directories. Try
#
Sorry the line that says this is the only line that needs to changed in the apache2.conf file is
#
I just clean installed ubuntu 14.04 and got the 404 errors, I had used this on 12.04 for about 2yrs.
My solution is as follows dont know if it is correct but works fine.
First change apache2.conf
sudo nano /etc/apache2/apache2.conf
AllowOverride None
Require all granted
THIS IS THE ONLY LINE YOU NEED TO CHANGE
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
#
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#
Follow Linerds instructions until sudo cp default site1 at this point make it
sudo cp 000-default.conf site1.conf
Next sudo nano site1.conf
under ServerAdmin add
ServerName site1
then change
DoucumentRoot /home/yourid/webdev/site1
save changes
sudo a2ensite site1.conf
then finish out like Linerd says.
Linerd thank you for the original tutoral. Like I said this works, if it works after update without having to make the change again I don't know time will tell.
#
is the missing line above. Sorry
#
Thank you! This is a great tutorial but maybe a bit out of date...but I got it working with your comment. Just for clarity I had to change "require all denied" under as mentioned in your post.
So happy to have this working with a nice directory structure and http address. Thanks, Linerd!
#
Thanks a whole lot for this tutorial. I just did a fresh install of ubuntu and this is the first tweaking I've done on it. Worked like a charm! I stumbled around a little at first and couldn't get it to work right, because I wasn't understanding the steps correctly. After a few tries I finally got 'er done.
#
I'm glad you got it working. Enjoy.
#
How could this be modified to include access to /home/me/webdev/site1 over a home network? That is, I'd like not just http://site1 to work but work across my home network, i.e., http://192.168.0.x/site1 ?
#
Got it to work with this tip I got off StackOverflow:
site1.conf:
ServerName site1
ServerAdmin webmaster@localhost
DocumentRoot /home/memyselfI/webdev/site1
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
. . .
Don't know how much of this is truly good karma vesus kludge. . . .
#
Thanks, I got it to work too, on Linux Mint 16. The config file(s) in /etc/apache2/sites-available/ must end with the .conf extension, e.g. site1.conf. And here is what the contents of the file look like:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName site1
ServerAdmin webmaster@localhost
DocumentRoot /home/user/websites/site1/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/user/websites/site1/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
#
Your sites-available config file is out of date for Apache 2.4.6 and my hacking around hasn't relieved a very difficult "403 Forbidden You don't have permission to access / on this server" I'm having. Any ideas?
#
Hello! I also have a file access problem: site1 and site2 are in a /home/myid/webdev. Folders and sub-folders of site1 and site2 are not writable through php. I have chmod'ed folder 'webdev' recursively to 755, so what could be blocking there?
#
Solved! Apparently, some PHP needed to be executed by user www-data, so i chown'ed the respective folder accordingly (adding myId to the www-data group was not good enough).
#
Thanks for the tutorial. I always have a file permission problem after setup and get the message: 403 Forbidden You don't have permission to access / on this server - when trying to access the newly setup websites.
I solve this by using the file manager to change permissions of the files and folders. So for a website that is on the hard-drive at:
/home//websites/site1/
I have to enable read only access for the files in the site1 folder for both group and others.
Then for each sub-folder in the line I change folder access permission to Access files for both group and others ( so I do this for site1, websites, )
My questions are - is there a better way to do this? Or did I miss something, because I do not see any other comments about file access problems? Is it possible to do this by adding yourself to a group so that everyone does not get access to the web development folders?
#
Sorry some things did not print properly in my comments above because I used angle brackets.
/home//websites/site1/ should be /home/user name/websites/site1/
and then
( so I do this for site1, websites, ) should be ( so I do this for site1, websites, user name)
#
Wehre are the apache error logs located, and which file to bee seen for errors? Thanks.
- Marsup
#
You can find the Apache logs under /var/log/apache2.
#
#
I'm not working locally, I have a server at an ip address and the partition for the site and files is on a separate disk than where the var/www directory is. Both virtual on the same server, but following the steps above, I get the "Index of/" page.
I'm using Drupal and put 1.1.1.1/drupal but to no avail. (that's not the real IP of course, but the example)
Is there anything else to reload/restart when doing this?
#
nevermind. I just copied and changed the default file so that the ip goes straight to the folder. Thanks.
#
yes, it worked....thank you so much.....
#
Great Tutorial. Had wrestled with Apache for a while without any luck.
#
What additional steps do I have to take to view the sites over my home network? I can view them on the machine that the server is running on, but that is not my main computer.
#
Are you trying to connect to the IP address of your server or 127.0.0.1? if its 127.0.0.1 this is know as a loopback address for your local machine and you wont be able to connect to another machine using this ip address. Try the IP for the server.
#
This is a life-saver. Use it lots. But how can I remotely access my ~/webdev/site1 ? It functions just fine on my own computer, but on my home LAN http://192.168.0.1/ gets me "It works!" but http://192.168.0.1/site1 gets me "Not found." AFA I know I've got everything 755 permissions-wise.
#
I found a solution at:
http://stackoverflow.com/questions/5922082/apache-see-named-virtual-hosts-from-lan
#
Hey
Thank you for this post .I want to know how can I inheriting HTML templates in APACHE2 Web-server as we can do in Django Framework . And how can I configure my My webpage with JS CSS IMAGE folders in webdev......?
#
hey dear, can u guide me for this,,,
when i place any folder inside site1 folder then, i am unable to access that folder.. in my Ubuntu 12.04 via the web browser. The css placed under any sub folder or the java-script also under any sub folder is not considered by the browser.
Example http://site1/ is working but http://site1/css gives forbidden message...
#
Do you have execute permission on the css folder? If not, try
chmod 755 css
#
Hey brother u are really sharing a nice stuff. I got really satisfied answer and technique of configuring apache.thanks once again. it is of great help to me 🙂
#
Hi! This and your LAMP instructions are working great for me, way better than XAMPP for Linux. Thanks!
One problem I'm encountering: on one of my sites, index.php (in the site's root directory) is not able to access main.css (in /css). The same is true for any resource in a subfolder that index.php tries to access. The specific error is "403 Forbidden."
I have no experience configuring apache or php. Is there a setting somewhere that tells the site to include subfolders? The site's folder is located in my home directory, so I can't imagine that permissions would be an issue.
Ubuntu 12.04, in case that matters.
#
Ah, I'm a dolt. Checking "Allow executing file as program" under folder properties did the trick. I should have ready into it a bit more.
#
I was just in the middle of a reply to look at the execute permissions on your folders when your second comment came in. I'm glad you got it figured out.
#
hello, how can I access the site I created following your guide externally? I setup a wordpress, can I show it to someone over the internet? Thanks in advance
#
I am new bird in Linux world... I have created my own Linux Apache server in CentOS for my network monitoring with CACTI, I have configured each & everything & my apache is working fine. I have registered my web portal also but still i am not able to my portal(web-page) with other machine in network. please suggest me what can i do for resolution of my this error. Please help me & guide for succesful result. Thanks in advanced for my help.
#
I don't know if you can answer me but I can't find /etc/apache2 directory in Mageia. I don't suppose you know where to look for this? 🙂
#
I'm not very familiar with Mageia, but you may find this forum post helpful.
https://forums.mageia.org/en/viewtopic.php?f=7&t=3302
#
hi, dis narender.k i want total informaion abt linux from basic to top level theory notes can u plz..............provide me the site u know/....................
#
When I browse to my http://site1/ I only get 'Could notcConnect' errors
As far as I can tell I've followed the directions, including the permissions suggestion.
Browsing localhost gives me the default 'It works!' page, but that's all I can load.
Please Help!?!
#
ERROR
The requested URL could not be retrieved
what happen?? not working in my ubuntu
#
Did you replace yourID in the file above with your user ID? Otherwise, it could possibly be a permissions issue with your directories. Do you have execute permission on all of the directories in your path?
#
yes, i replace "yourID"
how i can execute permission? which directories?
thanks for quick replay my question
#
You want execute permissions on your home directory, the webdev directory and site1 directory. You should be able to right click on the folders in your file manager to check the permissions. You can also set them from there.
You can also set permissions from the command line:
chmod ugo+x ~/webdev
chmod ugo+x ~/webdev/site1
chmod ugo+x ~/webdev/site2
#
thanks very much
#
Thanks a lot, it is working 🙂
#
Hi,
I got the solution. I was missing on some minor entry under my tools->options->Network->Connections->Settings.
When on proxy network, then under firefox browser all I had to choose was manual proxy with my proxy settings. And I had to add my newly created document root folder with name for example site1, site2 etc. in No Proxy for entry in my firefox browser.
Thanx anyway.
#
Thanks for posting your solution. I haven't had to work with proxy servers, so I couldn't be of much help.
#
Also, Adding to above information, I am able to open my joomla websites by typing localhost in both cases when I put it in /var/www/ .
So, Apache server is fine with or without proxy on vmware.
#
Hi,
Thanks for the great tutorial. This really helped me. But I am facing some issues.
I have Ubuntu-12.04LTS using vmware on Windows 7. I work on a internet with proxy configuration when I use my laptop in the office else I switch to no proxy. I configured the Apache as per your tutorial for multiple websites. It works great when I don't use proxy with my personnel internet connection at home.
But in office when connected with internet using proxy, it does not work. When I enter the site in address bar of firefox, it gives me google search results. This is not the case when I dont use the proxy at home.
For your information I have following configuration,
1. on Vmware setting for network, I have chosen NAT.
2. On Ubuntu under System Settings -> Network ,
i use manual proxy wwwgate0.xxxxx.com with port 1080 when using office else I configure it to no proxy when at home.
3. On Ubuntu, under Network Connections -> Wired I choose to configure my wired connection IPV4 as always Automatic(DHCP). This remains unchaged in both situations and I am able connect to internet.
4. In firefox under Tools->Options->Network->Connections->Settings, i choose No proxy or Manual depending upon where I am accessing internet.
Please help.
#
Super...I was struggling with an open source application installation for 3 weeks and the steps mentioned by you worked. Thanks a ton!!!!
#
Thanks! Worked like a charm 🙂
#
Why can i surf to the page http://192.168.1.*/site1/
but not http://site1 from my other computers on the same network?
Using ubuntu headless server. 12.04
P.s i´ve used the sleazy hack sudo ln -s /home/user/webdev/site1/ /var/www/ to make it work
#
I think you would need to edit your /etc/hosts file on each machine of your network so that site1 resolves as 192.168.1.1/site1.
#
Hi!
Thanks, i understand i can do that on each machine i have in the network.
But that is not an option since i have a couple of machines. It works if i edit the hosts on my OSX of course, but i can´t run around. And is it even possible to reach and edit the host files on a iPhone by the way?
Do i have to edit the DNS Server running on the server? And if, is there a good tutorial available?
#
Editing the DNS would be the "right" way to fix it for every client. Sorry, I don't know how to do this. BIND is the typical DNS server on Linux, so I suggest you start your research there. Good luck! 🙂
#
Thank you for this. I have just tested it on Xubuntu 12.04 and everything works fine.
I used gksudo leafpad instead of sudo nano
#
WONDERFUL!
I had so many issues doing this on Natty 11.04, however on Pp 12.04 and your tutorial it works fine.
BIG BIG thank you!
#
Hey Linerd,
It looks like things are getting worse for me. This solution I posted worked fine Yesterday, now my browsers can't display any local pages or phpMyAdmin any more... what's going on? thx
#
Check you /etc/hosts file. Sometimes Network Manager likes to overwrite this file, so you might need to make the changes again. If that is the case, you could try making the file immutable so it can't be overwritten by the system. So make your changes to the file, then
If you later need to reverse this later (is mutable a word?)
#
Linerd,
My problem was much simpler. Apache just stop running and I didn't know.
sudo service apache2 start
was enough! Thanks again.#
Hey there,
Thank you for the tutorial. I follow all the steps on ubuntu 12.04, but when I enter site1 or site2 on the address bar it is always the content of the default.html which is displayed. I check that site1 and site2 was enabled in the sites-enabled folder and the links are there. Can you help me figure out what is wrong?
Thank you
#
What is the content of your /etc/hosts file? You should have a line that looks like:
If you edit that file, make sure to then reload Apache
You might also want to clear your browser cache for good measure too.
#
hey sorry, I have been waiting and didn't even think about just refreshing the page to see your reply.
this is the content of my hosts:
127.0.0.1 localhost
127.0.0.1 localhost site1
127.0.0.1 localhost site2
I did that after reading this comment here:
" Matt says:
January 10, 2012 at 8:33 AM
"Should the first line in /etc/hosts read "127.0.0.1 localhost site1 site2" for instance?"
No, each site requires a new line so instead of "127.0.0.1 localhost site1 site2" it should be:
127.0.0.1 localhost site1
127.0.0.1 localhost site2
You just repeat the steps you did to create site1 in order to create site2, site3, etc. except you add a line in /etc/hosts for each new site. Also, your site name can be pretty much any name you want (it doesn't have to be "site1"). "
I change the configuration to localhost site1 site2 and it it working! I have been on ths simple line for the hole night!!! crasy !
Thank you
#
Excelent tutorial but I have a more especifc question regarding permissions:
Supposing I don't want do change from /var/www main directory, and that I am programming from an external computer with Netbeans updating files directly on the server, what should be /var/www permissions? And owner of the directory?
With only one site I managed it, but now I have other projects and I am trying to setup a SVN subvservion repository and everything goes right until it's time to write inside /var/www/whatever...
Could you please, give me some tips?
Thanks in advance!
#
hey! thanks for this!
I was planning to have a local wordpress development environment setup. so i followed your tutorial and everything worked.
except one. when i create a new post or page and publish it, and try to open its permalink, i get the 404 error. it says that the link can not be found on Apache2(ubuntu) server at port 80.
moreover, it displays the url as "/permalink" rather than "site1/permalink".
what is going wrong?
#
It sounds like mod_rewrite isn't working. Did you change AllowOverride to All under the <directory /home/yourID/webdev/site1/> section?
#
Thank you for this tutorial. Could you give a bit more explanation on Apache directives in more simple as this configuration. Also add some comments in the files. thank you
#
After reading this post, you pretty know everything I know about Apache 🙂
I know it's not the easiest reading, but I suggest you check out the official Apache documentation.
#
I keep getting the same error
Forbidden
You don't have permission to access / on this server.
Apache/2.2.20 (Ubuntu) Server at site1 Port 80
I tried to rerun the tutorial, but still the same : / any idea what went wrong?
#
I have the same problem 🙁
#
check permissions for your home directory (under which you have created site1 and site2). you need to try: chmod 750 /home/yourid or chmod 710 /home/ or chmod 755 /home.yourid (depending on how much access you want to give - the least that is required for the sites to be visible is execute permission for the group)
do the same with the webdev folder and its contents chmod 750 -R /home/yourid/webdev (or 710 or 755)
#
followed the instructions here and everything came out as expected. thanks!
#
You rock. Thanks so much for posting this. I'm moving off a shared host and onto a barebones Linux box with no support... was totally lost as to how to emulate my old environment and this did the trick.
#
Great tutorial ! Worked like a charm !
#
maybe below can give more information ( note that site1 name is mysite here )
sugiono@ubuntu:~$ apachectl -S
ulimit: 88: error setting limit (Operation not permitted)
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server localhost (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost mysite (/etc/apache2/sites-enabled/mysite:1)
Syntax OK
#
Thank you very much. Instructions were perfect
#
MANY MANY THANKS. 5:00 was trying to make a virtual host on a pile of manuals, only your fully working. Thank you!
#
Hello again,
I checked each step , and everything looks good. testing.php and phpmyadmin run smoothly. the only thing when I try to execute install.php, the browser stop and blank.
Can you please advise? I did change the /etc/apache2/sites-available/[sitename] ,
Options Indexes FollowSymLinks MultiViews
AllowOverride All ( and also to AuthConfig>
Order allow,deny
allow from all
restart the apache, and still not working. pls anyone can help?
#
What is install.php? What is is supposed to do?
#
install.php is an executable file for my php package / module, but no worry about that first since i am still figuring out how to enable site 1 and site 2 since everytime i reload apache,
result
error line 13
unable to resolve host 0.0.0.0:80
thus i can never access index.html i have stored in that directory, instead it shows the index.html from /var/www
i do not know what happend, i edit /etc/hosts and erase the 127.0.1.1 ubuntu , since i thought that is the confusing culprit everytime the apache2 want to restart,
can you please help me straight this out, thanks in advance
#
the exact message is
sugiono@ubuntu:~$ service apache2 reload
* Reloading web server config apache2 ulimit: 88: error setting limit (Operation not permitted)
apache2: apr_sockaddr_info_get() failed for ubuntu
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'graceful' failed.
The Apache error log may have more information.
#
this problem arise since I install ubuntu server on my pc.
the creating a web development directory was fine, but then i was unable to execute install.php ( see my top posting), so i clean install everything and start with ubuntu server, ubuntu desktop and LAMP.
I forward my server ( port 80 ) so that I can have it alive. it went great for /var/www web, but when i tried to have the second hosting, web development, fail with the above message ( see my 3rd posting) although the name site1 can be accessible ( direct to /var/www, where it should be /home/webdev/site1 )
#
Do you get the same errors if you use sudo with the above command?
You can fix the fully qualified domain name by doing this:
#
Don't remove that line from /etc/hosts. It should work with it in there and removing it may mess up something else.
I think you need to find the file that is referencing IP address 0.0.0.0:80. Since you're working with your local machine, it should probably reference 127.0.0.1:80
#
Hi there,
I did it exactly the way you explained, and everything has been set up right. The only problem happened in the end ..
phpmyadmin could not be found ... i've got an 404 error, even with the "success" message at the end of installation "ldconfig deferred processing now taking place"
what could be the error?
Thanks that much ..
hugs from Brazil
#
Look at this post: http://tuxtweaks.com/2011/10/install-lamp-and-phpmyadmin-on-ubuntu-11-10/
and find the section near the bottom that refers to Fixing phpMyAdmin.
#
Hi,Thanks for the wonderful tutorial.If i wish to view say index.html under site1 from another computer connected over LAN,how can i do that.
So from my other computer if i fire http://site1/index.html it should render the contents
#
Great tutorial. I'm new to this stuff. Did the same thing for site2 as suggested but it didn't work! It generated the index.html output from /var/www/ instead. I think the tutorial needed to be a little more concise with regards to site2. Checked my scripts to ensure that there were no typo's. Should the first line in /etc/hosts read "127.0.0.1 localhost site1 site2" for instance?
#
"Should the first line in /etc/hosts read "127.0.0.1 localhost site1 site2" for instance?"
No, each site requires a new line so instead of "127.0.0.1 localhost site1 site2" it should be:
127.0.0.1 localhost site1
127.0.0.1 localhost site2
You just repeat the steps you did to create site1 in order to create site2, site3, etc. except you add a line in /etc/hosts for each new site. Also, your site name can be pretty much any name you want (it doesn't have to be "site1").
#
I use
with no problems.
#
HI.Thanks for the great tutorial.
Whenever i reload apache2 i get the following:
* Reloading web server config apache2 [Sat Nov 26 19:42:10 2011] [warn] NameVirtualHost *:0 has no VirtualHosts
[Sat Nov 26 19:42:10 2011] [warn] NameVirtualHost *:0 has no VirtualHosts
Also i am not able to send "PUT" requests via any REST client(for eg Google Chrome has an extension for the same)
#
Your virtual host file should refer to *:80 for port 80, not *:0.
#
U have to /etc/apache2/httpd.conf ----------- servername localhost . U won't get the error
#
U need to do this in /etc/apache2/site-available/site1 -------- DocumentRoot which u have create a directory site folder
#
Try it...........
/etc/apache2/site-available/site1.............
DocumentRoot
a2dissite default
a2ensite
service apache2 reload
service apache2 restart
u can see that error won't get u..............[warn] NameVirtualHost *:0 has no VirtualHosts
#
Thanks lol....
Below mentioned url is very easy to understand,
http://www.redhatlinux.info/2011/11/different-types-of-configure-httpd.html
#
I'm not really much on posting comments but I just have to thank you for this great tutorial, everything worked with no headaches.
A thank you also for this tutorial on installing lamp on ubuntu 10.04
http://tuxtweaks.com/2010/04/installing-lamp-on-ubuntu-10-04-lucid-lynx/
Thank you very much. 🙂
#
Thanks for the tutorial.
I also liked the idea to have it all setup under the account that I use on the server (ubuntu).
Now here is the issue that I have not been able to resolve and hope someone can help me with the optimal solution.
I use Joomla and Joomla uses www-data (the account apache uses) to write files when you install extensions or add files to the CMS.
Then I use an FTP account same as ubuntu user ID to copy an manipulate files remotely.
Yes I can cmod the files and dir eachtime they are written to give access to Joomla or my account but there must be some way that both system account www-data and useraccount have full access to /home/useraccount/webdev/site1 site2 etc
If not what is the use to set it up under the /home/useraccount
sorry I am a noob but eager to learn what is the best way to do this.
#
Thanks for this and the LAMP install how-to. Worked out of the box for me on Lucid - both laptop and workstation. I'm a mere developer, but the ease of this makes me feel frisky about the notion of doing it on my (internal) network print/file server as well. Refreshing to find simple, correct, complete how-tos.
Having been "playing with" Linux since '95 (Slackware, RedHat, Mandrake, Mandriva) and using exclusively since '05 (Fedora, Kubuntu), I observe 'tis rare and wonderful to get perfect advice in Linux-land. Yours is the kind of effort that leads to more satisfied Linux-geeks and fewer Windoze and Mac based developers.
richarduie
P.S. Last addition for my purposes was cURL...Shi Chuan had that at:
http://www.blog.highub.com/php/php-core/linux-ubuntu-install-setup-php-curl/
#
I've followed the chmod instructions, but still get:
forbidden
You don't have permission to access / on this server.
Any ideas on how to troubleshoot/fix?
#
Thanks for the guide. I am getting a 403 when I try http://site1/ The file permissions are 644 and the directory is 755.
#
I think your index file needs to have execute permission. Have you tried setting the file permission to 755? Actually, 744 might work too.
#
I found my mistake. First I took out:
Options FollowSymLinks
AllowOverride None
And that worked, then I realised I hadn't set All here:
Options Indexes FollowSymLinks MultiViews
AllowOverride All
So I put the first bit back in, AllowOverride to All, and changed permissions back to 644 for files and 755 for dirs.
Everything is fine now, though I am going to find out why each works and the difference they make.
Cheers
#
Hi,
Great instructions, thanks. Very clear.
I've got it all working on my Ubuntu virtual machine, running on a windows box but I've got a problem. I can't seem to access it via:
http://192.168.0.11/MyApp
I get a 'Not Found' response from apache.
It works within the Ubuntu box i.e.
http://localhost/MyApp
...but I'd rather just work with the browser if I can, from windows.
Any ideas anyone?
Thanks,
Al.
Oh, by the way... you'll need to set the 'i' immutable attribute on the hosts file or else Network Manager will screw it up for you. i.e.:
sudo chattr +i /etc/hosts
#
Check out this comment thread: http://tuxtweaks.com/2009/07/how-to-configure-apache-linux/comment-page-1/#comment-2089
It may be of some help, but I haven't tried it myself. Good luck!
Oh, and thanks for the tip about chattr on the /etc/hosts file. I know this has been getting overwritten for some people.
#
thanks man, it helps me alot.
#
Hi guys. Sorry but i still have problem. I followed all instructions but without success.
Whenever i try to to start my website i get default page - not index.html page of site.
Does anyone have suggestions how to fix this?
#
Make sure you added ServerName site1 to the site1 file in the sites-available directory.
#
Hey, a little help please ... I set it up exactly as described, and followed the instructions exactly as you said; then I got a "Oops! Could not contact domain ... trying again." So then I added the fqdn file, then I followed community help on Ubuntu and disabled the default using a2dissite, and kept the enabled for site1, and now I am getting a Forbidden error about not having permission to access / on this server?
I actually did all of this after following your previous post about setting up a dev environment with Ubuntu, so I'd really appreciate any troubleshooting help with this.
#
It may be a permission issue with the directory where have your files. Try this:
If you're using Firefox, you may also want to try clearing the browser cache after you change permissions.
#
Just to check -- by cdmod you mean chmod, right?
#
Oops. Yes, I mean chmod. I'll fix my previous comment.
#
Great tutorial. I have done step by step uninstalling LAMP and reinstalling it again. I also installed phpmyadmin but http://localhost/phpmuadmin is giving me a 404 not found error.
Can you please help get this phpmyadmin working
Thank you
#
Follow the instructions here to fix phpmyadmin: http://tuxtweaks.com/2010/04/installing-lamp-on-ubuntu-10-04-lucid-lynx/comment-page-1/#comment-2952
#
I get the following message where I use samd instead of site1.
I have followed the instructions above exactly.
While trying to retrieve the URL: http://samd/
The following error was encountered:
Unable to determine IP address from host name for samd
The dnsserver returned:
Name Error: The domain name does not exist.
I can ping samd and get the correct response.
Any help would be greatly appreciated.
#
Solved this. The proxy server was intercepting the url. I just added samd to the exception list and it worked.
#
when i run
sudo /etc/init.d/apache2 reload
I get
* Reloading web server config apache2
Warning: DocumentRoot [/home/yourID/webdev/site1/] does not exist
How can I fix?
#
You have to replace "yourID" with your login name, i.e. the name of your home directory. So if your login name is "safiur", then your home directory is probably /home/safiur.
To change to your home directory in terminal, type:
cd ~
Then to display the current working directory, type:
pwd
It should display something like:
/home/login_name
where login_name is your actual login name.
#
Great site, great tutorial! I am a windows user but am using ubuntu 10,10 via VMWare (to teach myself PHP on a lamp stack). I like ubuntu but I still get lost everytime I step too far outside of my cosy familiar windows world, and if I'm honest most linux guides and tutorials have succeeded in baffling my poor pea-sized brain!
This is one of the first linux sites that hasn't gone over my head, which I'm very grateful for 🙂 I'll be following closely from now on. Thanks!
#
Great tut!! I have been following yours from installing LAMP and configuring Apache2 from this post and I have to say everything running without any hiccup. You're the man! Thank you very much! This site will be definitely one of my favorite spot on the net!
#
Thanks for the great tutorials on getting LAMP up and running and setting it up for multiple sites! I love my new test environment.
When my computer goes into suspend, I lose the changes I made /etc/hosts. Not a huge deal since I just sudo nano /etc/hosts and make the edits again. If you have any idea why this file "resets" I'd love to know what I can do about it.
Thanks again for the fantastic tutorials!
#
I don't have time to dig into this right now, but it looks like there's a bug in Maverick. You may find a work-around if you read through the comments on the bug report.
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/659872
#
Thanks for the tip and link. I will check it out. It's not a huge deal to me since the workaround is quick and easy. When I figure it out, I will post it here. Thanks again!
#
Ubuntu 10.10 apparently released a fix in the network manager, because the "hosts" file is no longer overwritten, on suspend or reboot. Very nice! Thanks again, Linerd, for the great tutorial. I plan on reformatting and starting fresh with the final release of 11.04, so I will be using this tutorial again... Best, Aaron
#
Just as a side note: When adding site2 I configured /etc/hosts like this:
127.0.0.1 localhost.localdomain localhost site1 site2
Now all three of the sites work, so I assume sites can be continually added to the list without affecting the others.
Question: To enable the site I entered 'sudo a2ensite site'. Is there a command for disabling the site; say I no longer have the site.? I just don't want the list to grow and bog something down.
#
Yes, there is a command to disable a site. It is a2dissite. To remove site2 it would be like this:
#
Hey man. I'm truly just a beginner, but through workin' with tutorials have kinda learned a few things through teaching myself. Here's all I want. I have an ubuntu 10. server with LAMP on it. I just want to be able to host multiple sites that are custom created by myself through Dreamweaver and such. I can see my site fine on my 'localhost' server, the computer I'm on right now, but cannot let's say through my laptop over the net. If I could just be told what has to be done, not necessarily step by step, then I can maybe figure it out. Then again, maybe not, but I'd like to know what's missing. Is it just a matter of setting a unique IP and configuring my domain name (which I bought through GoDaddy.com) to find that address? Or is it something else?
I'm a beginner, REALLY JUST beginning... So, thank you very much, I really appreciate it!
#
Hi, thanks for the tutorial it has gotten me further than any previous attempts, there is however a snag at the very end that I wonder if you can help me with:
Where it says in you directions
"Edit the first line adding site1 to the end of the line so it looks something like this and save the file. 127.0.0.1 localhost site1"
the file I see is different, it looks like this and I don't know where I should apply the edit:
192.168.102.148 adrian-N80Vm # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 adrian-N80Vm localhost6.localdomain6 localhost6
127.0.1.1 adrian-N80Vm
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
When I run the final command
"sudo /etc/init.d/apache2 reload"
I get this:
Warning: DocumentRoot [/var/www/home/adrian/webdev/site1/] does not exist
Any ideas?
#
You should apply your edit to the end of the second line in your case: right after "localhost".
For the warning you're getting. Make sure that the path you have in your site1 configuration file is just /home/adrian/webdev/site1/.
#
I've removed/reinstalled LAMP and followed instruction to the letter (copy-pasted) twice, still not working. Is it possible that you are using 10.04 and there is a bug in 10.10?
#
Thanks for your answer, just to clarify (I'm a total newbie:)
Should it be:
/home/adrian/webdev/site1/
or
/var/www/home/adrian/webdev/site1/
?
#
It should be:
/home/adrian/webdev/site1/
#
I'm doing something wrong, think it's best to start over, Do I need to delete something so it won't clash with new configuration?
#
Never mind, I've removed and installed LAMP anew, should take care of it.
If it still does not work I'll be back nagging 🙂
#
Great tutorial, I have a special case in my setup I was wondering if you could help me out a little, I'm dualbooting Win7 & Ubuntu each on its partition, plus I have an extra big partition to store and share all my files betweem OS's, so in this partition I have setup a folder named "www" and from windows I'm accesing it using wamp by modifying in apache to link the server to "a:/dropbox/www" and on ubuntu I'm using lamp but I haven't been able to change from /var/www to /media/documentos/Dropbox/www since that is the path that appears in nautilus.
Anyhelp would be appreciated.
#
You should be able to create a configuration file for your site similar to the one above for site1. Just replace the instances of /home/yourID/webdev/site1/ with /media/documentos/Dropbox/www/.
#
Hi linerd, I did, exactly what you said, after the last step, restart apache, I get the following error:
403 Forbidden (In the title of the browser)
Forbidden
You don't have permission to access / on this server.
Apache/2.2.16 (Ubuntu) Server at localhost Port 80
I don't know what's going on.
#
I have the same 403 error. I am working on a single boot Ubuntu 11.04 install.
I came here after working through the tut on installing LAMP and running into problems in the last section: installing and testing phpmyadmin.
Otherwise: tx for the great tuts.
JohnJ
#
This is a cracking tutorial - I ran into the same 403 issue and after some digging sorted the solution.
Firstly you can check in the apache logs to confirm /var/log/apache2/error.log to see if it is a permissions issue.
The you can fix it by changing the permissions on the directory
cdmod o+x /home/yourid/webdev/site1
Hope this helps.
#
great post.n Thanks
#
Hi Linerd -
Your tutorial worked beautifully for me - every step.
Just reached the point where I downloaded the actual site and DB from my provider (for my first "test site") and the strangest thing is happening. I don't know what to make of it.
+ Before downloading the site files (pretty much a base installation of WordPress thus far) and DB - I would go to http://site1.com on my local machine and see the "Hello World" index.html that I wrote. Just fine.
+ After downloading (and configuring teh local database) - when I go to what I would expect to be the "local instance" of this site again (the non-www URL), it's automatically mapping to the "www" URL and taking me to the live site on the real web server. I validate this explicitly by pulling the network cable -- and wouldn't you know it... I get a connection timeout!!
Do you have any idea why my local machine is now connecting to the [real] web server server when it didn't before? Is there something in my site that's making this mapping that I need to override? Any thoughts??
Sorry if this is a noob question... but hey, I'm a noob!
Any insights most appreciated. Thanks!
Mark
#
So you downloaded the files from your provider rather than manually installing WordPress? The only thing I can figure is that there is a 301 redirect that's set up in one of the files from your provider's server. Take a look at this page: http://www.dailyblogtips.com/how-to-setup-a-301-redirect/
The redirect will be either the one of the PHP methods or one of the Apache methods. ASP is for Microsoft servers. I'm betting it's an Apache redirect in your .htaccess file.
If you can't find it, I suggest you blow away everything you downloaded and do a fresh local WordPress installation. http://tuxtweaks.com/2009/11/how-to-install-wordpress-on-ubuntu-part-1/
I just work on my website theme locally and then upload the theme folder to my provider's server when I have things looking the way I want.
One final thought. You said in your comment that you go to site1.com. You might want to try changing it to just site1.
#
Thanks -
Had only a little while to work this, but, I took your last comment and reworked my set-up so that mt local directories are truly site1, site2, etc... no longer site1.com, site2.com. That definely sounds better. It didn't resolve the problem yet, but it's cleaner.
No obvious 301 redirects that weren't in the fresh WordPress download files. When I "grep 301 *" there were five php files with a 301 string - both my original WordPress and the new WordPress files matched on this front!
Will try the fresh install via your other on-line links. We'll see how it goes...
One question per another comment you made, though -
So the core goal here is merely to modify my template, then? I'm trying to educate myself - and this clearly rings true. I have one site partially-functional (a small amount of initial content), but I do indeed want to significantly modify the template. If that's the case - I shouldn't be terribly worried about having my local content match as that's moot. It's all about the site design on the LAMP environment (and, naturally using as a repository for backups). Is that pretty much the philosophy?
Thanks again!!
Mark
#
Yeah, I just use the local LAMP setup for theme development and customizing. I don't really use it for backups of my site. My provider has a backup system available in Cpanel that will backup all of the site files and databases in one shot. Then I just download the archive to save it locally.
#
It worked the first day, but when I came back after, it didn't. I realized it was because the host file kept resetting to what it was before I saved it. So I re-edited it to add the various permissions.
And now Site 1 and Site 2 are available, but for some reason they're accessing the files from my original localhost site. I checked the site1 and site2 config files and they still have home/myname/webdev/site1 and site2 as their documentroots and directories. So I don't get why they're pulling the files from localhost.
Help?
#
Never mind. I had skipped a small step.
#
Hey, Great Tutorial.
I am attempting to setup a testing environment using unbuntu, however I am having some difficulties getting my site to work properly once placed into the var/www/ folder.
It seems none of the relative paths work. In my index.php file for example, I have a bunch of includes and images, however none of them appear when I view the page, only the basic html text appears.
I am assuming the most likely reason is that the file does not have read access to those files? Is this the case?
Is there a quick terminal command to fix this if it is?
Any help would be much appreciated.
#
I'm not sure what the correct permissions are. I'm thinking the files will need read and execute permission. To give everything read and execute permission, use this command.
#
I have done exactly as you have described above and site1 and site2 are working absolutely wonderfully. I wish to know if I can create name base virtual hosts in apache with localhost and access them from same machine?
(www.myname.com etc)
I tried the process after reading a few howto's in ubuntu forums. However whenever I restart apache a warning is received that unnumbered virtual hosts and numbered virtual hosts port 80 are not supported and reloading fails. Can I get some help with this problem?
#
Sorry, I can't help you with that one. That's beyond the scope of anything I've tried to do. The Ubuntu Forums are probably a better place to find help for this. Good Luck.
#
Hi Linerd,
Great tutorial, finally managed to get two sites going on a LAMP server.
This may be a stupid question, but how do i get to the sites without modifying the hosts file, what address?
I've tried the obvious http://localhost/site1 & http://localhost/site1/index.html
#
Hmm... I gave this a try and http://localhost/site1/ works for me. Did you make sure to enable the sites? Did you make sure to reload Apache?
sudo /etc/init.d/apache2 reload
Edit: Interesting, I just added the sites back to my hosts file and the change wouldn't take until I did a full restart of Apache, so maybe that's the trick to get it working for you.
#
Hi Linerd,
Thanks for the quick reply. I tried restarting Apache - no joy, I even tried undoing the fqdn fix you posted in case that was affecting it - no joy.
Turns out to be able to access site1 & site2 via http://localhost/site1/ or http://localhost/site2/ I needed to put the site1 & site2 folder under /var/www/ as opposed to /home/patrick/webdev/ and edit the /etc/apache2/sites-enabled/site1 & /etc/apache2/sites-enabled/site2 files appropriately.
Although as yet I haven't tested it from another machine, I'm guessing I will now be able to access it from http://192.168.1.82/site1 etc.
Just thought I would post back in case any other users have been spending as much time trying to get that going as i have! LOL
Thanks for the great tutorial. Feel free to edit this comment to keep it concise if you wish.
#
Hi Linerd,
I just had a fresh install on a new HDD and followed your tutorial for the third time and it worked again.
Muchas gracias
Bobot
#
De nada.
#
Thanks for the tutorial. Just wish I understood how those commands worked. 🙂 I've set up WAMP several times, but this is my first LAMP.
#
is there a way for other machines on a local network to view these sites? I can view the /var/www/index.html page using either the ip address (http://192.168.1.100) or the name (http://linux-box) of my linux machine, but can't seem to find the custom sites. (Which work perfectly on the linux computer, thank you)
#
Check out the comment from ZogsterJack. He found a way by editing the /etc/hosts files on the client machines so he could see the custom sites. http://tuxtweaks.com/2009/07/how-to-configure-apache-linux/comment-page-1/#comment-2089
I haven't tried it myself, but it's been reported to work.
#
Actually, I do have to add that it will only allow __.sytes.com to point to one of the site and it will not work in a __.sytes.net/site1 and __.sytes.net/site 2 way.
Still need to figure out this one.
#
Is the configuration the same if using a no ip tool like NO-IP?
I cannot reach any of the 2 sites when using the NO-IP URL (.syte.net).
I tried adding the following entry in /etc/hosts:
192.168.1.100 site1 site2
(192.168.1.100 being the IP address of my Linux box)
Although, if using the URL .sytes.net, I do reach the 'It Works!' Apache test page from my webserver.
Any help would be greatly appreciated.
Thx!
#
Rudy, I haven't tried this setup with a dynamic DNS setup. I'm thinking you would most likely have to modify the Apache configuration. However, it might work like it does when accessing the host machine web server from a VirtualBox guest. Have you tried __.sytes.net/site1 or __.sytes.net/site2?
#
Linerd,
Thx for the quick reply.
Yes I did try __.sytes.net/site1 or /site2 without luck.
I actually figured it out. I had to disable the default config under /etc/apache2/sites-available by using the 'a2dissite' command (sudo a2dessite default).
#
Just found the hack under the older posts...sorry should have checked there first
#
Fantastic post!!!!
I managed to get this working so if I VNC onto my ubuntu desktop server I can visit http://site1/ no problems but if i try from my laptop I get an error... should I be adding site1 to the second line of /etc/hosts @127.0.1.1 instead of 127.0.0.1 localhost?
Thanks a million
#
I NEEDED SOME MATERIAL TO FINISH MY REPORT ,I THINK I GOT IT THANK U
#
Awesome post! It worked great!
#
Linerd,
Thanks for cleaning up the comments. I fixed the issue. I had the database call parameters typed as strings ( ' ' ) by removing the single string quotes I was able to get the database to connect and the page would then load.
Thanks again for the tutorial to set up the multiple web application development environment for apache.
#
I installed LAMP on a setup of Ubuntu 10.04 and added the site1 site2 environments exactly as you show. Both sites worked just as you described. I have started using site1 to follow a series of tutorials on php.
I have run into a problem and am baffled. Using firfox, I can got to localhost/site1 and call the index.html page and see the "Site 1 works!" in the browser
I have copied the testing.php into site1 and when I call the page it gives me the php page, so I know that apache is serving up php from site1 as well.
I have built the following page called index.php which calls for a MySQL database called gwdb and a table in the database called guitarwars. I have written the code exactly as it is written in the tutorial changing only the location of the database to site1 in the call to connect to the database; $dbc = mysqli_connect('site1','root', 'password', 'gwdb')
All I am getting in firefox is a blank page. In chromium web browser I am getting "Oops this link appears to be broken"
I am new to Linux and PHP and trying to learn and I can't see what is causing this break in the link. I have included the code below:
#
James - I edited your comments into one to capture the spirit of what I think you were trying to show.
I'm no php pro, so I doubt I'll be much help. I did try your file on my machine and it doesn't load. The file does work if I remove the php portion. Maybe another reader can offer some advice.
#
in your mysqli_connect statement you should still be using localhost not site1 because the mysql server is on localhost.
#
Hi Linerd
Thanks for the tutorial. I'm a newbie trying to set up my own ubuntu linux server for a production enviroment to host some of my applications. Is the setup tutorial for lamp and apache suitable for production environments? Also if we want to keep Ubuntu lamp installation up to date is there a command that we use?
Thanks again for the great tutorial.
#
Hi Pragasan - I'm confident that the LAMP setup would be fine for a production environment. The Apache configuration, I'm not sure. I know little more than what I've documented on this website. I'm not sure that I've followed best practices for Apache, but the setup here works well for an offline development environment. I'd encourage you to consult the Apache documentation if you want to set up a production environment.
As far as keeping things up to date; if you're running Ubuntu Desktop, then the update manager should keep you up to date. Otherwise, you can update your system with
sudo apt-get upgrade
#
Hi Linerd
Thanks for all the help.
take car
#
Hey man! You are too great! What others cannot do, you have done. Now my long time desire has become possible because of your tutorial. And thanks to the almighty for showing me to this website.
#
Hello there
I have followed the tutorial and it seemed to work on the command line but when I tried to access http://site1/ i get 403 forbidden
You don't have permission to access / on this server.
where did I go wrong.
regards
roy
#
Check out the comments from Larry. He had the 403 error and it turned out to be a permissions problem. Do you have read permission open on your home directory?
#
Hello Linerd
Thank you very much that was the problem. Great tutorial.
Thanks again
Roy
#
thanks a lot for such a nice tutorial...straight away it worked...
#
i installed win XP as a guest using virtualbox.
host it ubuntu KK.
how can i access for exemple, http://site1/ from inside the virtualbox?
need this to test sites in IE 🙁
i read something about chaging the hosts files in xp but that didnt do anything, so maybe i did something wrong.
thanks for the great tutorial and for the help
#
A quick trip to Google found a solution. I found this on the VirtualBox Forum. Enter http://10.0.2.2/site1/ into the browser in XP. You should now see the site you are hosting on you VirtualBox host.
I just confirmed this with Kubuntu 10.04 running in VirtualBox. It should work the same with WinXP. Maybe I'll write up a short post about this.
#
How to Configure Apache Web Server on Linux” please send me
#
I still don't have permissions for /var/www
but everething works fine with site/ and site2
thank's for
127.0.0.1 localhost site1 site2
both sites work well now.
Thank again !
Merci beaucoup !
#
I'am a (very) new user of Ubuntu. I used to work with Wamp server in Windows.
How can I create websites when I don't have permissions to write in the webdev forder ? How can I get permissions ?
#
If you created the webdev folder without using sudo, then you should have write permissions to that folder. If you don't own the folder, then you should be able to change the ownership with the chown command. If you want to change the permissions, then chmod is the command you want to use. Look at the man pages for these commands for more info.
If you follow this tutorial, you won't need permissions to the /var/www/ folder since you'll be putting the files in a folder under your home directory.
If you want to put your files in the /var/www/ directory, you can add your userID to the www-data group with this terminal command:
Correction: I just looked at my system and /var/www is owned by root.
#
Thank you for your help.
I tried the command :
sudo adduser myid www-data
I gave my password
and I got
Adding user myid to group www-data
but I still don't have permissions to modify the index.html file
#
You can change the ownership of index.html with:
You may want to change the ownership of /var/www if that's how you want to work. See my above correction about the ownership of that directory.
sudo chown yourid:yourid www
#
#
wow, i am excited. thanks a lot for the new command "sudo a2dissite".
buenas noches and again muchas gracias.
#
this tutorial, along with the tutorial on LAMP installation is great. thanks a lot.
with the two tutorials i managed to set up my own web development environment. with a lot of tail chasing though, and lots of help from you. again, thanks a lot.
i have some questions though. after i was done with the set up, i realised that i did not like the directory placements, directory names, and host names. i figured that maybe i don't have to do it over again.
so what i did was to instead, just (1) move the directories to where i wanted them to be, (2) rename the directories, (3) tinker on the configuration files (found in /etc/apache2/sites-available$) for the hosts i have made before and rename them according to my desire, (4) delete the symlinks i found in /etc/apache2/sites-enabled, (5)tinker on the file /etc/hosts and change the first line accordingly (i.e. 127.0.0.1 localhost localhost2 localhost3 localhost4), (6) execute sudo a2ensite for the sites, (7) reloaded apache, and finally (8) check on my browser. it worked!!!...
my only fear is, am did i do it right? did i not break anything with what i did? muchas gracias.
#
It sounds like you did it right. You can also disable a site with the sudo a2dissite command. It will remove the symlinks for you.
#
Great tutorial!
However, I'm still not able to open my site1 page. It always points to the default page.
The error message when I reload apache2 is this...
apache2: Could not reliably determine the server's fully qualified domain
name, using 127.0.1.1 for ServerName
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
[warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts
Thanks!
#
Many thanks for the excellent tutorial
I have make changes exactly as you have metioned in your tutorial.
I receive following error for testing site1
Host not found
name lookup for site1 failed
#
Many thanks for the excellent tutorial - all worked perfectly for me.
One added point - I wanted to be able to access these multiple sites from other PCs on the local network.
Spent ages looking for the answer, then it dawned on me. Update the hosts file in /etc on the client PCs with the fixed ip address of the server and the equivalent entries to those in the tutorial; for example 192.168.0.100 site1 site2 (where 192.168.0.100 is the server ip address)
This does mean you'd have to setup each client PC and then amend for each new site you add in the future, but this works for me right now.
Guess the better option is to set up a DNS server (thinking Bind9 for this) to centralise this effort, but I'll personally save that for another late night.
Many thanks again
#
@ZogsterJack - Thanks for the comment. I know some other people have been wanting to figure out the same issue with the server on a home network, so thanks for posting a solution. I tend to just do my web work on my laptop with LAMP installed, so I haven't gotten into any real networking issues. I agree that a DNS server seems like the more "correct" solution, but I haven't found the motivation to give it a try.
#
Wow thanks alot, that worked like a charm, I use VMWare to test ie6-8 and for some reason it doesn't recognize the host machines site1 or site2 unless you change the host file. If anyone is wondering where this is located for windows XP: C:\windows\system32\drivers\etc\hosts
I suggest you assign a static address to your machine to make life easier.
I hate ie 6! Thanks a ton, this guide has been very useful.
#
Wonderful tutorial. Simple and concise.
#
Hey Linerd.
I figured it out. I although I had read permissions to all in ubuntu set to my "webdev" directory, I did not have read permissions set for the parent folder, which is my user in the home directory. It seems apache needs all folders in the virtual path to be readable by all. The only question I have is, does this make my entire user folder vulnerable in some way? Is there a way to restrict usability to only the home/user/webdev/ path, without having to change permissions of all other directories in the home/user/ directory individually?
I figure that this must be possible since it is possible to have multiple users in the home directory, and there is a set up that restricts users from viewing each other's files.
I guess the overall question is, is it possible to give read permissions to a sub directory without giving read permissions to all parent and sibling directories?
Thanks.
#
@Larry - There should be no need for the read permission to be open on sibling directories. You could also make the rest of the files readable only by you. Having read and execute permission open on the directory would allow someone else to see the files, but as long as the read permission on the file itself is restricted, they won't be able to open the file.
I'm sure there's another option that I can't think of right now too. You may be able to do something by creating a different group ID.
#
Great Tutorial Linerd. Two questions.
I am getting a 403 Forbidden permission error. I am new to running apache on my own machine (Ubuntu 9.10). Is the permissions error a problem with Ubuntu permissions or Apache permissions.
Also, a random question. If I make the server name a .com (e.g. "ServerName site1.com"), in which order with the browser (Firefox) resolve the name conflict with the remote site?
Do you know of a way to use Firefox to select which location to check. Someone may want to do this for testing purposes if they have static addresses all over there website (which a good coder would never do).
Thanks
#
thanks for this tutorial, its simple and works
#
Thanks this was very helpful. I've now got multiple top level sites on one machine.
Any idea how to access them on another machine on my local network?
The "It works" page can be accessed by the other machines on my network by entering this machine's IP address, but I can't figure out how to access site1 and site2 from the other machines.
#
@Vayu - I haven't tried accessing the sites from other machines on my network. You may need to set up a local DNS (domain name server). It may be possible to remotely access site1 and site2 by adding a line to your /etc/hosts file on the client machines. I'll have to give that a try.
Edit: As far as an easy solution, I've only come up with this cheap hack:
You can then access site1 on your network at: http://ip.address/site1/
#
Thanks. I normally develop on Windows and this is my first attempt at ubuntu.
#
This is really great!
I am finding my way through Linux, and tutorials are really educational.
Thanks a lot for sharing.
Got it right the first time!
Best regards
#
#
This and the LAMP tutorial are absolutely invaluable. Thank you Linerd.
:o)
One thing confused me. The two sites I created both ended up opening the same home page.
I finally figured out that it was necessary to give each its own line AND its own IP address in the hosts file. Some clued up folk may have understood that without being told, but there may be other noobs like myself who need it spelled out.
i.e.
For my wordpress site: 127.0.0.1
For my php_tutor site: 127.0.0.2
It worked, so I guess that was the right thing to do.
#
Alan - Glad you got things working. I was able to get my system working with both sites on the same IP address. My hosts file looks like this:
I'm no expert, but I don't think either way is necessarily right or wrong. There are usually several ways to get the job done. The key on this one is to make sure to run the apache2 reload command. I've also chased my tail a bit due to Firefox caching a page. The Web Developer Toolbar plugin provides an easy way to clear the browser cache.
I just remembered that I also explicitly set up localhost to point to the /var/www directory, so that may have made a difference on my setup.