Usando Linux para muchas cosas y disfrutando de videojuegos, en dispositivos moviles, consolas y pc. Using Linux for many things and enjoying video games, mobile devices, consoles and pc

Como instalar LAMP en Linux Ubuntu server paso a paso

DriveMeca instalando LAMP en Linux Ubuntu LTS
Una de las formas mas comunes en que usamos nuestros servidores Linux es sirviendo paginas web como por ejemplo instalando algún CMS como WordPress, Joomla, Drupal entre otros. Esta configuracion es conocida como LAMP y viene de las iniciales Linux-Apache-MySQL/MariaDB-PHP.

Para este articulo veremos como instalar y configurar un servidor Linux Ubuntu 16.04 LTS en modo LAMP (en vez de MySQL usaremos MariaDB) paso a paso de la forma mas sencilla y rápida.

Debo aclarar que LAMP no solo se ve en Linux Ubuntu, en todas las distribuciones Linux podemos instalar y configurar gracias a la "magia" del opensource con relativamente pocos cambios. Comencemos entonces con otro articulo de Ubuntu en español

Requerimientos para instalar LAMP en Linux Ubuntu

Como instalar LAMP en Linux Ubuntu server paso a paso

Instalamos dependencias

-Abrimos una consola e instalamos apache, mariadb y php en su versión 7
sudo apt install apache2 mariadb-server php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0

Vídeo tutorial instalando y configurando LAMP en Ubuntu Server



Activamos Apache 2 en Linux Ubuntu Server

-Activamos el servicio para que ejecute cada vez que haga boot el servidor Linux y ejecutamos apache 2
sudo systemctl enable apache2
sudo systemctl start apache2

-Verificamos este ejecutándose el servicio de Apache 2
sudo systemctl status apache2
apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since dom 2016-05-01 17:22:24 COT; 24min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/apache2.service
           ├─11573 /usr/sbin/apache2 -k start
           ├─11576 /usr/sbin/apache2 -k start
           ├─11577 /usr/sbin/apache2 -k start
           ├─11578 /usr/sbin/apache2 -k start
           ├─11579 /usr/sbin/apache2 -k start
           └─11580 /usr/sbin/apache2 -k start

may 01 17:22:23 xe systemd[1]: Stopped LSB: Apache2 web server.
may 01 17:22:23 xe systemd[1]: Starting LSB: Apache2 web server...
may 01 17:22:23 xe apache2[11555]:  * Starting Apache httpd web server apache2
may 01 17:22:24 xe apache2[11555]:  *
may 01 17:22:24 xe systemd[1]: Started LSB: Apache2 web server.
may 01 17:46:52 xe systemd[1]: Started LSB: Apache2 web server.

-Abrimos un browser en otro pc dentro de nuestra LAN y navegamos a la ip del servidor Linux
Navegamos a la ip de nuestro Ubuntu LAMP verificando apache

Ya tenemos activo nuestro Apache2

Articulo recomendado: Como instalar interfaz grafica en Ubuntu server paso a paso

Activamos MariaDB en Linux Ubuntu Server

-En estos momentos en Linux Ubuntu al instalar MariaDB no se pide la contraseña  de la cuenta root, por ello la borraremos directamente en la db para poder cambiarla despues
sudo mysql -u root
use mysql;
update user set plugin='' where User='root';
flush privileges;
quit;

-Aseguramos nuestra instalación de MariaDB colocándole contraseña a la cuenta root de MariaDB. Solo escribimos la contraseña y las demás preguntas las dejamos con el default presionando Enter
sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]
New password: <---escribimos contraseña a la cuenta root de MariaDB
Re-enter new password: <---confirmamos contraseña a la cuenta root de MariaDB
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

-Activamos el servicio de MariaDB y verificamos que este ejecutándose
sudo systemctl enable mysql
sudo systemctl status mysql
mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
   Active: active (running) since dom 2016-05-01 17:21:45 COT; 2h 17min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 27 (limit: 512)
   Memory: 83.5M
      CPU: 6.150s
   CGroup: /system.slice/mysql.service
           ├─4272 /bin/bash /usr/bin/mysqld_safe
           ├─4273 logger -p daemon err -t /etc/init.d/mysql -i
           ├─4417 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file
           └─4418 logger -t mysqld -p daemon error

may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.func                                         OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.gtid_slave_pos                               OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.help_category                                OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.help_keyword                                 OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.help_relation                                OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.help_topic                                   OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.host                                         OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.index_stats                                  OK
may 01 17:22:21 xe /etc/mysql/debian-start[4469]: mysql.innodb_index_stats                           OK
may 01 17:22:21 xe /etc/mysql/debian-start[11440]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables

Artículos recomendadosComo optimizar MySQL / MariaDB de forma segura
                                           5 pasos para instalar MariaDB en Ubuntu Server

Verificamos PHP y sus módulos instalados en Linux Ubuntu Server


-Verificamos versión de PHP instalada
php -v
PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.25-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

-Creamos un archivo php para verificar módulos instalados con PHP
sudo vi /var/www/html/index.php
<?php
phpinfo();
?>

-Reiniciamos el servicio de Apache2
sudo systemctl restart apache2

-Abrimos un browser en otro pc en nuestra LAN y navegamos a la ip del servidor Linux Ubuntu LTS http://ip-server/index.php
Verificamos nuestro Ubuntu LAMP


Ya tenemos un servidor Linux Ubuntu LTS con Apache, MariaDB y PHP 7 (comúnmente conocido como LAMP Ubuntu) listo para trabajar con nuestros proyectos web.

Artículos recomendadosComo agregar una cuenta a sudoers en Linux Ubuntu o Debian
                                           Como instalar MySQL Workbench en Linux Ubuntu paso a paso
                                           Como instalar phpMyAdmin paso a paso
                                           Como instalar Webmin en Linux Ubuntu paso a paso

Quiero vivir de mi blog, de enseñar opensource, pero esto no sera posible sin tu apoyo, me ayudas?

Donar 25 USD

Satisfech@ con el articulo? Bien, hazme un favor, compártelo en tus redes sociales (compartir es sexy). Escríbeme en los comentarios aquí debajo y pasa la voz compartiendo el tweet.

Sígueme en twitter google+facebook, email o YouTube  y podrás estar enterado de todas mis publicaciones.
Disfrútenlo.


Share/Bookmark

No hay comentarios:

Publicar un comentario

Dejame un comentario, aprecio la retroalimentacion. Leave me a comment, I appreciate the feedback.