PDA

View Full Version : add pages to the webserver (apache)



felipe_lopes
04-28-2003, 07:07 AM
Hi fellows!

(running from cd):

I started apache typing "apache" on the shell as root user.

After this, I was able to access the html file which are located on /var/www.

So far so good. But, how could I add pages (php pages in my case) on the server root?? When I try to save a file to /var/www I'm not able to (which is understandable)....

Thanks in Advance

Felipe Lopes

Stephen
04-28-2003, 07:39 AM
You could mount a partition on the hard drive as /var/www/ and server yourself webpages from there. You would make a directory on the /var/www/ for your web pages and then sudo chown user:user /var/www/your_directory to change the ownership to your user then you will have read-write access. You would access your web pages by http://127.0.0.1/your_directory/file.html.

probono
04-28-2003, 06:14 PM
or, even easier, edit apache's config file to change it to another path.

felipe_lopes
04-29-2003, 05:17 PM
or, even easier, edit apache's config file to change it to another path.

Even running knoppix from CD am I able to edit apache's config file??

Stephen
04-29-2003, 05:42 PM
or, even easier, edit apache's config file to change it to another path.

Even running knoppix from CD am I able to edit apache's config file??

You can edit the files in /etc/?? they only get saved to ramdisk unless you install to Hard Drive or keep your configuration with floppy config or persistent home.

felipe_lopes
04-29-2003, 06:02 PM
When I tried to edit and save the config file the system said that I had no permission...I guess it impossible to save, isn't it?

Stephen
04-29-2003, 07:37 PM
When I tried to edit and save the config file the system said that I had no permission...I guess it impossible to save, isn't it?

Try editing the file with sudo editor file to be superuser (root) when you edit and save.

felipe_lopes
04-30-2003, 02:59 AM
Try editing the file with sudo editor file to be superuser (root) when you edit and save.

Here what I tried to do:

Open a shell from /etc/apache



sudo su

kedit httpd.conf

I tried to use the shell editor but was too hard for me :cry:

Then I changed the lines I wanted to and when I tried to save it appeared:
"Unable to write to file"

What more can I do?

Stephen
04-30-2003, 04:31 AM
I just booted the CD on a spare computer and it worked for me here although I used vi but that should not matter. Editing the file to change the root really is not going to make much difference anyway you are going to store these files on the HD right? In which case just leave the file as is the support for PHP is already turned on in the httpd.conf and do as I suggested in my post above make a directory on HD and serve yourself web pages from there.

felipe_lopes
04-30-2003, 06:51 PM
You could mount a partition on the hard drive as /var/www/ and server yourself webpages from there. You would make a directory on the /var/www/ for your web pages and then sudo chown user:user /var/www/your_directory to change the ownership to your user then you will have read-write access. You would access your web pages by http://127.0.0.1/your_directory/file.html.

Sorry Stephen, But I gotta be stupid....When I try to create a directory in /var/www/ it returns an error! On your code, what I suppose to put on "user:user"?
Maybe I didn get what you said to do...

thank you and sorry

Felipe Lopes

Stephen
04-30-2003, 07:32 PM
You could mount a partition on the hard drive as /var/www/ and server yourself webpages from there. You would make a directory on the /var/www/ for your web pages and then sudo chown user:user /var/www/your_directory to change the ownership to your user then you will have read-write access. You would access your web pages by http://127.0.0.1/your_directory/file.html.

Sorry Stephen, But I gotta be stupid....When I try to create a directory in /var/www/ it returns an error! On your code, what I suppose to put on "user:user"?
Maybe I didn get what you said to do...

thank you and sorry

Felipe Lopes

In a console window after you have booted from CD:

sudo mount /dev/hda1 /var/www/ - to mount first partition on first drive (c: in windows)

sudo mkdir /var/www/mywebpages - make a directory for your webpages (you could have already done this in windows first and already have your web pages there in which case this would be unnecessary)

sudo chown -R knoppix:knoppix /var/www/mywebpages/* - to change ownership of files in all the directories of your web pages (may not be needed use if it gives you a no permission to access files)

You may only need step one to mount the HD as your /var/www/ then when you type http://127.0.0.1/mywebpages/file.php in the browser your web pages will be served from your HD directory.

The user:user part in post above is your username I should have been a little clearer on that.


Also if it will not let you add pages to your web page directory sudo chown knoppix:knoppix /var/www/mywebpages (to find the ownership of the directory ls -la /var/www/mywebpages)

felipe_lopes
05-01-2003, 03:38 AM
I've done everything you said...The first 2 steps worked fine, but the third step returnned the following error:



root@ttyp0[knoppix]# chown -R knoppix:knoppix /var/www/web/*
chown: changing ownership of `/var/www/web/index.php': Operation not permitted


When I try to access my "web" directory thru konquedor (running apache) it says that I don't have permission to see that page...I'm assuming that it is happen due to the above error...How to solve it?

Thank you Stephen so far!

Felipe Lopes
ICQ:59336685

Stephen
05-01-2003, 04:54 AM
Put sudo in front of the chown line you must be super user to change permissions.

felipe_lopes
05-01-2003, 06:57 AM
But I'm already logged in as root -> "#"

Stephen
05-01-2003, 08:11 AM
Did you make the directory in knoppix or windows? If you made the directory with knoppix you can change the permissions because you just wrote to the drive, if you made it in windows are you by any chance using ntfs file system on the drive you are trying to change the permissions on if this is the case the drive would be mounted read-only you cannot write to ntfs.

Check the output of ls -la /var/www/web and ls -la /var/www/web/* also the output of the mount command to see what the file system type is and whether there is a (rw) at the end of the line with /var/www. If the directory /var/www/web is owned by root then change it to knoppix, also try to change just the single file index.php without the -R in the chown line.

felipe_lopes
05-01-2003, 08:21 PM
Just wondering:

I've edit httpd.conf and then I saved it on my hd (knoppix running from cd)...
Then I started apache this way:


# apache -f /path/to/file/httpd.conf


Didn't worked though!!!
Does it only work w/ knoppix on hd?

smarchand291
11-10-2003, 06:00 PM
Hi guys,
I confirm, using -f (apache -f) is best, transfer your config files(httpd.conf)
onto another partition. but ?

There's a problem here:
trying changing the ownship of files in ... let's say ... /mnt/sda4
(my website resides on sda4)

bring me to "operation not permitted" !
Even as "root" :shock: :? :?: :?: . I already posted a message about that.

wouldn't be best to hdinstall ?

thanks for any info

uname -a
Knoppix 2.4.22 i586 19092003

hdwlist:
sis530 amd k6-2 500, onboard sound
156 mb ram
3com 905btx
cd, ide zipdrive 100mb, sandisk 64mb usb, floppy and hda 2.4 gig
usb ezonics II webcam, wintv-go pci