Skip to content

Commit

Permalink
feat: add new project
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcristho committed Apr 19, 2024
1 parent c155d9b commit e55018a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 0 deletions.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions ansible-laravel-with-swoole/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Deploy Laravel App Using Swoole Runtime
hosts: all
become: true
remote_user: root
roles:
- config
37 changes: 37 additions & 0 deletions ansible-laravel-with-swoole/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Add PHP repository
ansible.builtin.apt_repository:
repo: "ppa:ondrej/php"
state: present

- name: Install PHP 8.2 & dependencies
ansible.builtin.apt:
name:
- php8.2-mysql
- php8.2-fpm
- php8.2-mbstring
- php8.2-xml
- php8.2-bcmath
- php8.2-curl
- php8.2-cli
- php8.2-common
- php8.2-zip
- php8.2-gd
- php8.2-swoole
- php8.2-soap
state: present
update_cache: true

- name: Add sail config
ansible.builtin.template:
src: sail.j2
dest: /etc/php/8.2/cli/conf.d/99-sail.ini
mode: preserve

- name: Add supervisor config
ansible.builtin.template:
src: supervisor.j2
dest: /etc/supervisor/conf.d/laravel.conf
mode: preserve


28 changes: 28 additions & 0 deletions ansible-laravel-with-swoole/templates/nginx.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 80;
server_name yourdomain.com;
root /var/www/public;

# CORS Config
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' '*' always;
add_header 'Access-Control-Allow-Headers' '*' always;

index index.html index.htm index.php;
error_page 404 /index.php;
location / {
proxy_pass http://127.0.0.1:8089;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location ~ /\.ht {
deny all;
}

error_log /var/log/nginx/athena_error.log;
access_log /var/log/nginx/athena_access.log;
}
4 changes: 4 additions & 0 deletions ansible-laravel-with-swoole/templates/sail.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[PHP]
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
16 changes: 16 additions & 0 deletions ansible-laravel-with-swoole/templates/supervisor.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
program:laravel-octane-worker]
process_name=%(program_name)s_%(process_num)02d
command=php -d variables_order=EGPCS /var/www/laravel/artisan octane:start --server=swoole --max-requests=1000 --workers=4 --task-workers=12 --port=8089
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/laravel/storage/logs/swoole_http.log
stopwaitsecs=3600
environment=LARAVEL_SAIL="1"

[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid

0 comments on commit e55018a

Please sign in to comment.