in ,

How To Install LAMP Stack On Gentoo Linux VPS?.. A Quick Start Guide.

Gentoo Lamp Stack

In this lab, we will try to install LAMP Stack On Gentoo Linux, so our Gentoo VPS/Server can be ready to host web applications or our blogs like WordPress or Drupal CMS.

We will do the following:

  • Configure Our Gentoo Linux Server
  • Install And Configure Apache Web Server
  • Install And Configure PHP
  • Install And Configure Mysql Database Server

we will use demo data like domain name= and public IP-Address=, etc… but you will need to replace all of the demo data with yours.

Step1: Configure the Gentoo Linux Server

Update Our Gentoo Portage

To sync repositories and update Portage

# emerge --sync
# emerge -1q portage

Set Gentoo Timezone

I will set our server TZ=’Europe/Rome’ as the following…

# echo "Europe/Rome" > /etc/timezone
# emerge --config sys-libs/timezone-data

Configuring pkg...

 * Found a regular file at /etc/localtime.
 * Some software may expect a symlink instead.
 * You may convert it to a symlink by removing the file and running:
 *   emerge --config sys-libs/timezone-data
 * Copying /usr/share/zoneinfo/Europe/Rome to /etc/localtime.

Set Gentoo Hostname

We need to configure our server hostname, we can use the server as the hostname, and so our FQDN will be:

Edit the /etc/conf.d/hostname file and replace localhost with your Gentoo hostname server, or keep the current value if it’s OK.

# vim /etc/conf.d/hostname

Append the FQDN to the /etc/hosts file; our FQDN will be, as the server is the hostname, and is our domain name.

And make the FQDN point to your Public IP Address, which in our lab is: (must replace with your public IP address).

Like the following

# vim /etc/hosts
# IPv4 and IPv6 localhost aliases       localhost.localdomain   localhost
::1             localhost.localdomain   localhost      server 
# Imaginary network.

And apply the Gentoo hostname for the current session as the following

# hostname server

Declaring USE Flags For The LAMP Stack

Create the file /etc/portage/package.use/lamp and append the following USE Flags into it.

# vim /etc/portage/package.use/lamp
dev-libs/apr-util mysql
www-servers/apache threads apache2_modules_authn_dbd apache2_modules_dbd apache2_mpms_event
app-eselect/eselect-php apache2 fpm
dev-lang/php apache2 bcmath calendar cgi cjk curl curlwrappers ctype exif ftp fpm gd hash imap intl json mysql mysqli mysqlnd pdo soap sockets sodium spell ssl threads truetype tokenizer unicode wddx xml xmlreader xmlrpc xmlwriter zlib zip
media-gfx/imagemagick hdri jbig jpeg jpeg2k lcms lzma png tiff truetype webp -openmp


Step2: Install Mysql Server

To compile and Installing the MySql Server 8.0.27, run the following command

# emerge -q dev-db/mysql
 * This version of mysql reorganizes the configuration from a single my.cnf
 * to several files in /etc/mysql/mysql.d.
 * Please backup any changes you made to /etc/mysql/my.cnf
 * and add them as a new file under /etc/mysql/mysql.d with a .cnf extension.
 * You may have as many files as needed and they are read alphabetically.
 * Be sure the options have the appropriate section headers, i.e. [mysqld].
 * You might want to run:
 *   "emerge --config =dev-db/mysql-8.0.27"
 * if this is a new install.

As described in the above output, to configure and initialize the MySql server we need to run the following command and select the caching_sha2_password (1) to set the database root password.

# emerge --config =dev-db/mysql-8.0.27
 * Please select default authentication plugin (enter number or plugin name):
 * 1) caching_sha2_password [MySQL 8.0 default]
 * 2) mysql_native_password [MySQL 5.7 default]

To tunning and configure your MySql Server, you can edit the config file /etc/mysql/mysql.d/50-distro-server.cnf

Step3: Install Apache 2 Webserver

To Compile and Install The Apache 2 Webserver we need to run the following command

# emerge -q www-servers/apache

To list all shared and enabled Apache modules

# apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_anon_module (shared)
 authn_core_module (shared)
 authn_dbd_module (shared)
 authn_dbm_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_dbm_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_owner_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 cgid_module (shared)
 dbd_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 expires_module (shared)
 ext_filter_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 info_module (shared)
 log_config_module (shared)
 logio_module (shared)
 mime_module (shared)
 mime_magic_module (shared)
 negotiation_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 speling_module (shared)
 ssl_module (shared)
 unique_id_module (shared)
 unixd_module (shared)
 usertrack_module (shared)
 vhost_alias_module (shared)

You can detect That mod_rewrite, mod_ssl, mod_deflate, and mod_mpm_prefork are installed and enabled.

To tunning Apache module configs, you can found/create configs files at /etc/apache2/modules.d/ directory.

Step4: Install PHP

To get the currently available PHP version

# emerge -p dev-lang/php
[ebuild  N     ] dev-lang/php-8.0.16-r1  USE="acl apache2 bcmath bzip2 calendar cgi cjk cli ctype curl exif fileinfo filter flatfile fpm ftp gd gdbm iconv imap intl ipv6 jit mysql mysqli nls opcache pdo phar posix readline session simplexml soap sockets sodium spell ssl threads tokenizer truetype unicode xml xmlreader xmlwriter zip zlib -apparmor -argon2 -berkdb -cdb (-coverage) -debug -embed -enchant -ffi (-firebird) -gmp -inifile -iodbc -kerberos -ldap -ldap-sasl -libedit -lmdb -mhash -mssql -oci8-instant-client -odbc -pcntl -phpdbg -postgres -qdbm (-selinux) -session-mm -sharedmem -snmp -sqlite -systemd -sysvipc -test -tidy -tokyocabinet -webp -xpm -xslt"

We can detect that the PHP version available is PHP8, so we need to append the PHP_TARGETS="php8-0" value to the /etc/portage/make.conf file

# echo "PHP_TARGETS=\"php8-0\"" >> /etc/portage/make.conf

Start to compile and Installing PHP

# emerge -q dev-lang/php
# emerge -q dev-php/pecl-imagick

The php.ini apache config file will be located at /etc/php/apache2-php8.0/php.ini file

Now enable PHP by adding -D PHP to the Apache options

# vim /etc/conf.d/apache2

Step5: Enable Apache And MySQL Auto-Start

# rc-update add mysql default
* service mysql added to runlevel default
# rc-update add apache2 default
* service apache2 added to runlevel default

Reboot your server, and it’s all running now

# netstat -puntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0    *               LISTEN      2933/sshd: /usr/sbi
tcp        0      0*               LISTEN      2582/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      2933/sshd: /usr/sbi
tcp6       0      0 :::80                   :::*                    LISTEN      2965/apache2
tcp6       0      0 :::443                  :::*                    LISTEN      2965/apache2
tcp6       0      0 :::33060                :::*                    LISTEN      2582/mysqld

Start to build your web application and database

What do you think?

Leave a Reply

Your email address will not be published.

Nvidia Gpu Cuda Share With Docker Container

How To Share Your Host GPU With Docker Container

Ios To Android

The Google Unlisted IOS APP To Helps You Switch From IOS To Android