Apache, PHP, MySQL and Samba

Ask questions regarding Gentoox, Gentoo and Linux in general in these forums and we'll do our best to help you!
Spiff
Newbie
Posts: 5
Joined: Fri May 07, 2004 5:48 pm

Apache, PHP, MySQL and Samba

Post by Spiff » Sat May 08, 2004 12:31 pm

Can someone who know this write a 100% complete guide on how to install Apache, PHP, MySQL and Samba after a completely fresh (ie. first boot) Pro 1.1 install, WITHOUT any graphical interface (xfree, xfce, etc). I have tried several times now, and it fucked up every time.

Ankh
Newbie
Posts: 9
Joined: Sun Apr 18, 2004 10:43 pm
Location: Leicester, UK
Contact:

Post by Ankh » Sat May 08, 2004 4:08 pm

Quick Hint,

You need to edit /etc/make.conf and change the USE variable to exclude stuff like XFree, e.g. USE="-X". This will tell gentoo to NOT compile those optional extra GUI frontends that require XFree86.

See http://www.gentoo.org/doc/en/portage-manual.xml for more details. See /usr/portage/profiles/use.desc for a listing of keywords / apps.

HTH,

Rich

Spiff
Newbie
Posts: 5
Joined: Fri May 07, 2004 5:48 pm

Post by Spiff » Sat May 08, 2004 6:50 pm

Thanks Ankh, I'll take a look at that.

And sorry for posting loads of crap, but the database was lagging greatly, which made me think it didn't work.

User avatar
nobspangle
Gentoox Guru!
Posts: 1681
Joined: Sun Sep 28, 2003 11:59 am
Location: Manchester, UK

Post by nobspangle » Sat May 08, 2004 11:13 pm

I'll put a how to together but it will take a while as it means starting with a clean pro install and compiling all the programs. Then documenting as I go
If you keep an open mind, will your brain fall out?

Spiff
Newbie
Posts: 5
Joined: Fri May 07, 2004 5:48 pm

Post by Spiff » Sun May 09, 2004 1:12 am

I get a access violation error when emerging "net-daemon" (dependency of MySQL) after running "emerge samba". Why is that?

[Edit] Nevermind, I think I figured everyhing out by myself. I am so smart :D

User avatar
nobspangle
Gentoox Guru!
Posts: 1681
Joined: Sun Sep 28, 2003 11:59 am
Location: Manchester, UK

Post by nobspangle » Sun May 09, 2004 4:04 pm

In this tutorial it is assumed you have a virgin gentoox pro install with a working Internet connection, since it is a tutorial for the pro edition, it is also assumed that you know how to switch to the root user and how to edit text files. The tutorial was updated on 24th January 2005 and uses the latest versions of the programs available in portage marked as stable on that date, it will probablly work with earlier and later versions but I cannot gaurentee that. The versions I installed were:-

mysql 4.0.22-r2
samba 3.0.10
Apache 2.0.52-r1
PHP 4.3.10
mod_php 4.3.10


First up we need to set the use variable in /etc/make.conf if you are starting, like me, with a virgin 1.5 pro install then then you only need add -qt -gtk -gnome -kde to prevent xfree being compiled with php, if you have changed your at any point make sure you have mysql, apache2 and samba in the list. If you don't need cups (printing) support then you can add -cups to the list to prevent it being compiled as a dependency of samba. I also added -sdl due to a new use flag on lib-compat.

Then we'll emerge the packages, we'll update portage while we are at it.

Code: Select all

emerge sync && emerge -av portage mysql samba mod_php
Apache and php are dependencies of mod_php so it is not necessary to emerge them seperatley although it won't make any difference if you do. On my standard installation (non-native) with a 1Mbps Internet connection it took around 5 hours to emerge the packages including an emerge sync.

I have arranged the configuration section in the order the packages are installed, this means you can configure each package as soon as it is installed whilst the system is compiling the other packages.

Configuring MYSQL (mysql was compiled and installed after approx 2 hours)

