Gentoo LAMP (Linux, Apache, MySQL, PHP) install tutorial
Publish date 03/08/2008
updated 12/11/2013
This is a tutorial to install LAMP: Linux, Apache, MySQL and PHP on Gentoo.
As Gentoo compiles everything it can takes some time. You might want to use screen, so you don't have to leave a console open.
To install on gentoo just emerge the necessary packages.
You might want to sync the emerge database first:Then emergeemerge --sync
emerge www-servers/apache
USE="mysql apache2" emerge dev-lang/php
emerge dev-db/mysqlAs emerge compiles and installs everything, you only need to configure.
Apache
Change the config file:
APACHE_OPTS="-D PHP5" //uncomment this line and modify itnano /etc/conf.d/apache2
nano /etc/apache2/conf/apache2.conf [code from apache2.conf] ServerName 127.0.0.1 //change the IP to your domain name #parse php in HTML #add this line to the bottom of the conf file AddType application/x-httpd-php .php .html .htm #for directory views, directory access and vhosts see the example above.
To start the apache server
To make it start on boot:/etc/init.d/apache2 start
rc-update add apache2 default
MySQL
To start the MySQL server:
you will get a specific error message telling you to run a mysqladmin command. To set the password for the root user:/etc/init.d/mysql start
You might want to create extra users for different task or databases. This can be done with GRANT:/usr/bin/mysqladmin -u root -h localhost password "newpassword"
(You replace "database" withe the name of the database, "username" with the name of the user and "password" with the secret password) This allows the user to connect from localhost only! Which is in most cases enough, and the most secure.
bin/mysql -u root -pGRANT select,insert,update,delete,create,drop ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password'
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';To start MySQL server at boot:
rc-update add mysql default