Web server

From Sinfronteras
Revision as of 17:26, 31 July 2019 by Adelo Vieira (talk | contribs) (Install NGINX on Unbuntu/Debian)
Jump to: navigation, search

In computing, a server is a computer program or a device that provides functionality for other programs or devices, called "clients". Typical servers are database servers, file servers, mail servers, print servers, web servers, game servers, and application servers.

The computer that a server program runs in is also frequently referred to as a server (Server machine).

A web server is a computer system that processes requests via HTTP, the basic network protocol used to distribute information on the World Wide Web. https://en.wikipedia.org/wiki/Web_server

Apache

The Apache HTTP Server, colloquially called Apache, is the world's most used web server software.

Instalación de Apache

Apache User/Group Name and ID

En esta página se muestran varios métodos para obtener el User and Group of Apache: https://www.cyberciti.biz/faq/unix-osx-linux-find-apache-user/

apachectl -S
ps aux | egrep '([a|A]pache|[h|H]ttpd)'
ps aux | egrep '([a|A]pache|[h|H]ttpd)' | awk '{ print $1}' | uniq | tail -1
ps -ef | egrep '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

Para desplegar el Apache user-id (UID) and groupd-id: http://www.digimantra.com/linux/find-users-uid-gid-linux-unix/

id -u www-data
id -g www-data

El comando id despliega el id de cualquier usuario o grupo (no sólo del Apache user).

Start/Stop/Restart Apache Service

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

How do I change the root directory of an apache server

http://stackoverflow.com/questions/5891802/how-do-i-change-the-root-directory-of-an-apache-server

https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-16-04


Please note, that this only applies for Ubuntu 14.04 LTS and newer releases.

In my Ubuntu 14.04 LTS, the document root was set to /var/www/html. It was configured in the following file:

/etc/apache2/sites-available/000-default.conf

So just do a

sudo nano /etc/apache2/sites-available/000-default.conf

and change the following line to what you want:

DocumentRoot /var/www/html

Also do a

sudo nano /etc/apache2/apache2.conf

and find this

<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

and change /var/www/html to your preferred directory

and save it.

After you saved your changes, just restart the apache2 webserver and you'll be done :)

Change Apache HTTP default Port

https://www.tecmint.com/change-apache-port-in-linux/

sudo vi /etc/apache2/ports.conf     [On Debian/Ubuntu]
sudo vi /etc/httpd/conf/httpd.conf  [On RHEL/CentOS]

Versión de PHP usada por apache

Al actualizar la versión de PHP (o si tenemos varias versiones de PHP instaladas) puede ser necesario configurar la versión de PHP que queremos que Apache use. La cuestión es que la versión de PHP que se muestra al ejecutar «php --version» puede ser distinta a la que está usando Apache. https://superuser.com/questions/969861/phpinfo-and-php-v-shows-different-version-of-php/1083828

Para saber cuales son las versiones de PHP disponibles: https://superuser.com/questions/969861/phpinfo-and-php-v-shows-different-version-of-php/1083828

ls /etc/apache2/mods-available/php*.load

Ahora, para configurar la versión de PHP que Apache utilizará: https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/

Primero desactivamos la que está usando actualmente:

sudo a2dismod php5.6

Para luego activar la que queremos:

sudo a2enmod php7.2

Por último:

sudo service apache2 restart

NGINX HTTP Server

Install NGINX on Unbuntu/Debian

sudo apt-get install nginx


Es impotante notar que, if there is already a process running in port 80 (An Apache Web server running for example) al final de la instalación de «nginx», cuando el programa de instalación intente iniciar el servicio «nginx» se desplegará un error indicando que el servicio no se pudo iniciar. Esto se debe a que el puerto 80 (puerto utilizado por nginx por defecto) ya está siendo utilizado. Para solucionar este problema podemos:

sudo fuser -k 80/tcp and then restart NGINX

Luego de esto podemos iniciar nginx:

sudo systemctl start nginx.service

Start/Stop/Restart NGINX service

sudo systemctl start   nginx.service
sudo systemctl stop    nginx.service
sudo systemctl restart nginx.service

Change NGINX HTTP default Port

https://websiteforstudents.com/change-nginx-http-server-port-on-ubuntu-16-04-17-10-18-04/

sudo vi /etc/nginx/sites-available/default
 server {
        listen 8082 default_server;
        listen [::]:8082 default_server;
...

Usar dos Web server (por ejemplo Apache y NGINX) en la misma computadora

Para poder ingresar a distintos Web servers instalados en la misma computadora, lo único que hay que hacer es configurar puertos distintos para cada servidor. Ver: Web server#Change Apache HTTP default Port

Web server#Change NGINX HTTP default Port

Podría también ser necesario, configurar los Firewalls para poder acceder a otros puertos.

Hide Pages, Files, and Directories from Search Engines as Google - The Robots.txt file

http://etikamarketing.com/inbound-marketing/hide-your-pdf-content-from-search-engines/

En MediaWiki - Robots.txt

https://www.mediawiki.org/wiki/Manual:Robots.txt/fr

Block an IP from your site using htaccess

Block a country from your site using htaccess

http://www.inmotionhosting.com/support/website/htaccess/block-country-ips

De esta forma lo logré hacer:

Este método plantea obtener la lista de IP's a bloquear from here: https://www.ip2location.com/free/visitor-blocker y colocarla en el archivo .htaccess. Éste archivo se coloca en cualquier directorio y afectará todos los subdirectorios. En mi caso lo he colocado en el directorio principal de MediaWiki (/var/www/sinfronteras_ws/perso) para que afecte todas las páginas del MediaWiki


Sin embargo,

Aquí se muestran varias formas de hacerlo: https://www.sitepoint.com/how-to-block-entire-countries-from-accessing-website/

Parece que el método más apropiado es a través es este:

Apache Modules

You don’t have to fill your .htaccess file with thousands of lines of IPs. Instead, you can install a C library and an Apache module to do the heavy lifting for you.

MaxMind provides a popular free database that is often used for IP lookups. Their GeoLite2 is a free database that is updated monthly. Their paid product is more accurate and updated more frequently if you require that.

By using this database and installing one of their various APIs, you can handle traffic as you see fit.

For our purposes, you would need to install the C library API as well as the Apache module. Once those are working and enabled, place the database file somewhere, and then you can set up your country blocks with code as simple as this in the .htaccess or Apache config file...


Explicación de los archivos .htaccess, donde colocarlo y cómo se activa en Apache:

http://webmasters.stackexchange.com/questions/61009/how-to-enable-use-of-htaccess-in-apache-on-ubuntu

http://www.commentcamarche.net/contents/7-apache-les-fichiers-htaccess

https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file