Skip to content

Instantly share code, notes, and snippets.

@xsenechal
Last active September 25, 2019 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xsenechal/771cebfb1758fa775ccb3fb04ada45c5 to your computer and use it in GitHub Desktop.
Save xsenechal/771cebfb1758fa775ccb3fb04ada45c5 to your computer and use it in GitHub Desktop.
######### Install xampvm ###################
# https://www.apachefriends.org/download.html
######### Ajout d'un vhost ###################
1. Se connecter en "SSH" adans la VM.
2. Dans le fichier /opt/lampp/etc/httpd.conf, décommenter la ligne
Include etc/extra/httpd-vhosts.conf
3. dans le fichier /opt/lampp/etc/extra/httpd-vhosts.conf, ajoute les lignes suivantes
<VirtualHost *:80>
ServerName toto.local
ServerAlias www.toto.local
DocumentRoot /opt/lampp/htdocs/my_project_name/public
<Directory /opt/lampp/htdocs/my_project_name/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
#
ErrorLog "logs/my_project_error.log"
CustomLog "logs/my_project_access.log" combined
</VirtualHost>
4. dans le fichier /opt/lampp/etc/extra/httpd-xampp.conf, au niveau de /phpmyadmin, remplacer Require local par Require all granted
http://toto.local/phpmyadmin/
5. sur mac, dans le fichier dans /etc/hosts, ajouter la ligne. avec l'ip de la VM
192.168.64.3 toto.local
6 sur l'interface de la VM, restart apache et accès à l'appli http://toto.local/
7. ajouter le transfert de port 3306
mysql -h 127.0.0.1 -P 3306 -u root
######### debug avec xdebug et phpstorm ###################
#### Installer php-dev + phpize pour compiler xdebug
# php-dev 7.3 sur debian https://computingforgeeks.com/how-to-install-php-7-3-on-debian-9-debian-8/
apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
apt update
apt install php7.2-dev
# phpize just installed is located at /usr/bin/phpize
export PATH=/usr/bin/:$PATH
#### Installer xdebug
apt-get install autoconf automake
php -i # voir si xdebug est déjà installé
#https://xdebug.org/wizard.php
wget http://xdebug.org/files/xdebug-2.7.2.tgz
tar -xvzf xdebug-2.7.2.tgz
cd xdebug-2.7.2
./configure
make
cp modules/xdebug.so /opt/lampp/etc/
Edit /opt/lampp/etc/php.ini and add the line
zend_extension = /opt/lampp/etc/xdebug.so
# show config issues with
/opt/lampp/bin/php -m
Ajouter dans le fichier (remote_host est l'IP de la machine avec PHPSTORM)
[xdebug]
zend_extension=/opt/lampp/etc/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=192.168.64.1
#### Installer extension chrome ou FF pour ajouter le cookie qui active le debug
# https://www.jetbrains.com/phpstorm/marklets/
# https://www.jetbrains.com/help/phpstorm/browser-debugging-extensions.html
#### sur phpstorm
1. créé une configuration PHP remote debug
2. Lancer le debugger (symbole téléphone)
# https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html
3. ajouter les local file path éventuellement si pas mappé direct
4. Stop break at first line
https://stackoverflow.com/questions/7114762/how-to-stop-xdebug-from-stopping-on-first-line-with-phpstorm
##### ajout des liens symfony debug vers IDEA
Dans le fichier framework.yaml, indiquer la config suivante (HOME et "idea" à adapter au besoin)
ide: 'idea://open?file=%%f&line=%%l&/opt/lampp/htdocs/>/Users/xs/.bitnami/stackman/machines/xampp/volumes/root/htdocs/'
#### composer dans la VM
# https://getcomposer.org/download/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { 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 /usr/local/bin/composer
apt install -y zip git
#### MAJ php 7.2 -> 7.3
apt update
apt upgrade
sudo apt install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
apt update
sudo apt install php7.3
apt install php7.3-cli php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml
rm /opt/lampp/bin/php # pointe avant sur php7.2
ln -s /usr/bin/php /opt/lampp/bin/php
# aussi pour apache
apt install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-fpm libapache2-mod-php7.3 php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-intl
update-alternatives --set php /usr/bin/php7.3
a2enmod php7.3
mv /opt/lampp/modules/libphp7.so /opt/lampp/modules/libphp7.so.bck
cp /usr/lib/apache2/modules/libphp7.3.so /opt/lampp/modules/libphp7.so
#### renouveller le certifiact pour https
mv /opt/lampp/etc/ssl.crt/server.crt /opt/lampp/etc/ssl.crt/server.crt.bck
mv /opt/lampp/etc/ssl.key/server.key /opt/lampp/etc/ssl.key/server.key.bck
openssl req -x509 -nodes -days 1365 -newkey rsa:2048 -keyout /opt/lampp/etc/ssl.key/server.key -out /opt/lampp/etc/ssl.crt/server.crt
vim /opt/lampp/etc/extra/httpd-ssl.conf
<VirtualHost _default_:443>
ServerName toto.local:443
DocumentRoot /opt/lampp/htdocs/toto/public
<Directory /opt/lampp/htdocs/toto/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog "logs/mylittlegeeks_error.log"
CustomLog "logs/mylittlegeeks_access.log" combined
SSLEngine On
SSLCertificateFile /opt/lampp/etc/ssl.crt/server.crt
SSLCertificateKeyFile /opt/lampp/etc/ssl.key/server.key
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment