Last active
December 28, 2015 20:29
-
-
Save a-yasui/7557382 to your computer and use it in GitHub Desktop.
MAMP.cwd の brew apache2 バージョン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /usr/local/Cellar/etc/apache2/httpd.conf | |
ServerRoot "/usr/local/Cellar/httpd/2.2.25" | |
Listen 8888 | |
LoadModule authn_file_module libexec/mod_authn_file.so | |
LoadModule authn_dbm_module libexec/mod_authn_dbm.so | |
LoadModule authn_anon_module libexec/mod_authn_anon.so | |
LoadModule authn_dbd_module libexec/mod_authn_dbd.so | |
LoadModule authn_default_module libexec/mod_authn_default.so | |
LoadModule authz_host_module libexec/mod_authz_host.so | |
LoadModule authz_groupfile_module libexec/mod_authz_groupfile.so | |
LoadModule authz_user_module libexec/mod_authz_user.so | |
LoadModule authz_dbm_module libexec/mod_authz_dbm.so | |
LoadModule authz_owner_module libexec/mod_authz_owner.so | |
LoadModule authz_default_module libexec/mod_authz_default.so | |
LoadModule auth_basic_module libexec/mod_auth_basic.so | |
LoadModule auth_digest_module libexec/mod_auth_digest.so | |
LoadModule cache_module libexec/mod_cache.so | |
LoadModule dbd_module libexec/mod_dbd.so | |
LoadModule dumpio_module libexec/mod_dumpio.so | |
LoadModule reqtimeout_module libexec/mod_reqtimeout.so | |
LoadModule ext_filter_module libexec/mod_ext_filter.so | |
LoadModule include_module libexec/mod_include.so | |
LoadModule filter_module libexec/mod_filter.so | |
LoadModule substitute_module libexec/mod_substitute.so | |
LoadModule deflate_module libexec/mod_deflate.so | |
LoadModule log_config_module libexec/mod_log_config.so | |
LoadModule log_forensic_module libexec/mod_log_forensic.so | |
LoadModule logio_module libexec/mod_logio.so | |
LoadModule env_module libexec/mod_env.so | |
LoadModule mime_magic_module libexec/mod_mime_magic.so | |
LoadModule cern_meta_module libexec/mod_cern_meta.so | |
LoadModule expires_module libexec/mod_expires.so | |
LoadModule headers_module libexec/mod_headers.so | |
LoadModule ident_module libexec/mod_ident.so | |
LoadModule usertrack_module libexec/mod_usertrack.so | |
LoadModule setenvif_module libexec/mod_setenvif.so | |
LoadModule version_module libexec/mod_version.so | |
LoadModule proxy_module libexec/mod_proxy.so | |
LoadModule proxy_connect_module libexec/mod_proxy_connect.so | |
LoadModule proxy_ftp_module libexec/mod_proxy_ftp.so | |
LoadModule proxy_http_module libexec/mod_proxy_http.so | |
LoadModule proxy_scgi_module libexec/mod_proxy_scgi.so | |
LoadModule proxy_ajp_module libexec/mod_proxy_ajp.so | |
LoadModule proxy_balancer_module libexec/mod_proxy_balancer.so | |
LoadModule ssl_module libexec/mod_ssl.so | |
LoadModule mime_module libexec/mod_mime.so | |
LoadModule dav_module libexec/mod_dav.so | |
LoadModule status_module libexec/mod_status.so | |
LoadModule autoindex_module libexec/mod_autoindex.so | |
LoadModule asis_module libexec/mod_asis.so | |
LoadModule info_module libexec/mod_info.so | |
LoadModule suexec_module libexec/mod_suexec.so | |
LoadModule cgi_module libexec/mod_cgi.so | |
LoadModule cgid_module libexec/mod_cgid.so | |
LoadModule dav_fs_module libexec/mod_dav_fs.so | |
LoadModule vhost_alias_module libexec/mod_vhost_alias.so | |
LoadModule negotiation_module libexec/mod_negotiation.so | |
LoadModule dir_module libexec/mod_dir.so | |
LoadModule imagemap_module libexec/mod_imagemap.so | |
LoadModule actions_module libexec/mod_actions.so | |
LoadModule speling_module libexec/mod_speling.so | |
LoadModule userdir_module libexec/mod_userdir.so | |
LoadModule alias_module libexec/mod_alias.so | |
LoadModule rewrite_module libexec/mod_rewrite.so | |
<IfModule !mpm_netware_module> | |
<IfModule !mpm_winnt_module> | |
User yasui | |
Group staff | |
</IfModule> | |
</IfModule> | |
ServerAdmin yourmail@example.com | |
DocumentRoot "/usr/local/Cellar/httpd/2.2.25/share/apache2/htdocs" | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride None | |
Order deny,allow | |
Deny from all | |
</Directory> | |
<IfModule dir_module> | |
DirectoryIndex index.html index.php | |
</IfModule> | |
<FilesMatch "^\.ht"> | |
Order allow,deny | |
Deny from all | |
Satisfy All | |
</FilesMatch> | |
ErrorLog "/usr/local/var/apache2/log/error_log" | |
LogLevel warn | |
<IfModule log_config_module> | |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined | |
LogFormat "%h %l %u %t \"%r\" %>s %b" common | |
<IfModule logio_module> | |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio | |
</IfModule> | |
CustomLog "/usr/local/var/apache2/log/access_log" combined | |
</IfModule> | |
DefaultType text/plain | |
<IfModule mime_module> | |
TypesConfig /usr/local/etc/apache2/mime.types | |
AddType application/x-compress .Z | |
AddType application/x-gzip .gz .tgz | |
</IfModule> | |
<IfModule ssl_module> | |
SSLRandomSeed startup builtin | |
SSLRandomSeed connect builtin | |
</IfModule> | |
# Otherwise Configuration Load | |
Include /usr/local/etc/apache2/extra/*.conf | |
Include /usr/local/etc/apache2/Virtual/*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /usr/local/etc/apache2/Virtual/template.conf.back | |
<VirtualHost *:8888> | |
DocumentRoot {{ROOT}} | |
<Directory {{ROOT}}> | |
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch | |
AllowOverride All | |
order allow,deny | |
Allow from all | |
AddHandler cgi-script cgi | |
AddHandler application/x-httpd-php .php | |
AddType application/x-httpd-php .php | |
</Directory> | |
</VirtualHost> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# -*- coding: utf8 -*- | |
# | |
# webapp | |
# | |
# Brew Apache2 のサブコマンドとして、作業ディレクトリを公開ディレクトリにする | |
# | |
PATH="/bin:/sbin:/usr/bin:/usr/sbin" | |
cwd=`pwd` | |
CONF='/usr/local/etc/apache2/Virtual' | |
EXT='/usr/local/etc/apache2/extra' | |
TMPL="$CONF/template.conf.back" | |
HOST="$CONF/host.conf" | |
APACHECTL="/usr/local/sbin/apachectl" | |
if [ ! -e $CONF ]; then | |
echo "Not Found Apache. Please install: brew install apache2" | |
exit 1 | |
fi | |
if [ ! -f $TMPL ]; then | |
echo "Not Found Template file. Please install Tempate file for $TMPL" | |
echo " From https://gist.github.com/a-yasui/232783de4e6c76851261" | |
exit 1 | |
fi | |
if [ ! -d /usr/local/Cellar/php55 ]; then | |
echo "[WARN] Your not install PHP55" | |
echo "[WARN] Please install php55 using brew!!" | |
fi | |
if [ ! -d /usr/local/Cellar/php53 ]; then | |
echo "[WARN] Your not install PHP53" | |
echo "[WARN] Please install php53 using brew!!" | |
fi | |
############################################ | |
# Update the host file. | |
function update () { | |
/bin/echo -n "Changing Current Directory: " | |
echo "\033[1;35m $cwd \033[0m" | |
sed -e s#{{ROOT}}#$cwd#g $TMPL > $HOST | |
} | |
############################################ | |
# Stop Apache | |
function stop_apache () { | |
/bin/echo -n 'stopping...' | |
log=`$APACHECTL stop 2>&1` | |
if [ $? -eq 0 ]; then | |
echo "\033[32m OK \033[0m" | |
echo "Apache say:\033[1;31m $log \033[0m " | |
sleep 2 | |
else | |
echo "\033[31m NG \033[0m" | |
fi | |
} | |
############################################ | |
# Start Apache | |
function start_apache () { | |
/bin/echo -n 'starting...' | |
configtest=`$APACHECTL configtest 2>&1` | |
if [ $? -eq 0 ]; then | |
log=`$APACHECTL start 2>&1` | |
if [ $? -eq 0 ]; then | |
echo "\033[32m OK \033[0m" | |
echo "Apache say:\033[1;31m $log \033[0m " | |
else | |
echo "\033[31m NG \033[0m" | |
fi | |
else | |
echo $configtest | |
fi | |
} | |
############################################ | |
# Display the DocumentRoot Path. | |
function check_document () { | |
/bin/echo -n "DocumentRoot: " | |
awk '/DocumentRoot (.+)/{print $2}' $HOST; | |
} | |
############################################ | |
# Change PHP Version | |
function change_php () { | |
libpath=`find /usr/local -name 'libphp5.so' | grep $1` | |
if [ "X${libpath}" = "X" ]; then | |
echo "Not Found $1"; | |
else | |
echo "LoadModule php5_module ${libpath}" > $EXT/php.conf | |
fi | |
} | |
############################################ | |
# Usage | |
function usage () { | |
echo "$0 {start|stop|cwd|check|help}" | |
echo "" | |
echo " This command is changing documentRoot Directory script for apache." | |
echo " If you don't install apache using brew, Please do it \`brew install apache\`" | |
echo "" | |
echo " Options" | |
echo " start: this try Starting apache" | |
echo " stop : this try Stopping apache" | |
echo " check: this show the DocumentRoot Path Now" | |
echo " cwd : Changing the DocumentRoot at your current Directory." | |
echo " help : show this." | |
echo " change55: Changing PHP55." | |
echo " change54: Changing PHP55." | |
echo " change53: Changing PHP53." | |
} | |
for arg in $*; do | |
case $arg in | |
start) | |
stop_apache | |
start_apache | |
;; | |
stop) | |
stop_apache | |
;; | |
cwd) | |
stop_apache | |
update | |
start_apache | |
;; | |
check) | |
check_document | |
;; | |
change55) | |
change_php php55 | |
stop_apache | |
start_apache | |
;; | |
change54) | |
change_php php54 | |
stop_apache | |
start_apache | |
;; | |
change53) | |
change_php php53 | |
stop_apache | |
start_apache | |
;; | |
open) | |
open http://localhost.degg.biz:8888/ | |
;; | |
help) | |
usage | |
;; | |
esac | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment