Skip to content

Instantly share code, notes, and snippets.

@hugsbrugs
Last active April 27, 2016 20:52
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 hugsbrugs/86783a283835661768c2 to your computer and use it in GitHub Desktop.
Save hugsbrugs/86783a283835661768c2 to your computer and use it in GitHub Desktop.
Apache Memo
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*) http://www./$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www./ [R=301,L]
/var/www/maugey.fr/code
http://shop.alterlinks.com/htpasswd/passwd.php
// Placer le .htaccess dans le répertoire à protéger :
#AuthUserFile /var/www/wine-trip.yo/app/.htpasswd
AuthUserFile /homez.534/maugey/www
AuthGroupFile /dev/null
AuthName "Accès Restreint"
AuthType Basic
require valid-user
# Just display in shell line to add
htpasswd -nb USERNAME PASSWORD
# Create htpasswd file with encrypted password
htpasswd -c /home/www/.htpasswd <username>
// Placer le .htpasswd à la racine du site (sauter une ligne à la fin du fichier) :
hugo:xxxxxxxxxxxxxxxxxxx
// Protéger un répertoire par .htpasswd :
AuthUserFile /var/www/domains/alterlinks.fr/toto/.htpasswd
AuthGroupFile /dev/null
AuthName "Restricted Access"
AuthType Basic
require valid-user
# test config after changes
apache2ctl configtest
# gracefully restart server
apache2ctl graceful
# activate module (rewrite, proxy, proxy_http, proxy_ajp, deflate, headers, proxy_balancer, proxy_connect, proxy_html)
a2enmod <module>
# List Apache enabled modules
apache2ctl -M
# List Apache virtual Hosts
apache2ctl -S
# Enable/Disable virtual host (/etc/apache2/sites-available/virtualhost.conf)
a2ensite virtualhost.conf
a2dissite virtualhost.conf
# /etc/php5/apache2/php.ini
# upload size problems are related to :
upload_max_filesize
memory_limit
post_max_size
# Track Apache Rewrite
RewriteLogLevel 9
RewriteLog /tmp/rewrite.log
# Edit your local hosts files if working localy
sudo nano -w /etc/hosts
# Add your domain name
192.168.0.76 my-website.local www.my-website.local
# Create directory
sudo -Hu www-data mkdir /var/www/my-website.local
# Create default index.html file
sudo -Hu www-data nano /var/www/my-website.local/index.html
>Hello World !
# Copy default apache virtual host config file
sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/politiques.test.conf
# Adapt to your needs
sudo nano /etc/apache2/sites-available/politiques.test.conf
<VirtualHost *:80>
ServerAdmin admin@test.com
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# Enable Virtulal Host
sudo a2ensite politiques.test.conf
# Reload Apche config
sudo service apache2 reload
# Test your webiste in your browser
http://my-webiste.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment