You are not logged in.

#1 2005-08-14 07:06:45

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

how can I set apache to bu runed as a service(auto run when)

how can I set apache to bu runed as a service(auto run when i boot the server)?
config it in rc.conf?
someone help me

Offline

#2 2005-08-14 07:50:28

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: how can I set apache to bu runed as a service(auto run when)

add something like 'apache' to the daemons line in rc.conf, then create a file called 'apache' in /etc/rc.d and set it up like the ones that are already there...

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
  start)
    stat_busy "Starting Apache"
    add_daemon apache
  # put whatever to start apache here
    stat_done
    ;;
  stop)
    stat_busy "Stopping Apache"
    rm_daemon apache
  # end it here, ex: killall -q /usr/sbin/apache
    stat_done
    ;;
  restart)
    $0 stop
    sleep 2
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
#End of file

Offline

#3 2005-08-14 07:59:24

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

Thanks, I try it now.

Offline

#4 2005-08-14 08:26:17

LB06
Member
From: The Netherlands
Registered: 2003-10-29
Posts: 435

Re: how can I set apache to bu runed as a service(auto run when)

Just add httpd to the deamons array in rc.conf and you're set.

Offline

#5 2005-08-14 08:29:53

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

i first created the file /etc/rc.d/apache like this

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
  start)
    stat_busy "Starting Apache"
    add_daemon apache
  # put whatever to start apache here
    /usr/local/apache2/bin/apachectl start
    stat_done
    ;;
  stop)
    stat_busy "Stopping Apache"
    rm_daemon apache
  # end it here, ex: killall -q /usr/sbin/apache
    /usr/local/apache2/bin/apachectl stop
    stat_done
    ;;
  restart)
    $0 stop
    sleep 2
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
#End of file

and added apache daemon in /etc/rc.conf
but it said permission denied when booting

so I just added one line directly in /etc/rc.conf like this
/usr/local/apache2/bin/apachectl start

it started correctly, but, when booting the system return serval lines like this:
httpd pid xxxx is already running

please tell me why.
looking forward to your reply

Offline

#6 2005-08-14 08:32:10

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

just add httpd to the daemons array - what colnago suggested is unecessary

Offline

#7 2005-08-14 09:12:54

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

just add httpd?
but I dont have a httpd script in the path /etc/rc.d

I added "/usr/local/apache2/bin/apachestl start" into /etc/rc.conf, that led my to a danger way.
When booting it kept showing the message about httpd and never stop.
Then I booted /archCD/isolinux/vmlinuz from grub, and corrected my rc.conf.
wink

Offline

#8 2005-08-14 09:19:24

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

reinstall apache pacman -S apache - did you install with pacman?
Also:

pacman -Ql apache

[snip]
apache /etc/rc.d/
apache /etc/rc.d/httpd
[snip]
pacman -Qo /etc/rc.d/httpd 
/etc/rc.d/httpd is owned by apache 2.0.54-1

So it should be there and I would suggest that figuring out why it is not is the most important thing!

Offline

#9 2005-08-14 09:35:57

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

I installed httpd by compile it myself because I must enable so module.
I will try your way ,thanks

Offline

#10 2005-08-14 09:47:32

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

OK - if you install it yourself you need to get used to using abs to rebuild pkgs using the Arch method.

See http://wiki.archlinux.org/index.php/ABS … ild_System

Especially
http://wiki.archlinux.org/index.php/ABS … _a_package

This will be VERY useful to you!  HTH :mrgreen:

Offline

#11 2005-08-14 12:02:47

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

thanks very much
Though reading english document is not a easy job for me, I'll build a package tonight.

Offline

#12 2005-08-14 12:08:59

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

I think you will find the reading the hardest part, building the pkg will be easy.  Unfortunately we can't make it any easier... or maybe we can...

What exactly did you have to add to your apache build?

Did you have to use a special configure option or maybe some patches?  I think we can make a PKGBUILD for you smile

Offline

#13 2005-08-14 21:11:11

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

I think I can manage it.
I just use --enable-so for the option, I'll simply fill the option in build section.
Do it myself, and I will learn more.
I'll ask for your guys' help if I have any problem doing it.
btw, I find arch linux a very good system, my ab test shows that apache on arch is very efficiency.

Offline

#14 2005-08-14 22:46:53

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

I simply compress the directory httpd-2.0.54 to httpd-2.0.54.tar.php.
And then make a PKGBUILD file as show here below:

# Contributor: fluke <fluke@ospattern.net>
pkgname=httpd
pkgver=2.0.54
pkgrel=1
pkgdesc="a powerful http server"
url="http://www.apache.org"
groups=
provides=
depends=('gcc')
makedepends=('gcc')
#conflicts=('yafoo')
#replaces=('mffoo')
#backup=('/etc/foo/foo.conf')
#install=('foo.install')
source=(./$pkgname-$pkgver.tar.gz)
md5sums=('67e280c06d7fcd8b6c35338c70a289e0')

