아래에서 퍼옴.
http://www.zaphu.com/2007/08/21/ubuntu-lamp-server-guide-configure-apache-mysql-and-cgi-bin/
###################################################################
In a previous post, I shared step-by-step instructions for setting up a Ubuntu LAMP (Linux, Apache, mySQL, PHP) server on your local area network (LAN). I also showed how you could customize the server installation to include all of the niceties of Ubuntu’s Desktop GUI. If this installation was successful, you should be able to view the default site served by Apache (actually an index of the default site) using any machine on your LAN. Type the server’s IP address (or alias if you added the server to your
/etc/hosts
file) in your browser’s address bar or, if you are browsing on the server itself, type 127.0.0.1
or localhost
. If an error occurs, then you will have to edit the apache2.conf
file to ensure that Apache can fully resolve the server’s name. Out of
good measure you should do this anyway, even if everything seems to be
working. Use your favorite text editing program (I use vi here) and
open the file.Add the following line somewhere:
and restart Apache.
If the default site loads then you are ready to configure Apache to
serve your own sites. This configuration process may not be familiar to
you if someone else hosts your websites. Here I walk you through the
necessary steps. Additionally, I show you how to install phpMyAdmin to
administer mySQL databases and how to configure a cgi-bin
directory to run CGI programs.
Step 1: Create a new Apache site
To create a new site, first create a directory where you want to
keep files associated with this site. I like to keep sites in my home
directory so (using my user name of sam) I create a /home/sam/public_html
directory. The configuration files for all sites available to Apache are stored in the /etc/apache2/sites-available/
directory. Create a configuration file for your new site (here called
zaphu) by copying the configuration file for the default site.
Open the new configuration file.
You will notice that there is a lot of stuff between <VirtualHost>
tags. You have to edit some of this. Change the DocumentRoot
path to point to the newly created site directory.
In a similar fashion, change one of the Directory
directives (it looks something like this)
to be consistent with your site path.
After making these changes, disable the default site using the Apache disable site script.
Next, use the Apache enable site script to activate the new site.
Finally, restart Apache.
Create a simple index.html
file and save it in /home/sam/public_html/ to test your new site. Something simple like
<strong>Ron Paul for President in 2008</strong>
Browse (preferable on another machine) to your new Ron Paul for President site to test the configuration.
Step 2: Install phpmyadmin and create root mySQL user
In order to make mySQL database administration easy, many hosts provide phpMyAdmin. You can easily install this tool on your Ubuntu LAMP server too using the built in package management software. At the command prompt type
sudo aptitude install phpmyadmin
You will have to insert the Ubuntu install CD to complete this
installation. After the install completes, the phpMyAdmin script should
be in the /var/www/
directory. In order for it to resolve in your browser when you type localhost/phpmyadmin
(or xxx.xxx.xxx.xxx/phpmyadmin
) you must add the following alias to the zaphu site configuration file in /etc/apache2/sites-available/
.
Make sure you add this alias between the <VirtualHost>
tags. After restarting Apache (see above), you should be presented with the phpMyAdmin log in screen when you navigate to xxx.xxx.xxx.xxx/phpmyadmin
.
You can log in by using root as your username without a password
because by default the root password is set to null. To set the root
password navigate to the privileges page and click the icon that looks
like a pencil next to each root account (there may be more than one)
and enter a password in the appropriate field of the page that loads.
Step 3: Configure a cgi-bin directory
Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs (here I create /home/sam/public_html/cgi-bin
) and add the following to the site configuration file (again between the <VirtualHost>
tags).
<Directory /home/sam/public_html/cgi-bin/>
Options ExecCGI
AddHandler cgi-script cgi pl
</Directory>
The first line creates an alias that points to the directory in which CGI scripts are stored. The final line tells Apache that only files that end with the *.cgi and *.pl extensions should be considered CGI programs and executed.
Congratulations! Your new site is configured. It is worth mentioning that if you are going to be granting computers on the wide area network access to your new Ubuntu LAMP server, you should take some time to learn how to properly secure Apache. Check out these other sites for more information on configuring Apache under Ubuntu. Ubuntu Community, Apache2.2 Documentation
If you liked this guide, show support by leaving comments and visiting our sponsors.
'Develop' 카테고리의 다른 글
.htaccess 설정파일. (0) | 2008.01.27 |
---|---|
CVS 설정하기 (0) | 2008.01.05 |
How To Install Eclipse 3.3 Manually (0) | 2007.12.19 |
Local directories with Apache on Ubuntu 7.04 (0) | 2007.12.17 |
Set java path (0) | 2007.12.17 |