Introduction to Web Server Setup on FreeBSD Platform

Source: Internet
Author: User

In a FreeBSD system, a standard FreeBSD system requires at least one network interface to communicate with other computers. It supports Token Ring and FDDI, as well as general dialing connections, ISDN, ATM and other WAN connections. This article will discuss the establishment of WEB Services based on the system platform. FreeBSD uses version 4.7.

1. access the Internet

The first step of configuration is to allow FreeBSD to access the Internet and set up proxy services. The local machine uses ADSL to access the Internet in two cases, namely, the dynamic IP obtained by dialing or the static IP provided by the ISP. The following describes how to configure Dynamic IP addresses.

The method is simple. You can directly edit the "/etc/ppp. conf" file and the "/etc/rc. conf" file to access the Internet and support transparent proxy in NAT mode.

Run the following command to enable the configuration of the PPP. conf file:

# Vi/etc/ppp. conf

A simple configuration instance (Note that there must be spaces before set ):

Default:

Set log Phase tun command

Set ifaddr 10.0.0.1/0 10.0.0.2/0

Adsl: # configuration code

Set device PPPoE: vr0 # vr0 change to the name of the network adapter connecting to the ADSL modem

Set mru 1492

Set mtu 1492

Set authname username # username is the dialing User Name

Set authkey password # password is the dial-up password

Set dial

Set login

Add default HISADDR

Run the following command when you open the rc. conf file to implement the Configuration:

# Vi/etc/rc. conf

A simple configuration example:

# -- Sysinstall generated deltas -- # Tue Jul 21:20:28 1997

# Created: Tue Jul 21:20:28 1997

# Enable network daemons for user convenience.

# Please make all changes to this file, not to/etc/defaults/rc. conf.

# This file now contains just the overrides from/etc/defaults/rc. conf.

Hostname = "www.usweb.com" # Your host domain name

Ifconfig_fxp0 = "inet 192.168.0.1 netmask 255.255.255.0" # Intranet Nic IP address, fxp0 is the NIC name

Inetd_enable = "YES" # loading inetd at startup

Kern_securelevel_enable = "NO"

Linux_enable = "YES"

Nfs_reserved_port_only = "NO"

Sendmail_enable = "NO"

Sshd_enable = "YES"

Usbd_enable = "NO"

Gateway_enable = "YES"

Firewall_enable = "YES" # Enable Firewall

Firewall_script = "/etc/rc. firewall"

Firewall_type = "open"

Firewall_quiet = "YES"

Firewall_logging_enable = "YES"

Ppp_enable = "YES" # automatic dialing upon startup

Ppp_mode = "ddial"

Ppp_nat = "YES" # enable transparent proxy

Ppp_profile = "adsl" # configuration code

# -- Sysinstall generated deltas -- # Wed Jul 16 06:52:13 1997

After modifying the personality of the above two files and restarting them, you can dial the Internet and implement transparent proxy. The client must set the DNS address as the DNS address provided by the service provider, and the gateway to the IP address of the internal Nic of the proxy server. In this example, it is "192.168.0.1 ". Clear all check boxes about connection settings in Internet Options of IE. If the domain name cannot be resolved, check whether the DNS server address is correctly configured in the "/etc/resolv. conf" file.

2. Install and set the web Server

To install and set up a Web server, follow these steps:

Step 1: Disable the Squid service and delete the Ipfw transparent proxy port forwarding statement. The command composition is:

# Cd/usr/local/etc/rc. d

#./Squid. sh stop

# Mv squid. sh squid. sh. bak

# Ipfw del 500 fwd 127.0.0.1, 3128 tcp from 192.168.0.0/24 to any 80

Step 2: Install ports. It makes it easy for FreeBSD to install various software. (If the/usr/ports directory already exists, it indicates that it has been installed.) The command format is:

#/Stand/sysinstall

Select "Configure-Distributions-ports" in sequence, and the ports will be installed in the "/usr/ports" directory.

Step 3: Install apache1.3.27 + modssl (you can select the software installation version based on your actual situation, as shown below ). After installation, the system automatically generates the startup script apache. sh in the/usr/local/etc/rc. d directory. You can run apache. sh start | stop to start or stop apache. Command Format:

# Cd/usr/ports/www/apache13-modssl

# Make install # FreeBSD automatically downloads and installs

Step 4: Install mysql3.23. The launch script "/usr/local/etc/rc. d/mysql-server.sh" will be created after completion ". Command Format:

# Cd/usr/ports/database/mysql323-server

# Make install

Step 5: Install the apache module mod_php4. The command format is:

# Cd/usr/ports/www/mod_php4 # FreeBSD automatically downloads and installs

Edit the "configure. php" file under the scripts directory and add OpenSSL support. The command format is:

# Vi scripts/configure. php

Open this file, find this sentence: OpenSSL "OpenSSL support" ON, and then change it to: OpenSSL "OpenSSL support" YES to modify "configure. php, and then edit the apache configuration file.

Add the following content to/usr/local/etc/apache/httpd. conf:

DirectoryIndex index. php index.html # Set the default homepage name.

AddType application/x-httpd-php. php

AddType application/x-httpd-php-source. phps # these two sentences need to be manually added

Step 6: start the test

Restart and log on as the root user, and then execute the command "top" (view the thread command). If the following content is displayed, everything is ready:

PID USERNAME PRI NICE SIZE RES STATE COMMAND

69 root 2 0 440 K 296 K select natd # network address conversion process

132 root 2 0 3692 K 3052 K select httpd # apache process

166 mysql 2 0 27480 K 4824 K poll mysqld # mysql process

Enter http: // 192.168.0.1 in the address bar of the browser. If the apache welcome page is displayed, the web server is successfully installed. The web page files are stored in the/usr/local/www/data directory, you only need to copy your webpage to this directory, and then you can access your home page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.