-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproject_setup.sh
48 lines (38 loc) · 1.65 KB
/
project_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Prompt for user input
read -p "Enter your laravel app folder: " your_laravel_app_folder
read -p "Enter your database name: " your_db_name
read -p "Enter your database username: " user_name
read -p "Enter your database user password: " password
# Run Composer Install
echo "Running composer install..."
composer install --optimize-autoloader --no-dev
# Copy .env.example to .env
echo "Copying .env.example to .env..."
cp .env.example .env
# Open .env file for editing - user needs to manually update the environment variables
echo "Please update the .env file with your environment settings."
nano .env
# Install npm dependencies and build
echo "Installing npm dependencies and building..."
npm install
npm run build
# Cache configurations
echo "Caching configurations..."
php artisan key:generate
php artisan config:cache
php artisan event:cache
php artisan view:cache
# Set up MySQL Database
echo "Setting up MySQL Database..."
sudo mysql -e "CREATE DATABASE $your_db_name;"
sudo mysql -e "CREATE USER '$user_name'@'%' IDENTIFIED WITH mysql_native_password BY '$password';"
sudo mysql -e "GRANT ALL ON $your_db_name.* TO '$user_name'@'%';"
# Migrate the database
echo "Running migrations..."
php artisan migrate
# Set ownership for Laravel storage and cache
echo "Setting permissions for storage and cache..."
sudo chown -R www-data:www-data /var/www/$your_laravel_app_folder/storage /var/www/$your_laravel_app_folder/bootstrap/cache
sudo chmod -R 775 /var/www/$your_laravel_app_folder/storage /var/www/$your_laravel_app_folder/bootstrap/cache
echo "Laravel project setup completed. Remember to switch the debug_mode and environment in your .env file if needed."