Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active August 31, 2022 18:02
Show Gist options
  • Save ederrafo/7b608c64ee13c4610569 to your computer and use it in GitHub Desktop.
Save ederrafo/7b608c64ee13c4610569 to your computer and use it in GitHub Desktop.
Todo sobre apache

403 Forbidden

You don't have permission to access /api/users/roles/3 on this server.

<Directory "/home/costamar">
        .
        .
        Require all granted
    </Directory>

Error: 403 Forbidden, You don't have permission to access / on this server.

  $ apachectl -V
  > Server version: Apache/2.4.18 (Ubuntu)

Bloquear un directorio

  Crear un .htaccess en el directorio y poner:
  Deny from all

Redireccionar todo a otra url excepto algunas subfolders

  RewriteEngine On
  RewriteCond %{REQUEST_URI} !(folder1|script.php|folder2|folder3|folder4) [NC]
  Rewriterule ^(.*)$ http://anothersite.com [L,R=302]

See the date/time on my apache server via ssh ===

  $ date // Esta fecha es del server no de apache

Check version ==

  $ apachectl -V
  $ /usr/sbin/apache2 -v

Apache virtualhost

  $ sudo nano /etc/apache2/sites-available/000-default.conf
  <Directory "/home/eder/projects">
     Order allow,deny
     Allow from all
     # New directive needed in Apache 2.4.3: 
     Require all granted
     AllowOverride All
  </Directory>
  <VirtualHost *:80>
    ServerName costamaragencias.dev
    DocumentRoot /home/user/projects/costamaragencias.dev/
    SetEnv APPLICATION_ENV "development"
  </VirtualHost>

Instalando apache

  $ apt-get install apache2

Habilitando modulos con a2enmod (Apache2 Enable Module), activa los modulos que estan en "/etc/apache2/mods-available" y los

pasa a "/etc/apache2/mods-enabled."

  • Modulo rewrite : para urls limpias
$ a2enmod rewrite

Luego establecer a que host va a aplicar el rewrite, en el, debemos establecer: 'AllowOverride All', incluso se puede definir a que directorio queremos que aplique. http://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

Reiniciar apache

  $ sudo /etc/init.d/apache2 force-reload

=== htaccess ===

RewriteRule ^booking/(\w+)(\w+)$ booking.php?country=$1&lang=$2 RewriteRule ^booking/flights/(\w+)(\w+)$ flights.php?country=$1&lang=$2

Reescribe esta http://my-site/movil/booking.php?country='+ pais +'&lang=' +lang; a : http://my-site/movil/booking/'+ pais +'_' +lang

=== htaccess limitar el tamano de imagenes que se suben === php_value upload_max_filesize 2048K php_value post_max_size 2048K

=== Apache code errors === Error AH01276 [Fri Apr 22 10:48:14.267572 2016] [autoindex:error] [pid 6735] [client 127.0.0.1:44462] AH01276: Cannot serve directory /home/eder/projects/eder/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

Apache Error: No matching DirectoryIndex (index.html) found [SOLVED]

= Apache Error for One General Reason = This error may occur when attempting to access applications that have an index.php file (or other index file), but not an index.html or other specified ‘directory index’ file. For example, phpMyAdmin includes an index.php file upon installation, but not an index.html file. By default Apache is configured with the following: DirectoryIndex index.html

…meaning that Apache will only look for directory index files that are named index.html. So, when attempting to access phpMyAdmin, Apache throws the following error: [autoindex:error] [pid 20115] [client 10.30.6.80:50800] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive In this case we want to add index.php to the DirectoryIndex directive. $ vim /etc/httpd/conf/httpd.conf

Change: <<< DirectoryIndex index.html

to: DirectoryIndex index.html index.php

Then exit and save the file with the command :wq . Be sure to restart Apache: $ systemctl restart httpd

source: http://www.liquidweb.com/kb/apache-error-no-matching-directoryindex-index-html-found-solved/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment