FreeBSD - установка программ из портов


Авторandreyv

Возникла как-то ситуация. И с целью избежать дополнительных вопросов, в качестве примера, ставим наиболее популярный Apache на FreeBSD из портов Многие вещи великие ГУРУ (не только FreeBSD-шные) понимают как само собой разумеется. Для новичков - каждая команда - загадка, каждое действие - магическое набивание букавок. Приведу пример, когда гуру достаточно просто убивает проблему руками нубика через аську :) может быть кому-то поможет в жизни

newbee
поставил апач 22 из портов
он говорит что установился
но поиск дает вот такое
tools# whereis apache22
apache22: /usr/ports/www/apache22

как его запустить ?
мне просто надо запустить апач :)

guru
cd /usr/local/etc/rc.d

guru
ll

guru
дай мне вывод последней команды

newbee
команды чего?

guru
cd /usr/local/etc/rc.d
ll (LL только маленькими буквами, листинг директории смотреть хочу)

newbee
протупил :)
tools# ll
total 16
-r-xr-xr-x 1 root wheel 4744 Aug 27 07:45 apache22
-r-xr-xr-x 1 root wheel 833 Oct 28 2006 avahi-daemon.sh
-r-xr-xr-x 1 root wheel 1072 Oct 28 2006 avahi-dnsconfd.sh
-r-xr-xr-x 1 root wheel 622 Oct 28 2006 dbus
-r-xr-xr-x 1 root wheel 1184 Oct 15 2006 exim.sh
-r-xr-xr-x 1 root wheel 1046 Oct 15 2006 postfix

guru
cat apache22

newbee
большой скрипт показало

guru
пуляй сюды :-)

newbee
tools# cat apache22
#!/bin/sh
#
# $FreeBSD: ports/www/apache22/files/apache22.sh.in,v 1.1 2006/09/24 16:16:40 clement Exp $
#

# PROVIDE: apache22
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable apache22:
# apache22_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable apache22
# apache22_profiles (str): Set to "" by default.
# Define your profiles here.
# apache22limits_enable (bool):Set to "NO" by default.
# Set it to yes to run `limits $limits_args`
# just before apache starts.
# apache22_flags (str): Set to "" by default.
# Extra flags passed to start command.
# apache22limits_args (str): Default to "-e -C daemon"
# Arguments of pre-start limits run.
# apache22_http_accept_enable (bool): Set to "NO" by default.
# Set to yes to check for accf_http kernel
# module on start up and load if not loaded.
. /etc/rc.subr

name="apache22"
rcvar=`set_rcvar`

start_precmd="apache22_precmd"
restart_precmd="apache22_checkconfig"
reload_precmd="apache22_checkconfig"
reload_cmd="apache22_graceful"
graceful_cmd="apache22_graceful"
gracefulstop_cmd="apache22_gracefulstop"
configtest_cmd="apache22_checkconfig"
command="/usr/local/sbin/httpd"
_pidprefix="/var/run/httpd"
pidfile="${_pidprefix}.pid"
required_files=/usr/local/etc/apache22/httpd.conf

[ -z "$apache22_enable" ] && apache22_enable="NO"
[ -z "$apache22_profiles" ] && apache22_profiles=""
[ -z "$apache22_flags" ] && apache22_flags=""
[ -z "$apache22limits_enable" ] && apache22limits_enable="NO"
[ -z "$apache22limits_args" ] && apache22limits_args="-e -C daemon"
[ -z "$apache22_http_accept_enable" ] && apache22_http_accept_enable="NO"

apache22_accf() {
retcode=0
if checkyesno apache22_http_accept_enable
then
/sbin/kldstat -v | grep accf_http 2>&1 > /dev/null
retcode=${?}
if [ ${retcode} -ne 0 ]
then
/sbin/kldload accf_http 2> /dev/null
retcode=${?}
fi
else
apache22_flags="${apache22_flags} -DNOHTTPACCEPT"
fi
[ ${retcode} -ne 0 ] && echo "Unable to load accf_http module"
return ${retcode}
}

load_rc_config $name

if [ -n "$2" ]; then
profile="$2"
if [ "x${apache22_profiles}" != "x" ]; then
pidfile="${_pidprefix}.${profile}.pid"
eval apache22_configfile="${apache22_${profile}_configfile:-}"
if [ "x${apache22_configfile}" = "x" ]; then
echo "You must define a configuration file (apache22_${profile}_configfile)"
exit 1
fi
required_files="${apache22_configfile}"
eval apache22_enable="${apache22_${profile}_enable:-${apache22_enable}}"
eval apache22_flags="${apache22_${profile}_flags:-${apache22_flags}}"
eval apache22_http_accept_enable="${apache22_${profile}_http_accept_enable:-${apache22_http_accept_enable}}"
eval apache22limits_enable="${apache22limits_${profile}_enable:-${apache22limits_enable}}"
eval apache22limits_args="${apache22limits_${profile}_args:-${apache22limits_args}}"
apache22_flags="-f ${apache22_configfile} -c "PidFile ${pidfile}" ${apache22_flags}"
else
echo "$0: extra argument ignored"
fi
else
if [ "x${apache22_profiles}" != "x" -a "x$1" != "x" ]; then
if [ "x$1" != "xrestart" ]; then
for profile in ${apache22_profiles}; do
echo "===> apache22 profile: ${profile}"
/usr/local/etc/rc.d/apache22.sh $1 ${profile}
retcode="$?"
if [ "0${retcode}" -ne 0 ]; then
failed="${profile} (${retcode}) ${failed:-}"
else
success="${profile} ${success:-}"
fi
done
exit 0
else
restart_precmd=""
fi
fi
fi

