Created
July 30, 2021 09:17
-
-
Save khalid-s/3ee2c924aead65d44c8cea40eae41f24 to your computer and use it in GitHub Desktop.
iknsa-formation/symfony-app-deployment.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt update && sudo apt upgrade -y | |
| cd /tmp | |
| # https://computingforgeeks.com/how-to-install-mysql-on-ubuntu-focal/ | |
| wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb | |
| sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb | |
| sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password paris' | |
| sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password paris' | |
| sudo apt-get update | |
| sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7* -y | |
| sudo mysql_secure_installation | |
| mysql -uroot -pparis -e "CREATE DATABASE IF NOT EXISTS bookie"; | |
| mysql -uroot -pparis -e "CREATE USER 'bookie'@'localhost' IDENTIFIED BY 'paris'"; | |
| mysql -uroot -pparis -e "CREATE USER 'bookie'@'%' IDENTIFIED BY 'paris'"; | |
| mysql -uroot -pparis -e "GRANT ALL PRIVILEGES ON * . * TO 'bookie'@'localhost'"; | |
| mysql -uroot -pparis -e "GRANT ALL PRIVILEGES ON *.* TO 'bookie'@'%'"; | |
| mysql -uroot -pparis -e "FLUSH PRIVILEGES"; | |
| # PHP Installation | |
| sudo apt install software-properties-common | |
| sudo add-apt-repository ppa:ondrej/php | |
| sudo apt update | |
| sudo apt install -y php7.4 | |
| sudo apt install zip php7.4-xml php7.4-fpm php7.4-json php7.4-pdo php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php-pear php7.4-bcmath -y | |
| # Composer installation | |
| php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
| php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
| php composer-setup.php | |
| php -r "unlink('composer-setup.php');" | |
| mv composer.phar ~ | |
| cd ~ | |
| # Create deploy key | |
| ssh-keygen -t rsa -b 4096 -C "khalid.sookia@iknsa.com" | |
| eval "$(ssh-agent -s)" | |
| ssh-add ~/.ssh/id_rsa | |
| git clone git@github.com:iknsa-formation/symfony-5.3.git bookie | |
| cd bookie | |
| # on passe sur la branche qu'on veut mettre en prod dans le cas ou c'est pas la master | |
| git checkout addressform | |
| ../composer.phar install | |
| sudo systemctl disable --now apache2 | |
| sudo apt install git nginx -y | |
| # Configuration de nginx | |
| # /etc/nginx/sites-available/bookie.conf | |
| server { | |
| listen 80; | |
| root /home/ubuntu/bookie/public; | |
| location / { | |
| try_files $uri /index.php$is_args$args; | |
| } | |
| location ~ ^/index\.php(/|$) { | |
| fastcgi_pass unix:/run/php/php7.4-fpm.sock; | |
| fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
| include fastcgi_params; | |
| fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
| fastcgi_param DOCUMENT_ROOT $realpath_root; | |
| } | |
| location ~ \.php$ { | |
| return 404; | |
| } | |
| error_log /var/log/nginx/bookie_error.log; | |
| access_log /var/log/nginx/bookie_access.log; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment