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 / 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 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
The Apache web server is the most popular way of serving web content on the internet. It accounts for more than half of all active websites on the internet and is extremely powerful and flexible.
Apache breaks its functionality and components into individual units that can be customized and configured independently. The basic unit that describes an individual site or domain is called a virtual host.
These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS.
Each domain that is configured will direct the visitor to a specific directory holding that site's information, never indicating that the same server is also responsible for other sites. This scheme is expandable without any software limit as long as your server can handle the load.
In this guide, we will walk you through how to set up Apache virtual hosts on an Ubuntu 14.
@mjavadhpour
mjavadhpour / Symfony
Created December 14, 2016 07:57
Symfony install server
export SYMFONY_ENV=prod
composer install --no-dev --optimize-autoloader
@mjavadhpour
mjavadhpour / git-useful-commands.md
Last active October 21, 2017 20:48
Git usefull command

Delete all git branch with pattern:

$ git branch | grep " pattern " | xargs git branch -D

Remove file from git cache:

$ git rm --cached mylogfile.log
$ For a directory:
$ git rm --cached -r mydirectory