Skip to navigation

How to run a web server off a usb flash drive

Actually, turns out to be really easy:

  1. Install Slax on the USB flash drive. Here’s how I did it.
  2. Download the Xampp module for Slax. I got version 1.6.2 from here.
  3. Copy the Xampp_1_*_.mo file that you downloaded to the modules folder on your USB flash drive.
  4. Boot off the USB flash drive.
  5. Open a terminal and type:
    /opt/lampp/lampp start
  6. Open Konqueror and navigate to the URL http://127.0.0.1. You should see the Xampp info screen.
  7. To see what your webroot directory is, look at /opt/lampp/etc/httpd.conf. Here, it is /opt/lampp/htdocs.
  8. I added a symlink in opt/lampp/htdocs to a directory called slax_files on the larger data partition on the usb drive (I had partitioned the drive and put Slax on the smaller partition). I can now access files in that folder at http://127.0.0.1:slax_drives/ (This symlink does not survive a reboot. See the next post on how to make it permanent.)

27 Responses to “How to run a web server off a usb flash drive”

  1. Srky Says:

    I can not navigate to the URL http://127.0.0.1 !:(

    I get this:

    Forbidden

    You don’t have permission to access / on this server.
    Apache/2.2.4 (Unix) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2 Perl/v5.8.7 Server at 127.0.0.1 Port 80

    What is problem?

  2. Marianne Says:

    Hi Srky,

    Check the permissions of the stuff in your webroot dir. Files should be readable by all, dirs r and x by all.

    Also, make sure you have an index.html or index.php in your web root. On my slax, there’s an index.html in /opt/lampp/htdocs that includes a referrer to /xampp/, and in /opt/lampp/xampp, theres another index.php.

    m.

  3. Srky Says:

    Thanx for your fast reply M, but I`m not so sure I understand this.

    I think I have this index.html files at that places.

    I`m relatively new in web servers but I`m trying:)

    Where is webroot directory?

  4. Marianne Says:

    Look at the file httpd.conf, see item no. 7 in the original post. Look for the line with DocumentRoot. That is your web root directory (this is where apache looks for files to serve).

    Make sure you check the file permissions in that directory as I said in the previous comment.

    I’m also new to web servers :)

  5. Srky Says:

    Here we are:

    DocumentRoot “/opt/lampp/htdocs”

    Permissions –

    Owner: Can View & Modify Content

    Group: Can View Content

    Others: Can View Content

    Only owner can rename and delete folder content – left empty.

    Ownership –

    User: nobody
    Group: root

    6. Open Konqueror and navigate to the URL http://127.0.0.1.
    You should see the Xampp info screen.

    http://127.0.0.1/

    403 Forbidden

    You don’t have permission to access / on this server.

    What went wrong?:(

  6. Marianne Says:

    That looks okay. The files in there should also be readable, in particular the index.html file.

    You could also create a new minimal html file in /opt/lampp/htdocs, call it for example test.html:

    <html>
    <body> 
    It works.
    </body>
    </html>
    

    Make sure that has “readable by everyone” permissions, then point Konqueror directly to 127.0.0.1/test.html

    If that doesn’t work, another thing I can think of (but I’d say it’s unlikely) is that for some weird reason on your machine localhost isn’t 127.0.0.1. You could try http://localhost instead, or go to a terminal, type ifconfig and look for an interface called lo, and try the IP address you see.

    If that’s not it, my next guess is that it’s some setting in your httpd.conf, though if you got the same xampp as I did, it would be odd that it would have restrictive settings. I don’t know more about httpd.conf, so you’d have to just read it and try out some changes. It contains pretty good comments.

  7. Srky Says:

    If:

    root@slax:~# /opt/lampp/lampp stop
    Stopping XAMPP for Linux 1.6.2…
    XAMPP: Stopping Apache with SSL…
    XAMPP: XAMPP-MySQL is not running.
    XAMPP: Stopping ProFTPD…
    XAMPP stopped.

    Browser says:

    An error occurred while loading http://127.0.0.1/:
    Could not connect to host 127.0.0.1.

    If:

    root@slax:~# /opt/lampp/lampp start
    Starting XAMPP for Linux 1.6.2…
    XAMPP: Starting Apache with SSL (and PHP5)…
    XAMPP: Starting MySQL…
    XAMPP: Starting ProFTPD…
    XAMPP for Linux started.

    Browser says:

    Forbidden
    You don’t have permission to access / on this server.
    Apache/2.2.4 (Unix) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2 Perl/v5.8.7 Server at 127.0.0.1 Port 80

    Server is here, my localhost is 127.0.0.1 but it refuse to replay!

    I found on the internet this Error 403 Forbidden and this is what it looks like:
    (I hope it may be usefull if something goes wrong)

    HTTP Error 403 – Forbidden
    Introduction

    Your Web server thinks that the HTTP data stream sent by the client (e.g. your Web browser or our CheckUpDown robot) was correct, but access to the resource identified by the URL is forbidden for some reason.

    This indicates a fundamental access problem, which may be difficult to resolve because the HTTP protocol allows the Web server to give this response without providing any reason at all. So the 403 error is equivalent to a blanket ‘NO’ by your Web server – with no further discussion allowed.

  8. Marianne Says:

    Well, yes, that’ s the problem, but the solution might still be quite simple.

    (BTW, of course you get an error whey you stop lampp, because now apache isn’t running).

    I just did a mini test on this machine with apache2 (not lampp, but I don’t think it should make a difference):

    If I remove read permissions for others from index.html in my web root (chmod 600), I get:
    You don't have permission to access /index.html on this server.
    If I remove index.html altogether from the webroot (rename it to something else), I get:
    You don't have permission to access / on this server.

    That’s why I asked whether you have an index.html file in your web root. Now, for my lampp, the index.html is just a redirect to something like xampp/index.php, so to remove a layer of complexity, I asked you to create the test.html, make sure everyone can read it (chmod 644) and try to connect to localhost/test.html or 127.0.0.1/test.html. Did that work?

    In any case, if it didn’t, that’s as far as I can help you, but if you find out what it was, I’d be curious to know. Goog luck!

  9. Srky Says:

    Ok. This is my first step, thanx for your patience. I will inform you about my discoveries:)

  10. Srky Says:

    HI, M

    still don`t have permission:(

    This is the content of my /opt/lampp/htdocs/index.html

    Is your the same?

  11. Anonymous Says:

    Hi M.

    This is the content of my /opt/lampp/htdocs/index.html

    It includes a referrer to /xampp/ but there is no xampp folder!

    I have no folder xamp in /opt/lampp/ either.

    Only xampp that I have is in /opt/lampp/htdocs.

    S.

  12. Srky Says:

    Hi M.

    This is the content of my /opt/lampp/htdocs/index.html

    It includes a referrer to /xampp/ but there is no xampp folder!

    I have no folder xamp in /opt/lampp/ either.

    Only xampp that I have is in /opt/lampp/htdocs.

    S.

  13. Srky Says:

    Hi M.

    This is the content of my /opt/lampp/htdocs/index.html

    html
    head
    meta name=”author” content=”Kai Oswald Seidler”
    meta http-equiv=”refresh” content=”0;url=/xampp/”
    /head
    body bgcolor=#ffffff
    /body
    /html

    It includes a referrer to /xampp/ but there is no xampp folder!

    I have no folder xamp in /opt/lampp/ either.

    Only xampp that I have is in /opt/lampp/htdocs.

    S.

  14. Marianne Says:

    This is the content of my /opt/lampp/htdocs/index.html

    What is?

    Only xampp that I have is in /opt/lampp/htdocs

    That should be fine, since htdocs is the web root (DocumentRoot) and the path is probably relative.

    Did you try creating the test.html? Did you get an error message? What was it exactly?

  15. Srky Says:

    Yes I tried to create test.html, but the aswer is the same:

    Forbidden

    You don’t have permission to access / on this server.
    ———————————————————————————————————————–
    Apache/2.2.4 (Unix) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2 Perl/v5.8.7 Server at 127.0.0.1 Port 80

    I`m confused

  16. Marianne Says:

    Your index.html looks fine. As I told you, it’s a redirect. Go to /opt/lampp/htdocs/xampp and check the permissions for that folder and the files in it. Must be readable by all, and the directory xampp itself must be executable by all (rwxr-xr-x). Do you have an index.php in there, is that readable by all. Really, I’ve already typed up all the steps I would check above, but I don’t get the impression you actually checked them. If it’s none of these things, again as I said before, I’d go and take a look at httpd.conf.

  17. Marianne Says:

    Yes I tried to create test.html, but the aswer is the same:
    Forbidden
    You donít have permission to access / on this server.

    That’s odd, because I would expect it to say “You don’t have permission to access test.html on this server.” Just to double check, did you put in http://localhost/test.html into the URL bar?

  18. Srky Says:

    /opt/lampp/htdocs/xampp drwxr-xr-x root

    /opt/lampp/htdocs/xampp/index.php -rwxr-xr-x root

    is that ok?

  19. Srky Says:

    Sorry for confusing you about (17).

    Forbidden

    You don’t have permission to access /test.html on this server.
    Apache/2.2.4 (Unix) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.2 Perl/v5.8.7 Server at localhost Port 80

  20. Marianne Says:

    Okay. So if your permissions for /opt/lampp/htdocs/test.html are readable by all, then I can only imagine that you have some restrictive settings somewhere else. You really need help from someone who knows more than I do :)

    Go dig around httpd.conf, or do ls -a inside your htdocs directory and see whether you have a restrictive .htaccess file in there. Though that’s really unlikely with a fresh xampp install I’d guess.

  21. Marianne Says:

    /opt/lampp/htdocs/xampp drwxr-xr-x root
    /opt/lampp/htdocs/xampp/index.php -rwxr-xr-x root

    That should be fine.

  22. Srky Says:

    Hi M.

    I couldn`t make this thing work on SLAX Standard…

    Slax Server means business :)

    Happy coding

  23. Marianne Says:

    Interesting. I don’t think I downloaded a Slax server edition, but I’m not sure. Glad to hear you’ve got it running.

  24. Srky Says:

    SLAX Server – hand watch
    SLAX Standard – not original All Stars:)

  25. ed Says:

    Hello Srky,

    Sorry i’m not french,

    i suggest you to verify if your entirely path to your web directory is accessible for all. I tell you that because generally your home directory is set to drwx—— by default and so even if your web directory is rwxrwxrwx you cannot access to it.
    So you can go to the / directory in root, and enter the command :
    #chmod -R 777 /home/user

    I hope that helps you.

    Bye

  26. ed Says:

    in the previous message I make error I would say sorry i’m french and i don’t speak english ;)

  27. solved Says:

    cd /opt/lammp
    chmod -R 777 /htdocs