First we need to run the mysql_install_db script for this to run you need to be able to look up the IP address of your xbox from the hostname with resolveip. You get the hostname by typing hostname at a prompt, the default for a Pro install is Pro. To allow the IP address to be resolved from the hostname with resolveip we need to add an entry to /etc/hosts mapping the hostname to the IP address. If your IP might change use 127.0.0.1 then we can get on with the configuration.

Code: Select all

mysql_install_db
/etc/init.d/mysql start
mysqladmin -u root -h Pro password 'xbox'
mysqladmin -u root password 'xbox' -p
your should replace xbox with a password of your choice and Pro with the hostname of your xbox, after the second mysqladmin command you will be prompted for a password, this should be the same as the password you gave in the first mysqladmin command.

Now we will set up one database which can be used by phpBB

Code: Select all

mysql -p
create database phpbb;
quit
Lastly we'll add mysql to the default run level so it starts when gentoox boots

Code: Select all

rc-update add mysql default
That's it for mysql now on to Samba

Configuring Samba (Samba was compiled and installed after approx 2hrs 45mins)

I won't go in to Samba configuration too much as I consider the example config file to be more than adequate at explaining the basics with more advanced stuff available in the docs online at http://www.samba.org
Start by copying the example file into place, this gives you a good template. Then run testparm to see what you need to change

Code: Select all

rm /etc/samba/smb.conf && cp /etc/samba/smb.conf.example /etc/samba/smb.conf
testparm
This is what you get
/etc/smb.conf wrote:[global]
server string = Samba Server %v
map to guest = Bad User
log file = /var/log/samba3/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printcap name = cups
dns proxy = No
printer admin = @adm
printing = cups

[homes]
comment = Home Directories
read only = No
browseable = No