build() {
  cd $startdir/src/$pkgname-$pkgver
  ./configure --prefix=/usr/local/apache2 --enable-so
  make || return 1
  make prefix=$startdir/pkg/usr install
}

I succeeded in makepkg.
but when I pacman -U httpd.2.0.54.tar.gz, it said "loading package data... load_pkg: missing package info file in httpd-2.0.54.tar.gz".

I just wonder where should I place the pkg info?

Offline

#15 2005-08-14 23:25:36

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

um - i just checked -enable-so is already done in standard arch package - i don't understand the problem now

pacman -S apache
/etc/rc.d/httpd start

should give work apache server

Offline

#16 2005-08-14 23:29:54

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: how can I set apache to bu runed as a service(auto run when)

httpd.2.0.54.tar.gz isn't a package. Arch package ends with .pkg.tar.gz.  Try
pacman -U httpd-2.0.54-1.pkg.tar.gz

Offline

#17 2005-08-15 08:22:35

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

oh, thank you for your suggestion.

I typed ls in the path /var/abs/local, when i found httpd.2.0.54-1.pkg.tar.gz was there.
So I used pacman to install the package, but I find the "--prefix" option followed "./configure" didn't affect the path to install the package.
Then I modified my package to:

# Contributor: fluke <fluke@ospattern.net>
pkgname=httpd
pkgver=2.0.54
pkgrel=1
pkgdesc="a powerful http server"
url="http://www.apache.org"
groups=
provides=
depends=('gcc')
makedepends=('gcc')
#conflicts=('yafoo')
#replaces=('mffoo')
#backup=('/etc/foo/foo.conf')
#install=('foo.install')
source=(./$pkgname-$pkgver.tar.gz)
md5sums=('67e280c06d7fcd8b6c35338c70a289e0')

build() {
  cd $startdir/src/$pkgname-$pkgver
  ./configure --enable-so
  make || return 1
  make prefix=$startdir/pkg/usr/local/apache2 install  #*specify my prefix here*
} 

Then it worked.
There is a question.
How can I specify my install path(--prefix=) using pacman?
You know, not everyone wants to modify his PKGBUILD and build a package himself.

Offline

#18 2005-08-15 08:43:58

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

fluke wrote:

You know, not everyone wants to modify his PKGBUILD and build a package himself.

It is the easiest way in Arch.  If you do not wish to maintain your system correctly with pacman then why are you using Arch?  If you want script to start and stop apache easily then use the original pkg.  No one is forcing you to.  You asked for our help - we told you the easiest way to do it.

I still fail to see the original problem.  From what you have said the standard Arch pkg should have worked perfectly for you.  I was going to tell you exactly how to build the pkg you wanted but when I saw the standard PKGBUILD I realized that it already had the feature your required.

So, what are we supposed to do?  roll

Offline

#19 2005-08-15 09:21:19

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

I choose arch because its optimized for i686 system, and, pacman can help me install common packages for the official and many other repos servers.
And why not fedora? I think I don't like rpms, they might not fix my i686 system.

But for special softwares like apache,php,tomcat.. I'd like to compile them my self. It's just one of  my habits  tongue
In my mind, only when I am to install some packages form the net I will use pacman but when I have local source files and I will compile them myself.
Are there any different things between use pacman to install a package and compile it myself?:?:
Maybe I could not yet understand the whole meaning of the pacman system.

Please don't mind about my inconsecute English. I'm trying my best to learn it. wink
I can learn more deep anout linux from arch linux. This is the best thing I gain these days using arch. And you've told me much. smile

Offline

#20 2005-08-15 09:24:19

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

And I still don't know if I can specify a install dir when I use pacman to install a package for the offcial package server .

Offline

#21 2005-08-15 09:39:47

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

You can build source and install it using pacman and makepkg.  You should never need to build and install source "manually", you might want to and that is ok smile

The PKGBUILD you have created above is really not much use - this is the original PKGBUILD

# $Id: PKGBUILD,v 1.57 2005/04/16 18:37:54 judd Exp $
# Maintainer: judd <jvinet@zeroflux.org>
pkgname=apache                         
pkgver=2.0.54
pkgrel=1
pkgdesc="A high performance Unix-based HTTP server (with SSL)"
backup=(etc/httpd/conf/httpd.conf home/httpd/html/index.html 
        etc/conf.d/httpd etc/httpd/conf/ssl.conf)
depends=('glibc' 'gdbm' 'db' 'openssl' 'expat')
provides=('apr' 'apr-util')
conflicts=('apr' 'apr-util')
source=(http://www.apache.org/dist/httpd/httpd-$pkgver.tar.gz 
        httpd index.html mod_ssl.txt httpd.logrotate httpd.conf.d 
        httpd.conf ssl.conf)           
md5sums=('772503748ffb85301385d47fb2b96eca' '077b2d9dcb7914600f5b1a3de1dec8f7'
         '64206bf5da4daf4b962186ded0a3d20a' '2e68c9508d21e98c4503dcb159d22890'
         'a13925eef67108cf22f6bd1b2b8decb1' '62dba8077401cb5515ecb79fe29c2a52'
         '8747daec5196bdb6221f7dc334504f90' '7adfc868a67f9b16d63a9f3b074f3efa')
                                       
build() {                              
  cd $startdir/src/httpd-$pkgver       
  # fix the suexec user
  sed -i 's|^#define AP_HTTPD_USER.*$|#define AP_HTTPD_USER "nobody"|' 
    support/suexec.h
  ./configure --prefix=/usr --enable-layout=RedHat --datadir=/home/httpd 
    --enable-modules=all --enable-mods-shared=all --enable-ssl --enable-so 
    --enable-proxy --enable-proxy-connect --enable-proxy-ftp 
    --enable-proxy-http --enable-suexec
  make || return 1                     
  make DESTDIR=$startdir/pkg install   
  rm -f $startdir/pkg/usr/include/fnmatch.h
  rm -rf $startdir/pkg/home/httpd/html/* $startdir/pkg/home/httpd/manual
  install -D -m755 ../httpd $startdir/pkg/etc/rc.d/httpd
  install -D -m644 ../httpd.logrotate $startdir/pkg/etc/logrotate.d/httpd
  install -D -m644 ../index.html $startdir/pkg/home/httpd/html/index.html
  install -D -m644 ../mod_ssl.txt $startdir/pkg/etc/httpd/conf/mod_ssl.txt
  install -D -m644 ../httpd.conf.d $startdir/pkg/etc/conf.d/httpd
  install -D -m644 ../httpd.conf $startdir/pkg/etc/httpd/conf/httpd.conf
  install -D -m644 ../ssl.conf $startdir/pkg/etc/httpd/conf/ssl.conf
  # move suexec to the right place
  mv $startdir/pkg/usr/sbin/suexec $startdir/pkg/usr/bin/suexec
}

As you can see it is very different from yours.

My question is: why does the regualr Arch pkgs not work for you?

There is no way for me to tell you how to fix it if I don't know what is wrong!

Offline

#22 2005-08-15 11:28:39

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

Hey, you teach me so much again!
Now I understand how convenient and reliable to install package in this method.

My question is: why does the regualr Arch pkgs not work for you?

I haven't tried the regular pkg of apache because I want more flexibility. I used to use fedora, and I don't much like its yum install.
Now, as I see the PKGBUILD file myself, I believe its very professional and reliable.

There is no way for me to tell you how to fix it if I don't know what is wrong!

The problem is lack of this :install -D -m644 ../httpd.conf.d $startdir/pkg/etc/conf.d/httpd
I fixed the problem. I wrote a script to start http in daemon.

----------
I find there many beautiful pictures in your website.
Are they on fluxbox wm?
There is another problem.
I can't install other wms correctly.
I just use pacman to install them. like
pacman -S fluxbok
when I start them , return an err msg like this:
cannot open display
That is, I can only run xfce4.
these are my kde error messages:

xsetroot: unable to open display ''
xset: unable to open display ""
xset: unable to open display ""
xset: unable to open display ""
xsetroot: unable to open display ''
startkde: starting up...
startkde: Running kpersonalizer
kwin: cannot connect to C server
kpersonalizer:cannot connect to X server
kpersonalizer:cannot connect to X server
kpersonalizer:cannot connect to X server
kpersonalizer:cannot connect to X server
kpersonalizer:cannot connect to X server
...

Offline

#23 2005-08-15 11:36:35

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

fluke wrote:

Hey, you teach me so much again!
Now I understand how convenient and reliable to install package in this method.

My question is: why does the regualr Arch pkgs not work for you?

I haven't tried the regular pkg of apache because I want more flexibility. I used to use fedora, and I don't much like its yum install.
Now, as I see the PKGBUILD file myself, I believe its very professional and reliable.

There is no way for me to tell you how to fix it if I don't know what is wrong!

The problem is lack of this :install -D -m644 ../httpd.conf.d $startdir/pkg/etc/conf.d/httpd
I fixed the problem. I wrote a script to start http in daemon.

If you check out the abs (Arch Build System) tree you can find all of the necessary files for building standard.  First you need to get some tools:

$ pacman -Sy cvsup wget

the run abs simply by

$ abs

When that is done take a look in /var/abs/daemons/apache

Offline

#24 2005-08-15 19:27:09

fluke
Member
From: Shaoguan Univ., PRC
Registered: 2005-08-12
Posts: 241
Website

Re: how can I set apache to bu runed as a service(auto run when)

I get it now.

and, i know arch team now is developing a rewind(return to the status before install a package, I don't know if I use the word rewind is correct, because I saw this news in a chinese site, I don't have the news in English) feature for pacman, I want to know more about it.

Offline

#25 2005-08-15 19:32:08

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: how can I set apache to bu runed as a service(auto run when)

Hmmm, rewind is ok but "rollback" is the commonly used term.  Some of the GUI pacman frontends such as Jacman already feature rollback functions - I am not aware of plans for integration into the offical version

Offline

Board footer

Powered by FluxBB