Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| deploy_laravel_application_on_a_linux_vds [2025/05/13 07:44] – kkaragoz | deploy_laravel_application_on_a_linux_vds [2025/05/13 07:48] (current) – kkaragoz | ||
|---|---|---|---|
| Line 119: | Line 119: | ||
| Once these DNS records are pointing to your server' | Once these DNS records are pointing to your server' | ||
| - | |||
| ===== 4- Nginx Installation & Configuration ===== | ===== 4- Nginx Installation & Configuration ===== | ||
| [[https:// | [[https:// | ||
| Line 383: | Line 382: | ||
| Now, try accessing your '' | Now, try accessing your '' | ||
| - | ===== 7- Database | + | ===== 7- MySQL Installation ===== |
| - | For your Laravel application, you will need a database server. We will install MariaDB, which is the default database system in Debian 12 and a popular, community-developed fork of MySQL. [[https:// | + | For installing MariaDB, you can follow |
| - | + | ||
| - | ==== Step 1: Install MariaDB Server ==== | + | |
| - | You can install the MariaDB server and client packages directly from the Debian 12 repositories. This will typically install MariaDB version 10.11. [[https:// | + | |
| + | ==== Step 1: Install MariaDB ==== | ||
| + | With the given command, you will be able to access MySQL. | ||
| <code bash> | <code bash> | ||
| - | sudo apt update | + | sudo apt-get update |
| - | sudo apt install mariadb-server | + | sudo apt-get install mariadb-server |
| </ | </ | ||
| - | The '' | + | After installation |
| - | + | ||
| - | ==== Step 2: Run the Secure Installation Script ==== | + | |
| - | After installation, it is crucial to run the '' | + | |
| + | ==== Step 2: MySQL Secure Installation ==== | ||
| + | Run the following command: | ||
| <code bash> | <code bash> | ||
| sudo mysql_secure_installation | sudo mysql_secure_installation | ||
| </ | </ | ||
| - | The script | + | It will ask you for '' |
| - | + | <code bash> | |
| - | * | + | |
| - | <code bash> | + | |
| In order to log into MariaDB to secure it, we'll need the current | In order to log into MariaDB to secure it, we'll need the current | ||
| password for the root user. If you've just installed MariaDB, and | password for the root user. If you've just installed MariaDB, and | ||
| Line 411: | Line 406: | ||
| Enter current password for root (enter for none): | Enter current password for root (enter for none): | ||
| # Press Enter | # Press Enter | ||
| - | | + | </ |
| - | * **Set root password? [Y/n]:** Type '' | + | |
| - | <code bash> | + | Then maybe after some questions, it will ask you for setting a new '' |
| + | <code bash> | ||
| Change the root password? [Y/n] Y | Change the root password? [Y/n] Y | ||
| - | New password: # Enter a Strong | + | New password: # Enter a New Root Password |
| - | Re-enter new password: # Enter the Password | + | Re-enter new password: # Enter Again the New Root Password |
| Password updated successfully! | Password updated successfully! | ||
| - | | + | </ |
| - | * | + | |
| - | When you see the message | + | Then when you see the following |
| + | <code bash> | ||
| + | All done! If you've completed all of the above steps, your MariaDB | ||
| + | installation should | ||
| - | ==== Step 3: Log in to MariaDB | + | Thanks for using MariaDB! |
| - | You can log in to the MariaDB command-line interface as the '' | + | </ |
| + | ==== Step 3: Create a User ==== | ||
| + | Let's enter into the MySQL engine with the following command: | ||
| <code bash> | <code bash> | ||
| - | sudo mariadb | + | sudo mysql -u root -p< |
| </ | </ | ||
| - | You can also log in using the '' | + | Now we need to create a user: |
| - | < | + | < |
| - | mariadb -u root -p | + | CREATE USER ' |
| - | # Enter the root password when prompted | + | |
| </ | </ | ||
| - | To exit the MariaDB prompt, type '' | + | After creating |
| - | + | ||
| - | ==== Step 4: Create a Database and User for your Laravel Application ==== | + | |
| - | Now, let's create a dedicated database and user for your Laravel application. This is more secure than using the '' | + | |
| - | + | ||
| - | Log back into the MariaDB prompt (e.g., using '' | + | |
| - | + | ||
| - | Create the database. You can replace '' | + | |
| <code mysql> | <code mysql> | ||
| - | CREATE DATABASE laravel_db; | + | SHOW DATABASES; |
| + | USE mysql; | ||
| + | SHOW TABLES; | ||
| + | SELECT * FROM user; | ||
| </ | </ | ||
| + | Then it will display the users. Now the next step is creating a new database for the Laravel project and set grant privileges to the user that we created on the database. | ||
| - | Create a new user and set a strong password. Replace '' | + | ==== Step 4: Create a New Database ==== |
| <code mysql> | <code mysql> | ||
| - | CREATE | + | CREATE |
| </ | </ | ||
| + | You can change the database name however you want. For the tutorial I set the name as '' | ||
| - | Grant the new user full privileges | + | ==== Step 5: Grant Privileges ==== |
| + | Now we should set grant privileges to user on the '' | ||
| <code mysql> | <code mysql> | ||
| - | GRANT ALL PRIVILEGES ON `laravel_db`.* TO 'your_laravel_user' | + | GRANT ALL PRIVILEGES ON `laravel_db`.* TO 'USER_NAME' |
| </ | </ | ||
| - | + | It's good practice to flush the privileges to ensure | |
| - | Apply the privilege | + | |
| <code mysql> | <code mysql> | ||
| FLUSH PRIVILEGES; | FLUSH PRIVILEGES; | ||
| </ | </ | ||
| - | + | Now, if you get Query OK message, it's time to exit. | |
| - | Exit the MariaDB prompt: | + | |
| <code mysql> | <code mysql> | ||
| exit; | exit; | ||
| </ | </ | ||
| - | ==== Step 5: Verify MariaDB | + | ==== Step 6: MySQL Service |
| - | On Debian, | + | Now it is time to check the service: |
| <code bash> | <code bash> | ||
| - | sudo systemctl status mariadb.service | + | sudo systemctl status mysql |
| + | sudo systemctl status mariadb | ||
| </ | </ | ||
| - | It should show as '' | + | |
| + | If they are not activated and enabled, we should do: | ||
| <code bash> | <code bash> | ||
| - | sudo systemctl enable mariadb.service | + | sudo systemctl enable mysql |
| - | sudo systemctl start mariadb.service | + | sudo systemctl start mysql |
| + | sudo systemctl enable mariadb | ||
| + | sudo systemctl start mariadb | ||
| </ | </ | ||
| - | |||
| - | **Next Steps:** Remember to update your Laravel application' | ||
| ===== 8- Install Composer ===== | ===== 8- Install Composer ===== | ||
| Line 655: | Line 652: | ||
| php artisan migrate | php artisan migrate | ||
| </ | </ | ||
| - | |||
