Jump To Content

Linux, Apache, MySQL and PHP (LAMP) Server configuration

Introduction

This lesson will be about the usual configuration of a LAMP server in Fedora 9. Feel free to add links to other distro HowTo's or contribute a lesson based on another distro.

Procedure

Linux

Go get Fedora from the site.
http://fedoraproject.org/

You might, also, want to try and download a respin, since they have the up-to-date versions of packages and updates available for the current distribution version.
http://spins.fedoraunity.org/

Apache

  1. Installing Apache means installing the program which will handle requests to your web server. For most people, Apache itself is the web server, terminologically speaking. In your Fedora Core installation, depending on the choices you made during the install process, you may or may not have Apache already installed. Just use the following command to check:
  2. [renich@introdesk ~]$ rpm -q httpd
  3. If it tells you a version number, then it's installed and we can progress to the next step. Otherwise, we need to install it:
  4. [renich@introdesk ~]$ su -c 'yum install httpd'
  5. After installation, the service must be configured to start automatically.
  6. [renich@introdesk ~]$ su -c '/sbin/chkconfig httpd on'
  7. To start the server process immediately:
  8. [renich@introdesk ~]$ su -c '/sbin/service httpd start'
  9. Finally, it's important to make sure that port 80 is remotely accessible, by configuring iptables to open the port (and to leave it open by default from the outside). The following commands will remember the rule for you across reboots and apply it immediately:
  10. [renich@introdesk ~]$ su -c '/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT'

    [renich@introdesk ~]$ su -c '/sbin/service iptables save'

    [renich@introdesk ~]$ su -c '/sbin/service iptables restart'

    You can put in the hostname or IP address of the server in the address bar of a web browser (whether on the same host or elsewhere in the network) to test the installation. You'll see a welcome page if everything was successful. Otherwise, refer to troubleshooting.

MySQL

  1. Installing and running the database component of the LAMP stack, called MySQL, is at least as easy. The following command will install the database and the server process.
  2. [renich@introdesk ~]$ su -c 'yum install mysql mysql-server'
  3. The server process must likewise be running and accessible.
  4. [renich@introdesk ~]$ su -c '/sbin/chkconfig  mysqld on'

    [renich@introdesk ~]$ su -c '/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT'

    [renich@introdesk ~]$ su -c '/sbin/service iptables save'

    [renich@introdesk ~]$ su -c '/sbin/service iptables restart'

    [renich@introdesk ~]$ su -c '/sbin/service mysqld start'
  5. To test that everything is working okay so far, run this command to print out some information and check its status:
  6.  # mysqladmin version status

PHP (or Perl or Python)

    PHP interprets the scripts of your favorite web site or application, running on top of the other parts of the LAMP stack.

  1. The following command will install PHP, along with the needed stuff to glue it together with the web server and the database.
  2. [renich@introdesk ~]$ su -c 'yum install php php-mysql'
  3. PHP is pretty much ready to run after that, although you may need to restart the web server to make sure it loads the PHP module.
  4. [renich@introdesk ~]$ su -c '/sbin/service httpd restart'
    If you'd like to use another 'P' in the place of PHP (or install alongside), the steps are pretty similar. Both Perl and Python come with ways to access MySQL and modules to allow them to run smoothly and quickly inside of Apache.

  5. To run Python on your web server, run the following. (Python is already installed on all Fedora installations, so it's not needed to install that as well.)
  6. [renich@introdesk ~]$ su -c 'yum install mod_python MySQL-python'
  7. For Perl, the following will get you started:
  8. [renich@introdesk ~]$ su -c 'yum install perl mod_perl perl-DBD-mysql'
    Don't forget to restart the web server after either (or both) of these commands to make sure the relevant modules will be loaded by Apache.

Troubleshooting

Definitively testing the whole thing is pretty easy. You can create a small test PHP file and try to access it.
  1. Create the test script:
  2. [renich@introdesk ~]$ su -c 'echo "<?php phpinfo(); ?>" > /var/www/html/index.php'
    Then access the web server by putting the address in any web browser that can access the server. If your server's IP address is 192.168.1.100, put that in the address bar. By going to that address, you should see a long detailed page describing PHP's configuration and status in detail.

    You can skip down to the MySQL section by putting a jump in the address bar to it. (If you used http://192.168.1.100/ to access the page, use http://192.168.1.100/#module_mysql to skip down to the relevant part.) You should see various options about MySQL enumerated.

  3. If all this is successful, you should delete the script you just created.
  4. [renich@introdesk ~]$ su -c 'rm -f /var/www/html/index.php'
    Now it's time to install your favorite web application (phpBB, mediawiki, squirrelmail/roundcube) or learn PHP.

References

Here are some LAMP references from other distributions:

# Ubuntu
https://help.ubuntu.com/community/ApacheMySQLPHP

# Mandriva
http://www.howtoforge.com/perfect_server_mandriva_2008.0

# Gentoo
http://gentoo-wiki.com/LAMP

Credits

Original HowTo from: http://fedorasolved.org/server-solutions/lamp-stack/?searchterm=lamp

Copyright (c) 2008 by hypodermia. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, vX.Y or later (the latest version is presently available at http://www.opencontent.org/openpub/).
Renich
  • Authority 185
Post Body
Renich said:

It would be cool if somebody could contribute some other distro’s specialized lesson!

I’m a Fedoran!

  • Quote
  • Posted 4 months ago.
  • Your comment will be modifiable for 10 minutes after posted.

Page Author

Avatar
Renich
Name
Renich

From Here You Can…

Information

  • 2131 Views
  • 1 Comment
  • Ratings Likes 2 Negative 0

Most Recent Related Content

  • Lesson
    Avatar
    Avatar
    Title
    Functions - Basic Concept
    Body
    Today, we will see yet another concept present in any programming language. N...
    Author
    zainvi_sf zainvi_sf
  • Lesson
    Avatar
    Avatar
    Title
    Using Aplications made for Windows in Ubuntu
    Body
      Did you know that you can run lots programs available to windows in ub...
    Author
    kir360 kir360
  • Lesson
    Avatar
    Avatar
    Title
    C++ As Better C
    Body
    Before moving on further in advanced C++, it is better to ensure us that C++ ...
    Author
    zainvi_sf zainvi_sf
  • Lesson
    Avatar
    Avatar
    Title
    More On Classes
    Body
    OOP encapsulates data(attributes) and functions(behaviors) into packages call...
    Author
    zainvi_sf zainvi_sf
  • Lesson
    Avatar
    Avatar
    Title
    Linux Podcasts
    Body
    Learning Linux nowadays come not from just one source. The whole environment ...
    Author
    jza jza
  • Video
    Avatar
    Avatar
    Title
    Rkward
    Description
    KDE GUI front end for the R-base environment great for statistics.
    Author
    jza jza
  • Lesson
    Avatar
    Avatar
    Title
    Education Project
    Body
    The OpenOffice.org education project created last year which mission is to gi...
    Author
    jza jza
  • Lesson
    Avatar
    Avatar
    Title
    Union, Typedef, Enums
    Body
    By now, you already know what is an array, what is a structure, and how to us...
    Author
    zainvi_sf zainvi_sf

Published In…

This work is public domain.