Servidor LAMP con Wordpress

Apr 21, 2024

Instalación de un Servidor LAMP

Install a LAMP Server

Raspberry Pi 4B-400-Zero 2W-5

Con la llegada de una nueva Raspberry Pi, ha llegado una nueva versión del Sistema Operativo de cabecera de nuestra querida placa, el conocido Raspbian basado en Debian, ahora se llama Raspberry Pi OS. Con el arribo de esta versión, llegan nuevos paquetes, y nuestros clásicos se actualizan.

Montarnos un Servidor LAMP (Linux-Apache-MySql-Php) es algo simple, que nos brinda la posibilidad de alojar nuestras propias webs en nuestra red local y abriendo el puerto 80(HTTP) o el 443, accederemos desde cualquier lugar del mundo. Wordpress nos brinda la posibilidad, de no necesitar tener el conocimiento para hacer una página web desde cero, gracias a sus plugins, temas y plantillas. Pero, podemos obviar instalar wordpress y crear nuestras propias webs, para nuestros proyectos de Internet Of Things, Aplicaciones Webs, proyectos audiovisuales, etc, desde cero. 

With the advent of a new Raspberry Pi, a new version of the head-end Operating System of our beloved board has arrived, the well-known Debian-based Raspbian, now called Raspberry Pi OS. With the arrival of this version, new packages arrive, and our classics are updated.

Setting up a LAMP Server (Linux-Apache-MySql-Php) is something simple, which gives us the possibility of hosting our own websites on our local network and opening port 80 (HTTP) or 443, we will access from anywhere in the world. Wordpress gives us the possibility of not needing to have the knowledge to make a web page from scratch, thanks to its plugins, themes and templates. But, we can avoid installing wordpress and create our own websites, for our Internet Of Things projects, Web Applications, audiovisual projects, etc., from scratch.

La L proviene de Linux, en nuestro caso Raspberry Pi OS:

The L came from Linux:

Así que, para comenzar necesitaremos una tarjeta de memoria de mínimo 16GB formateada en FAT32, descomprimir NOOBS Lite en ella, colocarla en nuestra Raspberry Pi y descargar mediante el menú de NOOBS, Raspberry Pi OS. O usamos el nuevo Raspberry Pi Imager

So, to start we will need a memory card of at least 16GB formatted in FAT32, unzip NOOBS Lite on it, place it in our Raspberry Pi and download through the NOOBS menu, Raspberry Pi OS. Or we use the new Raspberry Pi Imager

La A proviene de Apache, el cuál será nuestro Servidor Web:

A from Apache, our Server:

Una vez iniciado Raspberry Pi OS, tras haber pasado su Setup Wizard, abriremos la Terminal e instalaremos Apache.

Once Raspberry Pi OS boot Open Terminal and type:

Tras lo cual podremos ver nuestro servidor funcionando, mediante el navegador, ingresando en la barra de dirección localhost y presionando Enter.

After which we can see our server running, through the browser, entering localhost in the address bar and pressing Enter.

http://localhost

La M proviene de MySQL nuestra base de datos, en Raspberry Pi OS usamos MariaDB:

M from MySQL in Pi is from MariaDB:

Procedemos con la instalación de MySql. Abrimos la Terminal e instalamos los siguientes paquetes--Open Terminal and Type:

La--The P proviene de--came from Php, Perl o Python:

Abrimos nuestra Terminal para instalar los siguientes paquetes--Open Terminal and Type:

Tras lo cual reiniciaremos nuestro servidor--Restart apache which one of this command:

Hasta este punto, hemos conseguido instalar un servidor 100% funcional, nuestras páginas webs están almacenadas por defecto en el directorio /var/www/html/ , aquí podremos colocar nuestras webs.

Up to this point, we have managed to install a 100% functional server, our web pages are stored by default in the /var/www/html/ directory, here we can place our webs.

Pero para que sean accesibles debemos darle acceso a Apache, abrimos la Terminal y nos dirigimos al directorio--But for make it accesible we need to let Apache perms so ee need to move to:

Brindamos el acceso a Apache--And let access to Apache,becarefull we need to be in /var/www/html/ :

(www guion data: espacio punto)

Reiniciamos el servicio--Restart apache which one of this command:

Para copiar de una forma interactiva nuestras webs a dicho directorio, podremos abrir el Gestor de Archivos con permisos root  y luego brindar los permisos nuevamente.

To interactively copy our websites to said directory, we can open the File Manager with root permissions and then provide the permissions again.

Si poseemos diversos desarrollos webs, podremos optar porque una esté por defecto en el localhost(/var/www/html/index.html) o [IP]  y el resto dentro de carpetas(/var/www/html/webX/index.html) [IP/webX/] dónde webX, se refiere a cualquier nombre que le hayas colocado a tus diferentes webs(web1,web2,raspberry,arduino,cine,musica,etc) y al indicar IP, me refiero a la dirección IP que tú router/switch le brinda a tú Raspberry Pi,en tu red local(en casa) tendrás una determinada IP, si deseas acceder desde cualquier lugar del mundo debes abrir el puerto 80 en tu router y la IP será la que te brinda tú proveedor y no la debes hacer pública por cuestiones de seguridad.

If we have several web developments, we can choose one to be by default in the localhost (/var/www/html/index.html) or [IP] and the rest inside folders(/var/www/html/webX/index.html) [IP/webX/] where webX refers to any name that you have given to your different websites (web1, web2, raspberry, arduino, movies, music, etc) and when indicating IP, I mean the IP address that your router/switch provides to your Raspberry Pi, in your local network (at home) you will have a certain IP, if you want to access from anywhere in the world you must open port 80 on your router and the IP will be the one that you provide provider and you should not make it public for security reasons.

Instalemos WordPress

Let's install WordPress

Abriremos Terminal y vamos al directorio html--Go to:

Si no hemos hecho una página web propia, procederemos a eliminar la web por defecto de Apache, si realizaste tu web, salteate este comando--Delete apache default web file:

(rm espacio asterico)

Descargamos el último paquete de Wordpress--Get the latest Wordpress version:

Descomprimimos el paquete recién descargado--Untar the file:

Si wordpress será nuestra web por defecto, moveremos todo su contenido a la carpeta html, de no ser así, obviaremos el siguiente comando--If our wordpress will be the unique web then type, if not jump to Multiple Webs Steps:

(/asterisco espacio punto)

Eliminamos el paquete de wordpress y si movimos los archivos, la carpeta wordpress--And delete the unnecesary files:

Multiple Webs Step:

After you untar wordpress you will get a wordpress folder, we need to copy this to another folder for differents webs.

And all the cp you want.

Now we can see with list command that we have 3 folders and the latest.tar.gz (we can deleted):

Will give us this result: wordpress web web2w latest.tar.gz

Volvemos a brindarle acceso a Apache--Follow the normal steps:

Creamos nuestra primer Base de datos--We make our database(can be 1 or more if we follow the Multiple webs:

Abrimos la Terminal  y ejecutamos MySql con permiso root, donde creamos la base de datos y su usuario--Type:

Para una sola web--One web steps(Para multiples web saltar a--multiple steps jump to Multiple Database):

Brindamos acceso a la base al usuario creado--Grant access to the  user:

Presionamos--Press Ctrl+D  para salir de--To exit from MySQL(MariaDB).

Multiple Database para más de una web--for more webs:

For the first web(I left pi user but is your user of Pi OS):

ATENTION: Change pi for your username!!!

Brindamos acceso a la base al usuario creado--Grant access to the  user:

Presionamos--Press Ctrl+D  para salir de--To exit from MySQL(MariaDB).

For the second web(I left pi user but is your user of Pi OS):

Brindamos acceso a la base al usuario creado--Grant access to the  user:

Presionamos--Press Ctrl+D  para salir de--To exit from MySQL(MariaDB).

For the one million web(I left pi user but is your user of Pi OS):

Brindamos acceso a la base al usuario creado--Grant access to the  user:

Presionamos--Press Ctrl+D  para salir de--To exit from MySQL(MariaDB).

Instalamos Wordpress mediante el Navegador

Abrimos Chromium y colocamos localhost en la barra de direcciones, si hemos decidido que wordpress será nuestra web por defecto, caso contrario indicamos: localhost/wordpress/

Open browser and type localhost

Y pulsamos "Enviar"--Press "Send".

Multiples Wordpress sites:

Para el primer sitio web--For the First site:

Open browser and type http://localhost/web:

Y pulsamos "Enviar"--Press "Send".


Para el sitio web2--For the Second site:

Open browser and type http://localhost/web2:

Y pulsamos "Enviar"--Press "Send".


Para el sitio número N--For the N site:

Open browser and type http://localhost/web1000000:

Y pulsamos "Enviar"--Press "Send".

PhpMyAdmin como interfaz gráfica de base de datos

PhpMyAdmin like GUI for manage Database

Podemos instalar PhpMyAdmin como interfaz web para el manejo de nuestras bases de datos. Para ello abrimos una nueva Terminal--We can install PhpMyAdmin like database interface for this open Terminal and type:

Durante el proceso de instalación se nos harán algunas preguntas:

During the installation process we will be asked some questions:

Se nos preguntará, si deseamos configurar una base de datos, ya lo hemos hecho mediante MariaDB, asi que elegiremos No.

We will be asked, if we want to configure a database, we have already done it through MariaDB, so we will choose No.

Ingresando por primera vez

a

PhpMyAdmin

Enter for first time to PhpMyAdmin

Abrimos el Navegador Chromium e introducimos localhost/phpmyadmin en la barra de dirección--We open the Chromium Browser and enter localhost/phpmyadmin in the address bar.

Se nos solicitarán las credenciales de nuestra base de datos, las que hemos creado con MySql a través de MariaDB anteriormente, cuando creamos la base de datos "Wordpress", el usuario "pi" y la contraseña "Password1234". Obviamente, con los datos que  hayas generado tú.


We will be asked for the credentials of our database, the ones we have created with MySql through MariaDB previously, when we created the "Wordpress" database, the user "pi" and the password "Password1234". Obviously, with the data that you have generated.