"the practice of arbitrary imprisonments have been, in all ages, the favorite and most formidable instruments of tyranny." --Alexander Hamilton, Federalist #84
In this article, i will explain to you how you can set up a full webserver on Gentoo Linux.
This will include: Apache, MySQL, PHP. (also known as a LAMP server)
Yes, i know there are things such as Xampp where this comes pre-bundled
but,... what is the fun in that??
Incase you're wondering if you can add Ruby, Perl, or even Python,
the answer is yes. You can.
These extentions are nothing more than modules.
Requirements:
1) Internet
2) Patience
3) Coffee
4) Basic knowledge of Gentoo Linux (read: abillity to install it)
5) Good set of reading glasses
Introduction to Gentoo's Portage
Gentoo Linux uses a system called "portage" to install packages. (like BSD's Port)
Installing an application:
CODE :
# emerge <package name>
Un-installing an application:
CODE :
# emerge -C <package name>
Searching for an application:
CODE :
# emerge --search <package name>
However, this takes ages and is an ineffecient method.
I suggest using eix for this.
CODE :
# emerge eix && update-eix
the above will install eix, and update it's database of applications.
CODE :
$ eix <package-name>
Updating the portage tree:
CODE :
# emerge --sync
If you use eix, I suggest you also update the eix database.
CODE :
# update-eix
However, it doesn't stop there.
Since Gentoo Linux compiles all programs from source,
the applications become far more flexible. We can now add, and remove features with the USE flags.
Add the following to /etc/apache2/httpd.conf
[code]
ServerName <name>
Listen <port>
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5"
Where <name> is the name of the host and <port> is the port you want Apache to listen on.
If Apache is hosted locally, you can usually use localhost for name. Port will usually be 80 for webserving.
You should now have a basic, functional Apache server.
Please check this page
Add as you feel required. (don't forget mysql and apache2 !)
I suggest you read trough those carefully. Otherwise you need to re-compile php with the USE flags you've forgotten to add.
Installation
Simple:
CODE :
# echo "dev-lang/php apache2 mysql <ADDITIONAL USE FLAGS>" >> /etc/portage/package.use
# emerge php
Configuration
The configuration file is located in 3 places, so you can configure php differently for the 3 ways you can use it.
We are only interrested in the 3rd file.
CODE :
Automatically launch the server upon startup:
CODE :
# rc-update add mysql default
Securing
(The "mysql_setpermission" script requires DBI and DBD-mysql to be installed. This is not called out in the install instructions/dependencies above.)
you HAVE to use the same password for root that you used when you ran emerge --config dev-db/mysql !!
CODE :
mysql_setpermission
An alternative method is to do it manually via the mysql console:
CODE :
mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('betchawontguessit');
Cast your vote on this article 10 - Highest, 1 - Lowest
Comments: Published: 8 comments.
HackThisSite is the collective work of the HackThisSite staff, licensed under a CC BY-NC license.
We ask that you inform us upon sharing or distributing.