|
Setting up Apache, MySQL, and PHP4 on a Debian System For LAMP on Debian Etch I have 2 tutorials, local web server and something suitable for a live LAMP on Etch It's pretty easy to get a working local web server on your Debian box. You can use the command line (apt-get install) to get your packages or fire-up Synaptic to do it. When I set up LAMP I need my web server to work for various Content Management System (CMS) scripts. Some, like VTiger use gd for image manipulation, so I install that aspect when installing the web server. As well, I use Mambo for many sites, this one included, so I install php4-pear, curl, etc.
You will probably need less components, and if you're only coding html, all you need to install is Apache. Today we'll install Apache, PHP4, and MySQL. README: This brief tutorial sets up a local web server. Local! This tutorial is not intended to set up a real, live running web server serving up pages to the world. In no way is this a suitable tutorial for accomplishing that task. If you want to compile your own LAMP packages it's simple to do as well, just visit this compiling LAMP tutorial. Since you're coming from Windows we use a fancy GUI in the tutorials on debiantutorials.org. Mostly. Also, to make life really easy you'll be installing Webmin to admin your server, et al. Webmin can do a lot and can admin your entire machine, but I don't use it for much and I never leave it running.
On to business...open Synaptic and search for "apache". Right-click apache 1.3.33-6 in the results and choose to "mark for installation". It'll have dependencies so allow those to be installed as well. Don't forget to also select: - libapache-mod-perl
- libapache-mod-ssl (you never know)
Next, search for "php4". This pic illustrates the php4 components that I have installed on my machine. They are not all necessary for you but no harm if you install them as well. Make sure you install: - libapache-mod-php4
- php4-mysql
The rest of the php4 modules are fluff, but handy. Installing php4 is a good idea. Yes to dependencies.
Next search for "mysql" and right-click on "mysql-server" and mark for installation. Again, there will be dependencies. Even if you don't plan to utilize MySQL in a web environment, there are many cool applications that you might feel like installing someday that use the MySQL database.
Following the selection of these LAMP components, install 'em! You may be prompted a couple times during the actual installation; things like setting up Apache, stopping or restarting it, etc. etc. I let it restart during installation when it installs a module or otherwise must stop to incorporate a change in its configuration file. You don't have to worry, it's OK to do this. Also, when prompted to run Apache in SuEXEC it's OK to say NO. (See the following "SuEXEC on a local machine" search result. Good info on page 1 and 2, search for "SuEXEC" on the pages)
Following the install open a terminal because we MUST create a password for your Admin (root) user in MySQL. There are many that say to change the default username but I think you're covered by just picking a password. This setup won't be serving actual pages on the web will it? If it is then this tutorial is not for you as I do not discuss securing your web server. That's a different tutorial for a different day. For today, see any of the following Google search results: Continuing, in your terminal type the following as a regular user: $ mysqladmin -u root password [pick-a-password] Next, let's make sure php4 will work with MySQL. Go ahead and open the following file: # gedit /etc/php4/apache/php.ini this will open your PHP configuration file so you can un-comment a couple things. I just search for mysql.so to find the section quickly. ; Example lines:
;extension=mysql.so
;extension=gd.so remove the semi-colons in the beginning of each line beginning with "extension". Save the file and exit Gedit. Following any changes you make to the httpd.conf (or module conf files like php.ini) you must restart apache: # /etc/init.d/apache restart At this point, installing LAMP this way, Apache and MySQL will both start when your machine does. I don't normally utilize the public_html capabilities letting each machine user have a web directory in his/her /home directory. You may want to do this, just because it's easier when creating your websites. Example, you want to start writing websites in .html. You cannot save your project files/folders to your /var/www directory because it's chmod'd and chown'd to keep regular users out. It's a good thing - Linux security 101. To take advantage of multi-user home web directories see this: link or do your own search. At this point you do have a working web server but we'll want to modify your httpd.conf file a little to allow for .php pages...and stuff. We'll also install phpmyadmin for easy database management (ish) and Webmin 'cos you never know. Installing phpmyadmin is as easy as opening your terminal and running the following command: # apt-get install phpmyadmin A link will be created in your /var/www directory so running phpmyadmin is as simple as typing: 127.0.0.1/phpmyadmin into your web browser's address bar. Installing Webmin is just as simple, but first let's install libnet-ssleay-perl so we can run Webmin securely. In your terminal run the following command: # apt-get install libnet-ssleay-perl Go ahead and download webmin right now, I'll wait...Following this, goto the directory you saved the .tar file to and extract the Webmin install directory. Next, cd into the extracted directory ( $ cd /path/to/webmin-1.210 ). Now run the following command to install Webmin: # sh setup.sh /usr/local/webmin
From there follow the prompts, mostly just enter. You may choose your port, uname and password. As well, you may choose to have Webmin start at boot or no. I choose no. The command to start/stop Webmin when you need it is the following:
# /etc/webmin/start # /etc/webmin/stop Now let's get to your httpd.conf file and make a few mods allowing our sites to run. You can change the file from Webmin, or just run a text editor as "root" I open gedit as root. Go ahead and open your /etc/apache/httpd.conf file. Scroll down in the config file until you come to this section: # First, we configure the "default" to be a very restrictive set of
# permissions.
#
Options SymLinksIfOwnerMatch
AllowOverride None
change None to read: AllGo to this section next: # This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None change None to read: AllThen:
DirectoryIndex index.php index.html index.htm index.shtml index.cgi
Make sure index.php is first one the string.If you want to run cgi scripts and the like from another location (default on Debian is here: /usr/lib/cgi-bin ) find this section in the httpd.conf file:
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#
# "/usr/lib/cgi-bin" could be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
and change the default location to a location you desire, like /var/www/cgi-bin.Finally, keep scrolling to the following section: # And for PHP 4.x, use:
#
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps un-comment the two AddType lines.You're finished. Easy - huh? All you have to do now is restart Apache to incorporate your changes. Remember that command? If you forgot, here it is: # /etc/init.d/apache restart There are many cool and/or functional scripts you can now install into your web directory. There are Genealogy scripts (they work as a website), recipe scripts, CMS, a movie database -- the list goes on. You can install some other cool apps that use MySQL as well - like prokyon3 for your music. I also like to put my .oggs and .mp3's into an SQL database so I can run pmreport and revel in the geekness of data! To see your websites open your browser and type: 127.0.0.1/site into your address bar. If you only have one local site and it's not in a sub directory of your /var/www directory, than just typing 127.0.0.1 into your address bar will serve that up. By installing LAMP on your box you just opened up some listening daemons on your machine. You should probably go ahead and install a firewall now if you have not already done so. Fire up Synaptic and search for "firewall". Or, goto your favorite forum and ask around. Popular and very simple scripts are: - Firestarter
- Guarddog
- kmyfirewall
- shorewall
These are just simple front-end scripts for iptables, your built-in firewall.machiner - 13 July 2005 ADDENDUM: Many people are searching for advice on installing Mambo on a Debian system. I know this because I see it in my server logs. May as well do a quick write up for it, ey? This is how I do it: Download the latest Mambo or Joomla from your favorite place -- it's everywhere. Keep your browser open because we'll need that for the install. Also, open your terminal. After downloading the file you will have a .tar.gz file that will need extracting. Careful because the files are not packed in a directory, so when you extract them you'll have all of the files in your server's root directory. If you like to have multiple web sites on your local LAMP server then you'll need to make a directory to put the Mambo (Joomla) files into. You can do it like this: # tar -xvzf /location/of/file/Joomla_1.0.8-Stable-Full_Package.tar.gz --directory=/var/www/joomla The directory will be created. After you've extracted Mambo, or Joomla to your server root you'll need to make the owner of that directory www-data. It's pretty simple, change ownership at the command line like this: # chown -R www-data:www-data /var/www/mambo We're ready to install Mambo. You don't need to create a database first, the install routine will ask you for your mysql credentials and make the database for you. Switch to your browser and open your Mambo site: 127.0.0.1/mambo and you will be greeted by the Mambo install script. It's pretty self explanatory and you can simply go through the 3 or 4 screens and you will be finished. After you install Mambo switch back to your still open terminal and still as root remove the installation directory: # rm -rf /var/www/mambo/installation At this point you're finished. The last screen in the Mambo install will have 2 links atop the page, skewed to the right, pick one: Site or Administrator. Have fun with Mambo.
|