A Hammerspoon script for managing Apache, Nginx, PHP, and MySQL server services directly from the macOS menu bar.
- Start, stop, and restart server services (Apache, Nginx, PHP, MySQL).
- View and clear service logs.
- Open configuration files for each service.
- Display notifications for service status changes.
- Designed to work seamlessly with the macOS menu bar.
- Hammerspoon: Make sure you have Hammerspoon installed on your Mac. You can download it from Hammerspoon.org.
- Homebrew: This script uses
brew
to manage the services, so Homebrew must be installed on your system. You can install Homebrew using the following command:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Clone the repository:
git clone https://github.com/githubcom13/Hammerspoon-Server-Service-Manager.git
-
Copy the script to your Hammerspoon configuration: Move the content of the repository to your Hammerspoon configuration directory:
cp Hammerspoon-Server-Service-Manager/init.lua ~/.hammerspoon/
-
Reload Hammerspoon: Open Hammerspoon and click on the "Reload Config" button or use the following command:
hs.reload()
The script adds a menu bar icon called "Services" to your macOS menu bar. Click on the "Services" icon to:
- Start, stop, or restart individual services.
- View and clear logs for Apache, Nginx, PHP, and MySQL.
- Open configuration files for easy editing.
To integrate the Lua code with Hammerspoon, follow these steps:
-
Download the
init.lua
file: Make sure you have theinit.lua
file in your project directory. This file contains the necessary Lua code to manage your server services. -
Copy the
init.lua
file to the Hammerspoon configuration directory: Run the following command in your terminal to move theinit.lua
file to the Hammerspoon configuration folder:cp init.lua ~/.hammerspoon/
-
Reload the Hammerspoon configuration: Open Hammerspoon and reload the configuration by clicking on the Hammerspoon icon in the menu bar and selecting "Reload Config," or run the following command in the Hammerspoon console:
hs.reload()
-
Verify the setup: After reloading, you should see the "Services" menu in your macOS menu bar, allowing you to manage Apache, Nginx, PHP, and MySQL services directly.
- You can modify the services managed by this script by editing the
init.lua
file. - To change the PHP version detected by the script, update the command in the
getPHPVersion()
function.
- Service Not Starting: Make sure that the services are installed via Homebrew using
brew install httpd
,brew install nginx
,brew install php
, andbrew install mysql
. - Log Files Not Found: Verify the paths to log files in the
init.lua
file. Paths might differ depending on your Homebrew installation.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Hammerspoon for their powerful automation tools.
- Homebrew for package management on macOS.