LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-15-2012, 05:32 AM   #1
lilleskut
LQ Newbie
 
Registered: Feb 2012
Posts: 19

Rep: Reputation: Disabled
Apache PHP MySQL setup newbie


I would like to test a program/website written in php/mysql on a local computer.

So I installed apache, mysql and php5 in (debian) linux and put the website in /var/www/

If I go to "localhost" in a browser, it correctly displays the homepage. However if I try to follow any link on the page, I get a page not found message, e.g.:

"The requested URL /customPage/About us was not found on this server."

I suspect that I need to setup my webserver somehow, but don't really know what to look for.

Any help would be appreciated.
 
Old 02-15-2012, 07:13 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
You have your index.html in /var/www/htdocs? If you're adding page links, you add them as http://server.domain/directory/file.html. server.domain is the name you gave it in /etc/httpd/httpd.conf (or wherever your httpd.conf file is).

So, take a look at httpd.conf and think about these sections:
Code:
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
#Listen 80
Listen  192.168.1.10:80
The server is fixed-IP at 192.168.1.10 and we listen on port 80.
Code:
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName fubar.com:80
This server, fubar.com, is not identified as www (because it's not available to the Internet). If yours is, use the "www.example.com:80" syntax.
Code:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
Add (at least) index.php to the DirectoryIndex line.

Now, for example, I have Bugzilla installed. For it to work, it's in /var/www/htdocs/bugzilla; that directory contains all the Bugzilla software.

At the bottom of /etc/httpd/httpd.conf I have this:
Code:
# Uncomment the following line to enable Bugzilla
Include /etc/httpd/extra/httpd-bugzilla.conf
My /etc/httpd directory contains a sub directory, extra. The file httpd-bugzilla.conf looks like
Code:
# Bugzilla
<Directory "/srv/httpd/htdocs/bugzilla">
        AddHandler cgi-script .cgi
        Options +Indexes +ExecCGI
        DirectoryIndex index.cgi
        AllowOverride Limit
</Directory>
and the link to Bugzilla in index.html is http://fubar.com/bugzilla (yes, my server is actually named fubar.com -- but not to the outside world because there is a www.fubar.com. That's not a problem. Note that Bugzilla launches with index.cgi, not index.html or index.php.

Note that the the address is /srv/httpd/htdocs/bugzilla? That's what you want to use; the token "srv" is equivalent to "/var/www." You can use absolute path but it may cause problems later, best to use the default "srv."

I have another application PHPGedView, which is launched with index.php in the directory /var/www/htdocs/phpgedview and the link on index.html points to http://fubar.com/phpgedview. There is no additional "stuff" in httpd.conf for PHPGedView, only the index.php addition to the DirectoryIndex line.

I know that's a little confusing but a PHP application works that way where something like Bugzilla (which is not a PHP application) works with CGI; different breed of kitty cat.

Too, you must have PHP enabled. In my httpd.conf that's done with
Code:
# Uncomment the following line to enable PHP:
#
Include /etc/httpd/mod_php.conf
and that file looks like
Code:
#
# mod_php - PHP Hypertext Preprocessor module
#

# Load the PHP module:
LoadModule php5_module lib64/httpd/modules/libphp5.so

# Tell Apache to feed all *.php files through PHP.  If you'd like to
# parse PHP embedded in files with different extensions, comment out
# these lines and see the example below.
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

# Tell Apache to feed all *.php, *.html, and *.htm files through
# the PHP module.  Add or subtract extensions here as desired.  Please
# note that running pages through PHP for no reason can be both slow
# and insecure, so be sure to know what you're doing.  It's a convenient
# shortcut, but probably isn't suitible for high-traffic sites if you
# write any of your pages in straight HTML.
#<FilesMatch "\.(php|html|htm)$">
#    SetHandler application/x-httpd-php
#</FilesMatch>

# This will display PHP files in colored syntax form.  Use with caution.
#<FilesMatch "\.phps$">
#    SetHandler application/x-httpd-php-source
#</FilesMatch>
Yours may vary but that's the basic requirement.

So, after all that stuff is taken care of you'll find that going to "http://localhost/blah" isn't the way to get to it -- just go to the actual server name and domain that you defined (here it's "fubar.com") and it'll probably work for you.

Hope this helps some.
 
Old 02-17-2012, 11:42 AM   #3
lilleskut
LQ Newbie
 
Registered: Feb 2012
Posts: 19

Original Poster
Rep: Reputation: Disabled
Thank you for the reply.

Eventually I figured it out. The problem was that the .htaccess was not recognized, so I had to change "AllowOverride" in my apache config.

---------- Post added 02-17-12 at 12:43 PM ----------

Thank you for the reply.

Eventually I figured it out. The problem was that the .htaccess was not recognized, so I had to change "AllowOverride" in my apache config.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How I setup Apache,Mysql,PhP on Slack 10.2 Tiepo Slackware 6 06-25-2006 03:51 PM
PHP/MySQL and Apache server setup nenyo Linux - Software 7 02-12-2005 01:48 PM
Apache/PHP/MySQL Setup Help jobless_joe Linux - Software 2 05-30-2004 01:55 PM
Apache PHP MySQL Setup after Slackware 9.0 Installation initself Slackware 37 12-20-2003 06:48 AM
Newbie Linux/Apache/SSL/MySQL/PHP Instalation Dilema rojow Linux - Software 12 10-24-2003 04:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration