Admin Apachectl

WWWグループにユーザー(自分)を追加する


#!/bin/bash -e
#com.cocolog-nifty.quicktimer.icefloe
#################################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行ユーザー(whoami): $USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
/bin/echo "このスクリプトを実行するには管理者権限が必要です。"
/bin/echo "sudo で実行してください"
  ### path to me
SCRIPT_PATH="${BASH_SOURCE[0]}"
/bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
/bin/echo "↑を実行してください"
  ###実行しているユーザー名
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
exit 1
else
  ###実行しているユーザー名
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
  ###実行しているユーザー名
HOME_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
/bin/echo "実行ユーザー(HOME): $HOME_USER"
  ###logname
LOGIN_NAME=$(/usr/bin/logname)
/bin/echo "ログイン名(logname): $LOGIN_NAME"
  ###UID
USER_NAME=$(/usr/bin/id -un)
/bin/echo "ユーザー名(id): $USER_NAME"
  ###STAT
STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
/bin/echo "STAT_USR(console): $STAT_USR"
fi

#######
#ローカルアカウントを調べる
STR_LOCALUSER=$(/usr/bin/dscl . list /Users | grep -v '^_' | grep -v 'admin' | grep -v 'daemon' | grep -v 'nobody' | grep -v 'root')
/bin/echo "ローカルユーザーリスト:" "$STR_LOCALUSER"
####WWWグループにユーザーを追加
STR_GROUPS_USER=$(/usr/bin/dscl . read /Groups/_www GroupMembership)
if [[ $STR_GROUPS_USER == *"$CONSOLE_USER"* ]]; then
echo "GroupMembershipに $CONSOLE_USER はすでに含まれています"
else
echo "GroupMembershipに $CONSOLE_USER は含まれていません"
/usr/bin/sudo /usr/bin/dscl . append /Groups/_www GroupMembership "$CONSOLE_USER"
STR_USER_UUID=$(/usr/bin/dscl . -read "$HOME" GeneratedUID | awk 'NF > 1 {print $NF}')
/usr/bin/sudo /usr/bin/dscl . append /Groups/_www GroupMembers "$STR_USER_UUID"
/usr/bin/dscl . read /Groups/_www GroupMembership
/usr/bin/dscl . read /Groups/_www GroupMembers
fi


exit 0


|

[macOS14]apache2ローカル 少し修正

ダウンロード - apachectl.zip


macOS14のユーザールートアクセス権750に対応
ーー>755に変更することで Sitesフォルダにアクセスできます

詰め合わせ
07-設定変更 Indexes.applescript
06-apachectlログ削除.applescript
05-アクセス権.applescript
04-apachectl再読込.applescript
03-apachectl再起動.applescript
02-apachectlストップ.applescript
01-apachectlスタート.applescript


Screen_326x187_001

|

[macOS14]apache2ローカル

ダウンロード - apachectl4os14.zip


基本的には
[Macos13]apache2ローカル
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-44151c.html
から変更はない
『with administrator privileges』を削除して
macOS14でもタッチIDを使えるようにした
[AppleScript] do shell scriptでTouchIDを使う(macOS14対応)
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-749bb4.html
[macos14]タッチIDを有効にする
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-b3346a.html

|

[Macos13]apache2ローカル

【1】apachectlスタート
【2】apachectlストップ
【3】apachectl 再起動
【4】apachectl 設定再読み込みして起動
【5】apachectl ディレクトリ関係 基本のアクセス権
【6】apachectl ログ削除
【7】apachectl 基本設定(ユーザーディレクトリ)


ダウンロード - apachectl2.zip



【1】apachectlスタート
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-39c5a5.html
【2】apachectlストップ
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-96dbff.html
【3】apachectl 再起動
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-ff86c5.html
【4】apachectl 設定再読み込みして起動
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-c4f41f.html
【5】apachectl ディレクトリ関係 基本のアクセス権
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-e9d8fd.html
【6】apachectl ログ削除
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-16d4b4.html
【7】apachectl 基本設定(ユーザーディレクトリ)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-b2fa5e.html

|

【7】apachectl 基本設定(ユーザーディレクトリ)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application

####WebServerディレクトリアクセス権
set strCommandText to "/usr/bin/sudo /bin/chmod 777 \"/Library/WebServer/Documents\""
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/chgrp www \"/Library/WebServer/Documents\""
do shell script strCommandText with administrator privileges
### Indexes MultiViews用にindexをリネーム
try
  set strCommandText to "/usr/bin/sudo /bin/mv -f \"/Library/WebServer/Documents/index.html.en\" \"/Library/WebServer/Documents/index.backup.html.en\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /bin/rm -f \"/Library/WebServer/Documents/index.html.en\""
  do shell script strCommandText with administrator privileges
end try
####共有サイトフォルダ作成
set strCommandText to "/usr/bin/sudo /bin/mkdir -p /Users/Shared/Sites"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod -Rf 755 /Users/Shared/Sites"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/chgrp -Rf www /Users/Shared/Sites"
do shell script strCommandText with administrator privileges

set strCommandText to "[[ -e \"/Library/WebServer/Documents/Shared\" ]] && /bin/echo true || /bin/echo false "
set boolFileExist to (do shell script strCommandText) as boolean
if boolFileExist is false then
  set strCommandText to "/usr/bin/sudo /bin/ln -s \"/Users/Shared/Sites\" \"/Library/WebServer/Documents/Shared\""
  do shell script strCommandText with administrator privileges
end if
########ローカルユーザー名取得
set strCommandText to "/usr/bin/dscl . list /Users | grep -v '^_' | grep -v 'admin' | grep -v 'daemon' | grep -v 'nobody' | grep -v 'root'"
set strCommandText to "/usr/bin/dscl . list /Users | grep -v '^_' | grep -v 'daemon' | grep -v 'nobody' | grep -v 'root'"
set strLocalUser to do shell script strCommandText
set AppleScript's text item delimiters to "\r"
set listLocalUser to every text item of strLocalUser
set AppleScript's text item delimiters to ""
########ユーザーサイトフォルダ作成
repeat with itemLocalUser in listLocalUser
  set strLocalUser to itemLocalUser as text
  set strCommandText to "/usr/bin/sudo /bin/mkdir -p \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/bin/touch \"/Users/" & strLocalUser & "/Sites/.localized\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/sbin/chown -Rf " & strLocalUser & " \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/bin/chgrp -Rf www \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /bin/chmod 755 \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  
  set strCommandText to "[[ -e \"/Library/WebServer/Documents/" & strLocalUser & "\" ]] && /bin/echo true || /bin/echo false "
  set boolFileExist to (do shell script strCommandText) as boolean
  if boolFileExist is false then
  set strCommandText to "/usr/bin/sudo /bin/ln -s \"/Users/" & strLocalUser & "/Sites\" \"/Library/WebServer/Documents/" & strLocalUser & "\""
  do shell script strCommandText with administrator privileges
  end if
end repeat


####ログファイル
set strCommandText to "/usr/bin/sudo /bin/mkdir -p /private/var/log/apache2"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/error_log"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/access_log"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/combined_log"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/sbin/chown -Rf www /private/var/log/apache2"
do shell script strCommandText with administrator privileges

###アパッチ停止
set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl stop"
do shell script strCommandText with administrator privileges
try
  set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl stop -w /System/Library/LaunchDaemons/org.apache.httpd.plist"
  do shell script strCommandText with administrator privileges
end try
try
  set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist"
  do shell script strCommandText with administrator privileges
end try

