Skip to content

Instantly share code, notes, and snippets.

View mjavadhpour's full-sized avatar
:octocat:

M.J. mjavadhpour

:octocat:
  • The Earth
View GitHub Profile
@mjavadhpour
mjavadhpour / Linux command
Created December 14, 2016 07:46
Linux usefull command
***********************************************************
* *
* Usefull comand *
* *
***********************************************************
php -i | grep php.ini
In ERROR 2002 (HY000):
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
service mysql start or service mysql start
@mjavadhpour
mjavadhpour / php-5.6-repository.md
Last active November 13, 2017 14:17
PHP 5.6 install in linux
$ sudo add-apt-repository ppa:ondrej/php
@mjavadhpour
mjavadhpour / Make Swap
Created December 14, 2016 07:53
Create swap file for linux ubuntu
dd if=/dev/zero of=/media/fasthdd/swapfile.img bs=1024 count=10M
Mkswap ~/swapfile.img
add swap line to ======> etc/fstab
swapon ~/swapfile.img
@mjavadhpour
mjavadhpour / Symfony
Created December 14, 2016 07:57
Symfony permission command
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
find ./ -type d -exec chmod 755 {} \;
find ./ -type f -exec chmod 644 {} \;
# if this doesn't work, try adding `-n` option
setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
export SYMFONY_ENV=prod
composer install --no-dev --optimize-autoloader
---------------------------------------------------------------------------------------------------------------------------------
chmod help:
@mjavadhpour
mjavadhpour / Symfony
Created December 14, 2016 07:57
Symfony install server
export SYMFONY_ENV=prod
composer install --no-dev --optimize-autoloader
@mjavadhpour
mjavadhpour / symfony_permission.md
Last active December 14, 2017 17:36
Another permission command

Symfony

HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)
setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
find ./ -type d -exec chmod 755 {} \;
find ./ -type f -exec chmod 644 {} \;
@mjavadhpour
mjavadhpour / Symfony
Created December 14, 2016 08:01
Turn on _profiler in server
cut from app/config/config_dev.yml and paste to app/config/config.yml
framework:
...
...
profiler: { only_exceptions: false }
web_profiler:
toolbar: false
intercept_redirects: false
cut from app/config/routing_dev.php and paste to app/config/routing.php
Switch PHP version:
From php5.6 to php7.0 :
Apache:
- sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
CLI:
- update-alternatives --set php /usr/bin/php7.0
From php7.0 to php5.6 :
Apache:
- sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
Today I got again problem with PHP 7 running despite I have disabled php7.0 apache module: phpinfo was showing php 7 using fastCGI ...
... So if after you follow the below instructions you face this situation, you may need to disable the proxy_fcgi apache module:
sudo a2dismod proxy_fcgi proxy; sudo service apache2 restart
1. Re-Install PHP 5.6
What worked for me was this guide: http://www.lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu
Actually is not required to remove php7.0, you can install php5.6 together ( also because you will have dependency problem with phpmyadmin package that required php7.0)
You should never have to run a website out of your home directory. EVER. You would otherwise have to give the web server the ability to traverse through /home/ to see the directory structure, but also into /home/$USER/ (your user's home directory, where we can try and see what else exists in your user directory), as well as any other subfolders in there. A poorly-configured or misconfigured or unpatched web server can cause massive data leakage this way, or loss of credentials and such which would put your personal data and logins on different things at risk. The symlink approach you are using doesn't help either for the same reason as trying to give Apache permissions to read /home/andre/www/moodle - the web server has to be able to traverse your home directory to get to the location that the symlink in /var/www/html points to, which still poses that security risk.
Firstly, use sudo cp -r /home/andre/www/moodle/ /var/www/html/. This will copy your files to /var/www/html, and keep it away from your own home