if [ "${1}" != "stop" ] ; then
apache22_accf || apache22_flags="${apache22_flags} -DNOHTTPACCEPT"
fi

apache22_requirepidfile()
{
if [ ! "0`check_pidfile ${pidfile} ${command}`" -gt 1 ]; then
echo "${name} not running? (check $pidfile)."
exit 1
fi
}

apache22_checkconfig()
{
echo "Performing sanity check on apache22 configuration:"
eval ${command} ${apache22_flags} -t
}

apache22_graceful() {
apache22_requirepidfile

echo "Performing a graceful restart"
eval ${command} ${apache22_flags} -k graceful
}

apache22_gracefulstop() {
apache22_requirepidfile

echo "Performing a graceful stop"
eval ${command} ${apache22_flags} -k graceful-stop
}

apache22_precmd()
{
apache22_checkconfig

if test -f /usr/local/sbin/envvars
then
. /usr/local/sbin/envvars
fi

if checkyesno apache22limits_enable
then
eval `/usr/bin/limits ${apache22limits_args}` 2>/dev/null
else
return 0
fi

}

extra_commands="reload graceful gracefulstop configtest"
run_rc_command "$1"

guru
для запуска апача в /etc/rc.conf допиши apache22_enable="YES"
и сделай /usr/local/etc/rc.d/apache22 start для запуска

newbee
*DRINK* как все просто :)

guru
если конфиг апача рабочий - должно стартонуть

newbee
tools# //usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
httpd: apr_sockaddr_info_get() failed for tools.voliacable.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
Starting apache22.
httpd: apr_sockaddr_info_get() failed for tools.voliacable.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

guru
в конфиге пропиши ченить в ServerName
...но вообще сам апач помоему и так стартонул,
проверь в процесах есть оно или нет

newbee
нету

guru
.... да, и на всяк случай -
пользуй /usr/local/etc/rc.d/apache22 restart
для перезапуска

guru
поправь конфиг, ServerName

guru
и пробуй еще разок стартонуть

newbee
tools# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
tools#
в процессах не вижу на 80м порту никого нету

guru
пжди, причем тут процессы и 80й порт

newbee
попытался эксплорером посмотреть на хост - пусто

guru
ps -auxww |grep http

newbee
tools# ps -auxww|grep http
root 60642 0.0 0.0 372 252 p0 R+ 8:58AM 0:00.00 grep http

guru
наверно нет :-(
netstat -an |grep LISTEN

newbee

tools# netstat -an|grep LISTEN
tcp4 0 0 127.0.0.1.25 *.* LISTEN
tcp4 0 0 *.22 *.* LISTEN
tcp6 0 0 *.22 *.* LISTEN

newbee
tools# /usr/local/etc/rc.d/apache22 status
apache22 is not running.

guru
дохло
давай логи читать /var/log/httpd-error.log

guru
помоему есть догадки

newbee
tools# cat httpd-error.log
[Tue Aug 28 08:50:48 2007] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Aug 28 08:50:48 2007] [alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "xxx.xxx.com"
Configuration Failed
[Tue Aug 28 08:55:23 2007] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Aug 28 08:55:23 2007] [alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "xxx.xxx.com"
Configuration Failed
[Tue Aug 28 08:56:47 2007] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Aug 28 08:56:47 2007] [alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "xxx.xxx.com"
Configuration Failed

guru
дай мне свой /etc/hosts

newbee
tools# cat /etc/hosts
# $FreeBSD: src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file. Replace 'my.domain' below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1 localhost localhost.my.domain
127.0.0.1 localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2 myname.my.domain myname
#10.0.0.3 myfriend.my.domain myfriend
#
# According to RFC 1918, you can use the following IP networks for
# private nets which will never be connected to the Internet:
#
# 10.0.0.0 - 10.255.255.255
# 172.16.0.0 - 172.31.255.255
# 192.168.0.0 - 192.168.255.255
#
# In case you want to be able to connect to the Internet, you need
# real official assigned numbers. Do not try to invent your own network
# numbers but instead get one from your network provider (if any) or
# from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or AfriNIC.)

guru
127.0.0.1 localhost localhost.my.domain
замени на
127.0.0.1 localhost xxx.xxx.com

newbee
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
60702 root 1 8 0 6416K 4864K nanslp 0:01 16.02% httpd
*DRINK*

newbee
It works![:-}

http://allwork.kiev.ua

Обновлено: 12.03.2015