[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
guest ok = Yes
printable = Yes
print command = lpr-cups -P %p -o raw %s -r # using client side printer drivers.
browseable = No

[print$]
path = /var/lib/samba/printers
write list = @adm, root
guest ok = Yes
You need to edit /etc/samba/smb.conf and add a netbios name I'm going to use xbox so I add a line in the [global] section that says

Code: Select all

netbios name = xbox
you will also want to add some shares add a section like

Code: Select all

[root]
path = /
writeable = yes

[http-root]
path = /var/www/localhost/htdocs
writeable = yes

[E-Drive]
path = /mnt/fatx/e
writeable = yes
That gives you a share of the whole rootfs one for the root of the apache webserver and one for your E drive check that you haven't made any mistakes with the testparm command and start the server and add it to the default run level to make it start on boot

Code: Select all

testparm
/etc/init.d/samba start
rc-update add samba default
If you want to tidy up your smb.conf an easy way to do it is to run testparm then copy the output into nano
Now we need to add some samba users, we'll add two one for each of the default gentoox users.

Code: Select all

smbpasswd -a root
smbpasswd -a gentoox
You should use the same passwords for samba users as you have set for gentoox users (defaults are xbox)

That's Samba done, on to apache

Apache configuration

Before you can configure apache you must wait until mod_php is compiled since it is invoked at start up

First off edit /etc/apache2/conf/apache2.conf uncomment the servername and change it to the name of your server, the server name is the fully qualified domain name of your server, if you were setting up a server to serve http://www.mynewwebsite.com you would put that as your server name.

Next it's a good idea for a server serving php pages that we change the directory index page order so the server looks for index.php before index.html this is changed in /etc/apache2/conf/commonapache2.conf find the line

Code: Select all

DirectoryIndex index.html index.html.var index.php index.php3 index.shtml index.cgi index.pl index.htm Default.htm default.htm
and change it to read

Code: Select all

 DirectoryIndex index.php index.html.var index.html index.php3 index.shtml index.cgi index.pl index.htm Default.htm default.htm
The Apache ebuilds are a bit broken and don't create a few folders they need to so we'll make them ourselves, here's one to hold the log files.

Code: Select all

mkdir /var/log/apache2
If you do want SSL support you will need to sort out your certificates, first define the Apache options

Code: Select all

echo "APACHE2_OPTS="-D SSL -D PHP4"" >> /etc/conf.d/apache2
next you'll need to create a self signed certificate and key, this would normally be done by the ebuild but more broken directories

Code: Select all

mkdir /etc/apache2/conf/ssl
mkdir /var/cache/apache2
cd /etc/apache2/conf/ssl/
/usr/lib/ssl/apache2-mod_ssl/gentestcrt.sh
You can fill in as many or as few of the fields as you wish, enter a . for fields you want to leave blank. You should enter something for the common name field, this should be the same as your server name.

Then fire up apache and add it to the default run level

Code: Select all

/etc/init.d/apache2 start
rc-update add apache2 default
Check Apache is up and running by pointing your browser to http://xbox_ip_address you should get the apache welcome page. Delete all these so your server is ready for your own pages

Code: Select all

rm -rf /var/www/localhost/htdocs/*
new pages can be put in /var/www/localhost/htdocs this can be accessed from your windows PCs on the network in \\xbox\http-root

To make sure mysql mod_php and apache are all playing together we'll install phpBB as this uses all three

Code: Select all

echo www-apps/phpBB\ ~x86 >> /etc/portage/package.keywords
emerge phpBB
point your browser to http://xbox_ip_address/phpBB/install/install.php
change database type to MySQL 4.x
fill in localhost for DSN
phpbb for database name
root for database user
and the password you used in the mysql configuration for database password
Fill in the admin config section then click start install
Click finish installation

delete the install and contrib directories

Code: Select all

rm -rf /var/www/localhost/htdocs/phpBB/install /var/www/localhost/htdocs/phpBB/contrib
refresh your browser

One word of warning, phpBB is now installed using web-app config, this is apparently a good thing, but I am too lazy to learn what it means or how to use it. With web apps I recommend grabbing the source from the author and installing it yourself.

All done

Edited for updates required by broken apache ebuilds
Last edited by nobspangle on Mon Jan 24, 2005 8:53 pm, edited 1 time in total.

Spiff
Newbie
Posts: 5
Joined: Fri May 07, 2004 5:48 pm

Post by Spiff » Sun May 09, 2004 5:12 pm

Very nice guide. I added FEATURES="-sandbox" when emerging xmlparser and net-daemon instead of recompiling perl and libperl. Is that also ok?

Mini-Buu
Linux User
Posts: 15
Joined: Sun May 16, 2004 7:40 pm

Post by Mini-Buu » Wed May 26, 2004 7:15 am

Can this be applied to Home 3.0 and what would i have to do different to make it work?

User avatar
nobspangle
Gentoox Guru!
Posts: 1681
Joined: Sun Sep 28, 2003 11:59 am
Location: Manchester, UK

Post by nobspangle » Wed May 26, 2004 4:48 pm

In home 3.0 samba is already installed so you can miss that part out.
Apart from that it would be the same, you need to pay paticular attention to the part about USE variables as these may need setting up first.
If you keep an open mind, will your brain fall out?

Krazy
Adept
Posts: 54
Joined: Wed Sep 10, 2003 8:41 pm
Location: Auckland, New Zealand

Post by Krazy » Wed Jun 02, 2004 10:39 pm

Excellent HOWTO, nobspangle! :D

I'd like to share my experience with this. I started with a near vanilla pro 1.1 install. Before starting this HOWTO, I had run "magic" to get all patches, except XFree (and things that need XFree). After all updates were done (including a kernel rebuild, and forced "sync"), I did an "emerge Apache". This crapped out with a "caught signal 1" after a while. I had no idea why, as I did nothing to instigate it. Hence on a whim I stopped fanctl, and started it manually, setting speed to 80% with "fanctl -f 80". After that no further unexpected quitting....

I also did a couple of extra things which may be benefical:

1) In /etc/make.conf I set the following*:

MAKEOPTS="-j2"
PORT_LOGDIR="/var/log/emerge"

*the lines were already there, they just needed uncommenting, and changing slightly. Then I created that directory: mkdir /var/log/emerge

This (IMHO) allows for each build to be captured in its own log file, and also permitted 2 compile jobs to be run at once, potentially speeding up the process.


2) I also enabled "ccache" (instructions on http://www.gentoo.org in portage manual, in section 2.3 or thereabouts), but since I didn't have to recompile anything again after making the fanctl change, it didn't gain me much -- some 200 files found as a "cache-hit" in near 4000 compiled]


My build order was slighty different, as didn't want to watch the whole thing, yet also didn't want to confuse myself by doing too many things at once (slow and sure is best...). Hence I did:
emerge apache
emerge perl
emerge samba
emerge mod_php

So what were my results?

I haven't tried samba shares yet, but the rest works. 8)

However I had some issues testing phpBB. For my install (different versions?), I needed to change the instructions a little:

A] where the HOWTO said point your browser to http://xbox_ip_address/phpbb, I need to use http://xbox_ip_address/phpBB/install/install.php

B] where the HOWTO said to delete the install and contrib directories (for phpBB), I needed to do:
rm -rf /var/www/localhost/htdocs/phpBB/install /var/www/localhost/htdocs/phpBB/contrib
{Note: captialization of "phpbb" changed to "phpBB" to match filesystem}


Hopefully this gives n00b's like myself confidence to give it a shot! All in all pretty easy for building from source.

Cheers! :wink:


UPDATE: Check out my post on page 2, for how things go on GentooX Home 4.0. Thanks again, to nobspangle! 8)
Last edited by Krazy on Sat Aug 13, 2005 4:11 am, edited 1 time in total.

User avatar
nobspangle
Gentoox Guru!
Posts: 1681
Joined: Sun Sep 28, 2003 11:59 am
Location: Manchester, UK

Post by nobspangle » Thu Jun 03, 2004 7:20 am

Krazy wrote:A] where the HOWTO said point your browser to http://xbox_ip_address/phpbb, I need to use http://xbox_ip_address/phpBB/install/install.php

B] where the HOWTO said to delete the install and contrib directories (for phpBB), I needed to do:
rm -rf /var/www/localhost/htdocs/phpBB/install /var/www/localhost/htdocs/phpBB/contrib
{Note: captialization of "phpbb" changed to "phpBB" to match filesystem}
Glad you liked the howto, strange differences on phpbb, I wrote the tutorial whilst compiling the stuff onto a fresh install of pro. They must have changed the phpBB install directory from phpbb to phpBB.
If you keep an open mind, will your brain fall out?

bdonkey
Linux User
Posts: 12
Joined: Sun May 23, 2004 5:35 pm

Post by bdonkey » Sat Jul 24, 2004 9:08 pm

I tried following your excellent tutorial on 1.3d, but xfree is still being compiled. Any help?

And I've already tried adding -X to the USE line in make.conf, but that didn't change anything.

User avatar
Trogdor
Gentoox Guru!
Posts: 553
Joined: Tue Oct 07, 2003 9:57 pm
Location: MOUNT TAPE U1439 ON B3, NO RING

Post by Trogdor » Mon Jul 26, 2004 2:25 am

bdonkey wrote:I tried following your excellent tutorial on 1.3d, but xfree is still being compiled. Any help?

And I've already tried adding -X to the USE line in make.conf, but that didn't change anything.
You have to use -a whole bunch of things. Run emerge -v [progname] to get some ideas.
MOUNT TAPE U1439 ON B3, NO RING

Q: HOW DO I RUN MAGIC ??
A: You run magic by not typing in capital letters.

User avatar
nobspangle
Gentoox Guru!
Posts: 1681
Joined: Sun Sep 28, 2003 11:59 am
Location: Manchester, UK

Post by nobspangle » Mon Jul 26, 2004 7:31 am

you need -qt
If you keep an open mind, will your brain fall out?

User avatar
Trogdor
Gentoox Guru!
Posts: 553
Joined: Tue Oct 07, 2003 9:57 pm
Location: MOUNT TAPE U1439 ON B3, NO RING

Post by Trogdor » Mon Jul 26, 2004 9:12 pm

nobspangle wrote:you need -qt
Among others.
MOUNT TAPE U1439 ON B3, NO RING

Q: HOW DO I RUN MAGIC ??
A: You run magic by not typing in capital letters.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests