Servidor LAMP con Wordpress
Instalación de un Servidor LAMP
Install a LAMP ServerRaspberry 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:
sudo apt-get install -y apache2
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.
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:
sudo apt-get install -y default-mysql-server
sudo apt-get install -y default-mysql-client
sudo apt-get install -y default-libmysqlclient-dev
La--The P proviene de--came from Php, Perl o Python:
Abrimos nuestra Terminal para instalar los siguientes paquetes--Open Terminal and Type:
sudo apt-get install -y php
sudo apt-get install -y php-mysql
Tras lo cual reiniciaremos nuestro servidor--Restart apache which one of this command:
sudo service apache2 restart
O
sudo systemctl restart apache2
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:
cd /var/www/html/
Brindamos el acceso a Apache--And let access to Apache,becarefull we need to be in /var/www/html/ :
sudo chown -R www-data: .
(www guion data: espacio punto)
Reiniciamos el servicio--Restart apache which one of this command:
sudo service apache2 restart
O
sudo systemctl restart apache2
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.
sudo pcmanfm
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:
cd /var/www/html/
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:
sudo rm *
(rm espacio asterico)
Descargamos el último paquete de Wordpress--Get the latest Wordpress version:
sudo wget https://wordpress.org/latest.tar.gz
Descomprimimos el paquete recién descargado--Untar the file:
sudo tar xzf latest.tar.gz
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:
sudo mv wordpress/* .
(/asterisco espacio punto)
Eliminamos el paquete de wordpress y si movimos los archivos, la carpeta wordpress--And delete the unnecesary files:
sudo rm -rf latest.tar.gz
sudo rm -rf wordpress latest.tar.gz
Multiple Webs Step:
After you untar wordpress you will get a wordpress folder, we need to copy this to another folder for differents webs.
sudo cp -r wordpress/ web
sudo cp -r wordpress/ web2
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):
ls
Will give us this result: wordpress web web2w latest.tar.gz
Volvemos a brindarle acceso a Apache--Follow the normal steps:
sudo chown -R www-data: .
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):
sudo mysql
CREATE DATABASE wordpress;
CREATE USER 'pi'@'localhost' IDENTIFIED BY 'Password1234';
Brindamos acceso a la base al usuario creado--Grant access to the user:
GRANT ALL ON Wordpress.* TO 'pi'@'localhost';
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!!!
sudo mysql
CREATE DATABASE web;
CREATE USER 'pi'@'localhost' IDENTIFIED BY '1234567superpassword';
Brindamos acceso a la base al usuario creado--Grant access to the user:
GRANT ALL ON web.* TO 'pi'@'localhost';
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):
sudo mysql
CREATE DATABASE web2;
CREATE USER 'pi'@'localhost' IDENTIFIED BY '1234567superpassword';
Brindamos acceso a la base al usuario creado--Grant access to the user:
GRANT ALL ON web2.* TO 'pi'@'localhost';
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):
sudo mysql
CREATE DATABASE web1000000;
CREATE USER 'pi'@'localhost' IDENTIFIED BY '1234567superpassword';
Brindamos acceso a la base al usuario creado--Grant access to the user:
GRANT ALL ON web1000000.* TO 'pi'@'localhost';
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
Seleccionamos nuestro idioma y presionamos continuar--Choose language.
Leemos las indicaciones y presionamos el botón "Vamos a ello!--Press the button".
Rellenamos los campos pedidos--Enter the data:
Database Name: wordpress
Username: pi (change to you username)
Password: Password1234
Database Host: localhost
Table Prefix: wp_
Y pulsamos "Enviar"--Press "Send".
"Ejecutar la instalación"--"Execute the install".
Llenamos los campos requeridos--Complete:
Site Title: Mi Web con Raspberry Pi
Username: pi
Password: PasswordForDashboard
Your Mail: mimail@gmail.com
Search engine visibility: Tick si no queres ser resultado de Google
"Instalar WordPress"--"Instasll WordPress".
Si todo va bien, pulsamos "Acceder/Login".
Ya podremos instalar plugins y Themes para nuestra web, a diseñar!!!.--Enjoy!!!
Multiples Wordpress sites:
Para el primer sitio web--For the First site:
Open browser and type http://localhost/web:
Seleccionamos nuestro idioma y presionamos continuar--Choose language.
Leemos las indicaciones y presionamos el botón "Vamos a ello!--Press the button".
Rellenamos los campos pedidos--Enter the data:
Database Name: web
Username: pi
Password: 1234567superpassword
Database Host: localhost
Table Prefix: wp_
Y pulsamos "Enviar"--Press "Send".
"Ejecutar la instalación"--"Execute the install".
Llenamos los campos requeridos--Complete:
Site Title: Web Raspberry Pi
Username: pi
Password: PasswordForDashboard
Your Mail: mimail@gmail.com
Search engine visibility: Tick si no queres ser resultado de Google
"Instalar WordPress"--"Instasll WordPress".
Si todo va bien, pulsamos "Acceder/Login".
Ya podremos instalar plugins y Themes para nuestra web, a diseñar!!!.--Enjoy!!!
Para el sitio web2--For the Second site:
Open browser and type http://localhost/web2:
Seleccionamos nuestro idioma y presionamos continuar--Choose language.
Leemos las indicaciones y presionamos el botón "Vamos a ello!--Press the button".
Rellenamos los campos pedidos--Enter the data:
Database Name: web2
Username: pi
Password: 1234567superpassword
Database Host: localhost
Table Prefix: wp_
Y pulsamos "Enviar"--Press "Send".
"Ejecutar la instalación"--"Execute the install".
Llenamos los campos requeridos--Complete:
Site Title: Web 2 Raspberry Pi
Username: pi
Password: PasswordForDashboard
Your Mail: mimail@gmail.com
Search engine visibility: Tick si no queres ser resultado de Google
"Instalar WordPress"--"Instasll WordPress".
Si todo va bien, pulsamos "Acceder/Login".
Ya podremos instalar plugins y Themes para nuestra web, a diseñar!!!.--Enjoy!!!
Para el sitio número N--For the N site:
Open browser and type http://localhost/web1000000:
Seleccionamos nuestro idioma y presionamos continuar--Choose language.
Leemos las indicaciones y presionamos el botón "Vamos a ello!--Press the button".
Rellenamos los campos pedidos--Enter the data:
Database Name: web1000000
Username: pi
Password: 1234567superpassword
Database Host: localhost
Table Prefix: wp_
Y pulsamos "Enviar"--Press "Send".
"Ejecutar la instalación"--"Execute the install".
Llenamos los campos requeridos--Complete:
Site Title: Web n Raspberry Pi
Username: pi
Password: PasswordForDashboard
Your Mail: mimail@gmail.com
Search engine visibility: Tick si no queres ser resultado de Google
"Instalar WordPress"--"Instasll WordPress".
Si todo va bien, pulsamos "Acceder/Login".
Ya podremos instalar plugins y Themes para nuestra web, a diseñar!!!.--Enjoy!!!
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:
sudo apt-get install -y phpmyadmin
Durante el proceso de instalación se nos harán algunas preguntas:
Indicaremos con la barra espaciadora que reconfiguraremos Apache2 y con Tab nos dirigiremos a Aceptar y presionamos Enter para proseguir.
During the installation process we will be asked some questions:
We will indicate with the space bar that we will reconfigure Apache2 and with Tab we will go to OK and press Enter to continue.
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.