###設定変更の値を保存できるように一時的なアクセス権
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2/httpd.conf"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2/extra"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2/extra/httpd-userdir.conf"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2/users"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 777 /private/etc/apache2/users/*conf"
do shell script strCommandText with administrator privileges



#############################
##設定変更
#############################
####読み込むファイル
set ocidFilePath to refMe's NSString's stringWithString:"/private/etc/apache2/httpd.conf"
###ファイルの内容を読み込む
set listReadFile to refMe's NSString's stringWithContentsOfFile:ocidFilePath encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)

set ocidReadFile to item 1 of listReadFile

###可変テキスト(置き換えするため)
set ocidMutableString to refMe's NSMutableString's stringWithCapacity:0
ocidMutableString's setString:ocidReadFile


#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("Options FollowSymLinks Multiviews\n") withString:("Options FollowSymLinks Multiviews Indexes\n") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange

#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("#LoadModule userdir_module libexec/apache2/mod_userdir.so") withString:("LoadModule userdir_module libexec/apache2/mod_userdir.so") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange

#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("#LoadModule include_module libexec/apache2/mod_include.so") withString:("LoadModule include_module libexec/apache2/mod_include.so") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange
log ocidMutableString as text


#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("#LoadModule rewrite_module libexec/apache2/mod_rewrite.so") withString:("LoadModule rewrite_module libexec/apache2/mod_rewrite.so") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange
log ocidMutableString as text

#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("#LoadModule rewrite_module libexec/apache2/mod_rewrite.so") withString:("LoadModule rewrite_module libexec/apache2/mod_rewrite.so") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange
log ocidMutableString as text


#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
###改行除去
ocidMutableString's replaceOccurrencesOfString:("#CustomLog \"/private/var/log/apache2/combined_log\" combined") withString:("#CustomLog \"/private/var/log/apache2/combined_log\" combined") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange
log ocidMutableString as text



#########################
####内容を書き込む UTF8で書き込む
set boolFileWrite to (ocidMutableString's writeToFile:ocidFilePath atomically:false encoding:(refMe's NSUTF8StringEncoding) |error|:(missing value))



set ocidReadFile to ""
set ocidMutableString to ""
#############################
#############################
####読み込むファイル
set ocidFilePath to refMe's NSString's stringWithString:"/etc/apache2/extra/httpd-userdir.conf"
###ファイルの内容を読み込む
set listReadFile to refMe's NSString's stringWithContentsOfFile:ocidFilePath encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
set ocidReadFile to item 1 of listReadFile
###可変テキスト(置き換えするため)
set ocidMutableString to refMe's NSMutableString's stringWithCapacity:0
ocidMutableString's setString:ocidReadFile


#########################
###↑文字数を数える
set numCntNSMutableString to ocidMutableString's |length|()
###↑文字数全部でレンジにする
set ocidNsRange to {location:0, |length|:numCntNSMutableString}
####除去
ocidMutableString's replaceOccurrencesOfString:("#Include /private/etc/apache2/users") withString:("Include /private/etc/apache2/users") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange

#########################
####内容を書き込む UTF8で書き込む
set boolFileWrite to (ocidMutableString's writeToFile:ocidFilePath atomically:false encoding:(refMe's NSUTF8StringEncoding) |error|:(missing value))


####################################
####ユーザーサイト
####################################

set objFileManager to refMe's NSFileManager's defaultManager()
set strDirPath to "/private/etc/apache2/users"
set ocidNSString to refMe's NSString's stringWithString:strDirPath
set ocidURLPath to refMe's NSURL's fileURLWithPath:ocidNSString
set ocidFileList to objFileManager's contentsOfDirectoryAtURL:ocidURLPath includingPropertiesForKeys:{refMe's NSURLNameKey} options:(refMe's NSDirectoryEnumerationSkipsHiddenFiles) |error|:(missing value)


repeat with objFiles in ocidFileList
  set ocidReadFile to ""
  set strFilePath to objFiles's |path|() as text
  
  #############################
  #############################
  ####読み込むファイル
  set ocidFilePath to (refMe's NSString's stringWithString:strFilePath)
  ###ファイルの内容を読み込む
  set listReadFile to (refMe's NSString's stringWithContentsOfFile:ocidFilePath encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
  set ocidReadFile to item 1 of listReadFile
  ###可変テキスト(置き換えするため)
  set ocidMutableString to (refMe's NSMutableString's stringWithCapacity:0)
(ocidMutableString's setString:ocidReadFile)
  
  
  #########################
  ###↑文字数を数える
  set numCntNSMutableString to ocidMutableString's |length|()
  ###↑文字数全部でレンジにする
  set ocidNsRange to {location:0, |length|:numCntNSMutableString}
  ###改行除去
(ocidMutableString's replaceOccurrencesOfString:("Options Indexes MultiViews\n") withString:("Options Indexes MultiViews FollowSymLinks\n") options:(refMe's NSRegularExpressionSearch) range:ocidNsRange)
  
  #########################
  ####内容を書き込む UTF8で書き込む
  set boolFileWrite to (ocidMutableString's writeToFile:ocidFilePath atomically:false encoding:(refMe's NSUTF8StringEncoding) |error|:(missing value))
  
  
end repeat



###設定変更の値を保存できるように一時的なアクセス権 を戻す
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2/httpd.conf"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2/extra"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2/extra/httpd-userdir.conf"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2/users"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod 755 /private/etc/apache2/users/*conf"
do shell script strCommandText with administrator privileges

###設定読み込んでlaunchctl
set strCommandText to "/usr/bin/sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist"
do shell script strCommandText with administrator privileges
###スタート
set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl graceful"
do shell script strCommandText with administrator privileges
delay 1
tell application "Safari"
  activate
  make new document with properties {name:"localhost"}
  tell front window
    open location "http://localhost"
  end tell
  delay 1
  tell front window
    open location "http://localhost"
  end tell
end tell

|

【6】apachectl ログ削除


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


set strCommandText to "sudo /usr/sbin/apachectl stop"
do shell script strCommandText with administrator privileges



set strCommandText to "/usr/bin/sudo /bin/mkdir -pm 775 /private/var/log/apache2"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /bin/rm /private/var/log/apache2/error_log"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /bin/rm /private/var/log/apache2/access_log"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /bin/rm /private/var/log/apache2/combined_log"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/error_log"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/access_log"
do shell script strCommandText with administrator privileges

set strCommandText to "/usr/bin/sudo /usr/bin/touch /private/var/log/apache2/combined_log"
do shell script strCommandText with administrator privileges


set strCommandText to "sudo chown -Rf _www /private/var/log/apache2"
do shell script strCommandText with administrator privileges

set strCommandText to "sudo chmod 666 /private/var/log/apache2/error_log"
do shell script strCommandText with administrator privileges

set strCommandText to "sudo chmod 666 /private/var/log/apache2/access_log"
do shell script strCommandText with administrator privileges

set strCommandText to "sudo chmod 666 /private/var/log/apache2/combined_log"
do shell script strCommandText with administrator privileges



set strCommandText to "sudo /usr/sbin/apachectl graceful"
do shell script strCommandText with administrator privileges



|

【5】apachectl ディレクトリ関係 基本のアクセス権


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

####ローカルサイト
set strCommandText to "/usr/bin/sudo /bin/chmod 777 \"/Library/WebServer/Documents\""
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/chgrp www \"/Library/WebServer/Documents\""
do shell script strCommandText with administrator privileges

####共有サイトフォルダ作成
set strCommandText to "/usr/bin/sudo /bin/mkdir -p /Users/Shared/Sites"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /bin/chmod -Rf 755 /Users/Shared/Sites"
do shell script strCommandText with administrator privileges
set strCommandText to "/usr/bin/sudo /usr/bin/chgrp -Rf www /Users/Shared/Sites"
do shell script strCommandText with administrator privileges


########ローカルユーザー名取得
set strCommandText to "/usr/bin/dscl . list /Users | grep -v '^_' | grep -v 'daemon' | grep -v 'nobody' | grep -v 'root'"
set strLocalUser to do shell script strCommandText
set AppleScript's text item delimiters to "\r"
set listLocalUser to every text item of strLocalUser
set AppleScript's text item delimiters to ""
########ユーザーサイトフォルダ作成
repeat with itemLocalUser in listLocalUser
  set strLocalUser to itemLocalUser as text
  set strCommandText to "/usr/bin/sudo /bin/mkdir -p \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/bin/touch \"/Users/" & strLocalUser & "/Sites/.localized\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/sbin/chown -Rf " & strLocalUser & " \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /usr/bin/chgrp -Rf www \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  set strCommandText to "/usr/bin/sudo /bin/chmod 755 \"/Users/" & strLocalUser & "/Sites\""
  do shell script strCommandText with administrator privileges
  
end repeat





|

【4】apachectl 設定再読み込みして起動


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl graceful"
do shell script strCommandText with administrator privileges



|

【3】apachectl 再起動


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

set strCommandText to "/usr/bin/sudo /usr/sbin/apachectl restart"
do shell script strCommandText with administrator privileges




|

【2】apachectlストップ


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


set strCommandText to "sudo /usr/sbin/apachectl stop"
do shell script strCommandText with administrator privileges




|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom