This scripts that I use for life with local projects
This Bash script facilitates the creation and deletion of projects along with configuring Apache settings and MySQL databases for a development environment.
Ensure that the following utilities are installed before executing the script:
* git
* openssl
* sudo
* systemctl
* mysql
* service
* a2ensite
* a2dissite
Before usinf you need to setup the script.
$ ./deploy_project.sh project_name action [git_repo]
Create a project:
$ ./deploy_project.sh create my_project_name https://github.com/username/my_project.git
Delete a project:
$ ./deploy_project.sh delete my_project_name
* project_name: The name of the project.
* action: The action to perform, either create or delete.
* git_repo (optional): The Git repository URL (for SSH project creation).
* MySQL: Ensure that the MYSQL_USER and MYSQL_PASSWORD variables are correctly configured in the script.
* Apache: Adjust the APACHE_SERVICE, SITES_AVAILABLE, and ADDRESS_SUFFIX variables as per your Apache configuration.
* Project Root Directory: Modify the PROJECTS_ROOT variable to define the root directory for your projects.
* Sets up MySQL database and user.
* Clones the project from Git repository (if provided) and configures Apache settings (add VirtualHost and add record to hosts file).
* Provides instructions and paths for the created project.
* Removes project-related directories and remove VirtualHost Apache settings.
* Deletes the MySQL database and associated database user.
* The script checks for the necessary utilities and prerequisites before execution.
* Modify the script variables to align with your system configuration before usage.