PCLinuxOS-Forums
 
*
Welcome, Guest. Please login or register. July 29, 2010, 01:21:10 PM


Login with username, password and session length


Pages: [1] 2   Go Down
  Print  
Author Topic: XAMPP/Apache2 and PCLinuxOS - A Howto  (Read 20710 times)
Synful_Coder
Guest
« on: February 13, 2006, 04:20:12 AM »

There are several web server's available, my personal favorite is apache. Apache is so wonderful because the power within the configurations.  I know that some people out there have their personal favorites, and i expect no less from anyone here. So here is a simple way to get apache up and running.  The below is a wonderful webserver software that can be found easily by typing "XAMPP " with or without the quotes, into any search engine. I recommend this because it's apache and does most of the work for you. There are alternatives, but like..  who cares, right?   Wink

XAMPP is a simple solution for starting your simple/personal web server,  This has mostly everything one would need to start a website, and includes full documentation and security measure's, a great way to start web development or even to start working with a scripting language like perl, python, and even php or java..  You can find out more on their site, but note, this is only for those who have taken the steps of installing the distrobution or who know how to create a partition and mount it for saving files.   if you do not fall under one of those catagories, your best to not even mess with personal web server hosting. 

:: SECURITY WARNING!! :: Shocked
Never, ever install a web server onto a personal desktop/laptop unless your using it for development, This is because it is easier to gain access to one's personal files from a "Cracker".  Alway's use a spare older or outdated computer with only the basic stuff needed. The more you install, the more risk you will run of an attacker using bad source-code on your box to gain access and allow for many things to be done once that far.  Remember to apply security for everything and never use the same passwords for everything. that being said, here is a few tips for making it harder on an attacker:
 
1.) Remember to make a sub-directory under the root folder (" / ") called: " srv " if one is not already created, you will want to make most of these files and folders read-only:
in the shell, it would look like this:

user@example~:$ cd /srv
user@example:/srv$ su -c ' chmod 644 <filename>
password:


The above is a simple way to make it so that root is the only person able to have write access.
There is a site, http://www.ss64.com/bash/chmod.html  that you can learn more about chmod and it even has a tool inside that page that allows you to ajust chmod's simple and easy like Smiley
Make sure not to use the "<", ">" and make sure that you always use the su -c 'program name' for running programs as super user, because the -c just runs that one program and then once finished, it will log out and back to the normal user account.

:: DIRECTIONS ::
Okay, we have created our own personal directory for the server, chmoded all the files and folders, we are now ready to start to point apache to this folder, we will want to configure the apache.conf to point here, i will choose to create another folder within the system and called it www, so it will come out looking like:  "/srv/www"

Ok, here is the apache.conf i have setup for a my personal development site:
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
# Feel free to copy and paste all of this into your apache.conf or whatever your main configure
# file is.
DocumentRoot "/srv/www/"

# Aliases: aliases can be added as needed (with no limit). The format is
# Alias fakename realname
# This is for creating a link within apache for the icons it defaults with during install.  It's
# Mainly just an example of how to add a non /srv/www directory into apache and the link
# would look like " http://localhost/icons " without the quotes. Cool huh?
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
   Options Indexes MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

# the main configuration file consists of many of these examples, and all can be tested and
# toyed with, just backup the main config file by copying it, pasting it, or renaming it with a
# ~ at the end of it.  Just play around with it, and if all goes wrong, just remove the ~ from
# the name of the backup or paste the copy made back in.  All of this will have to be done
# from within the superuser trick i showed you before. but here is the command for doing
# this incase you just want to have it for later:
# su -c  'mv /home/username/apache2.conf /etc/apache2
# make sure to make another backup or just use the command "cp" instead of "mv"

Well that about cover's the simple personal web server, if you have any more question's about apache config's, there is massive amounts of tutorials around the net, i recommend using the apache website at:
http://www.apache.org website, there is so much help available from that one site that is often over-looked.
The best way to learn anything though, is through trial and error, make the proper backup's and tinker. that is what truely sets apart the common-hacker apart from the crowd Tongue

Take care and happy web development all of you PCLinuxOS user's.  I don't personally use PCLinuxOS, but i know a good distro when i see one, and if your that new user friendly, i am willing to share my advice, tips, and tricks with all of you. Feel free to ask your questions, message me if you wish, please make this little tutorial a sticky and allow other's to add their feedback and comments.  I hope to keep bringing more information for all and will contribute as much as i can.

I only offer this because the wiki was blank and it would not allow me to write up a catagory for the blank one missing  Roll Eyes
Logged
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #1 on: March 04, 2006, 02:44:04 AM »

Hi Synful_Coder,

I've placed the contents of this howto on the web. I've nade some very minor corrections / additions in the process.
The page is: http://www.pclinuxonline.com/wiki/SettingUpWebserver

If you want you can edit/update it by registering for an account.

Although it doesn't say very clearly, if I remember correctly the wiki and its contents are under the gnu free documentation license. Basically the GPL for text. If you feel my posting of your work isn't correct (because of your copyrights, or you just don't want it in the wiki) let me know so I can remove the text from the wiki again.

Thanks for your help!
Logged
rustynail
Hero Member
*****
Offline Offline

Posts: 1374


« Reply #2 on: March 14, 2006, 06:08:11 AM »

Good writeup.

I have gotten this far, but now how do I go about getting the permissions in perl all squared away?  I have a test bed that I am trying to run cgi scripts outside of the cgi-bin directory but get all kinds of errors. 

Errors range from software (no number) to 500 errors.
Logged
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #3 on: March 14, 2006, 11:29:31 AM »

If with executing a perl/cgi script you get 500 errors, it usually means an error/bug in the perl program...
Logged
rustynail
Hero Member
*****
Offline Offline

Posts: 1374


« Reply #4 on: March 14, 2006, 07:03:49 PM »

If with executing a perl/cgi script you get 500 errors, it usually means an error/bug in the perl program...

That's what I thought too, but it is an program that I had written a few years back and it has been running under windows.  And it runs without any problems directly at the command prompt.  I can copy and past the results into a text.html file and view it properly from a browser.


Logged
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #5 on: March 15, 2006, 01:44:52 AM »

Perhaps some environment variable or something?
Or read/write permissions? The apache server runs the perl script as another user as you do. Make sure you have the user permissions set up correctlY.
Other perl scripts do run? It's not a misconfiguration on the side of apache?
Logged
rustynail
Hero Member
*****
Offline Offline

Posts: 1374


« Reply #6 on: March 15, 2006, 05:35:44 AM »

Perhaps some environment variable or something?
Or read/write permissions? The apache server runs the perl script as another user as you do. Make sure you have the user permissions set up correctlY.
Other perl scripts do run? It's not a misconfiguration on the side of apache?

The permissions thing is where I am stuck I guess.  I don't think apache is misconfigured because it runs the simple "Hello, World." script just fine.  The script that I have is rather complex that accesses several other files and subdirectories.  I honestly feel that I am on my own on this one. 

Would it be safe to say that if it runs at the prompt properly but errors out at the browser that it is a permissions/configuration issue?

Thanks for the input, it does help.
Logged
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #7 on: March 15, 2006, 05:43:42 AM »

I'm guessing the accessing files and directories is indeed where your problem is at.

You could 'solve' that by making the files and folder you need to read readable/writable by everybody.
You can right-click on a folder from konqueror file manager, and set the correct permissions. Others or all is probably what you need to set.

Commandprompt it is
chmod a+rw filename

Or a folder with all its files
chmod a+rw dirname -R

Better make real sure you open up the correct files to the world though! And make a backup before you change permissions, they are a nightmare to set back. So a backup would be crucial if you want to restore the correct permissions.

It's probably better to find out as which user apache is running and grant read/write/change/etc access to the user running apache.
Can't remember specifically how you do that though... it has been a few years, and I'm thinking that the xampp package doesn't run as a specific user, which preempts that solution.



Logged
rustynail
Hero Member
*****
Offline Offline

Posts: 1374


« Reply #8 on: March 15, 2006, 06:16:19 AM »

Your input most certainly helps. 

The windows versions of things doesn't care much about permissions either.  Good or bad, it was easier.  I was almost tempted to ftp into my server and setup that way. 

Right now all the files are root owned and not sure what apache is.  But you bring up a good point about to see which user apache runs in. 

Will post my findings.

Thanks.
Logged
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #9 on: March 15, 2006, 06:48:26 AM »

Well, even on Windows you need to set it up correctly. If you take ASP.NET for example, you have to set files you want to change up for the ASPNET user, basically using NTFS permissions. You have to even set up which folder can hold 'executable' pages, via the virtual folder features in the Internet Information Services...

Not that I'd know any of that though, obviously, never using Windows or ASP.NET. [cough] [cough]  Smiley
Logged
Spacebar
Guest
« Reply #10 on: April 10, 2006, 06:59:49 PM »

I recently setup mine. How?
1) Went to Synaptic
2) Went through the LAMP alphabet and
  • Added "apache-base", and deps
  • Added the main "mysql" package (can't remember specific name), and deps
  • Added "phpMyAdmin" and all deps
3) Applied
4) Rebooted
5) Found the folder in /var/www
6) Went crazy!

Couldn't have been simpler!
Logged
daiver
Sr. Member
****
Offline Offline

Posts: 383

Linux n00b


WWW
« Reply #11 on: May 05, 2006, 06:46:46 PM »

Is there some sort of way to add a user to the box and lock him in /var/www, whithout read/write permissions to the rest of the box?
Logged

Toshiba Satellite M65-SP811
Centrino 2.0
2 GB RAM
ATI Mobility Radeon x600 128MB
Intel Wireless B/G 2200
17" 1440 x 900 native resolution

PCLOS on a M65: www.aeroforo.com/linux
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #12 on: May 06, 2006, 01:21:41 AM »

Hmm, never tried that, actually.
I'm *guessing* you could try to create a new user and new group, not include him (or his group) in any other group. No home-folder. Then set the /var/www folder to this user and group using a chgrp and chown? Still to find out how to configure apache to then use that user, and how to figure out which user apache uses by default?

Spacebar: I've added your procedure to the wiki page about setting up a personal webserver.
Logged
daiver
Sr. Member
****
Offline Offline

Posts: 383

Linux n00b


WWW
« Reply #13 on: May 06, 2006, 11:37:17 PM »

I know very little, but it does seem kind of logical that you add a user and lock him in.  If there's any vulnerabilities en Apache (specially for those who are starting out, like me) and it gets cracked, then you'll have big problems in /var/www/, but the rest of the box will be safe.  At least, that's how I see it.
Logged

Toshiba Satellite M65-SP811
Centrino 2.0
2 GB RAM
ATI Mobility Radeon x600 128MB
Intel Wireless B/G 2200
17" 1440 x 900 native resolution

PCLOS on a M65: www.aeroforo.com/linux
LexNL
Sr. Member
****
Offline Offline

Posts: 469


« Reply #14 on: May 07, 2006, 01:32:17 AM »

yep, that's how it is.
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM