Start an apache server in any directory from command line

后端 未结 7 1340
故里飘歌
故里飘歌 2020-12-25 12:26

I want to be able to start an apache server from the command line, typing something like apache site-folder or apache . --port=2000

This sh

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-25 13:10

    Hope you find your solution. I hate .htaccess. So I wrote this:

    #!/bin/bash
    cat >._apache2_dir_conf << EOF
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf
    ErrorLog $1/._apache2_dir_error.log
    HostnameLookups Off
    NameVirtualHost *:$2
    ServerName joyeruc
    Listen $2
    PidFile $1/._apache2_pid
    
        ServerAdmin joyer@uc
        DocumentRoot $1
        
            Options FollowSymLinks
            AllowOverride None
        
        
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
        
        ErrorLog $1/._apache2_dir_error.log
        LogLevel warn
    
    
    EOF
    
    #apache2 -k $3 -X -f $1/._apache2_dir_conf
    apache2 -X -f $1/._apache2_dir_conf
    

提交回复
热议问题