The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. January 08, 2009, 11:16:53 PM

Login with username, password and session length


Pages: [1] 2 3 ... 7
  Print  
Author Topic: Got my Mac Mini, Now What?  (Read 3403 times)
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« on: July 19, 2008, 05:40:32 PM »

Ok, so this is basically a conversation between perk and me. Anyone else feel free to chime it, but basically perk is playing Yoda to my Luke.

We had been talking about my Linux woes, and that maybe the mac mini is the better way to go as a server. Partly because you are talking about a small, cheap, easily replaceable, consistent hardware, and a pretty solid OS. The other reason is what I thought of, which is, I know my way around a mac desktop. Yea sure, I should learn the shell and do everything from the prompt. Pfft eat me. Im a windows tard, who swims in the mac tard pool. I have enough windows server knowledge to fill the bucket half way, and when you include my wife's mac needs, i dont have half a bucket left for linux. At least I can do alot from the desktop if need be, and perk is avoiding my calls. Wink

So... without further ado... WTF now?

So perk,

Bought a mini today. Figured I would get started, while waiting for the RAM to come in a few days. Initial peeve is why did they use 2 freaking sticks of 512... ugh. anyways...

all setup, turned off some duh things like bluetooth and wifi, never screensaver, never sleep, never hard drive off, etc. turned up the security to what seemed to make sense to me, like no autologin. But now what?

first thing I have learned, its bash. meh whatever, I have no preference, so great, at least now I know its Bash when I need to lookup something online.

But how do you install services like apache or php or mysql? Is there an apt-get/yum/rpm type deal, or is it a little more hands on?

oh yea, and how do you add multiple IPs?

that i think is a good start... nothing big... lol



#############################################
#             pasting the brief steps here for future reference         #
#############################################
This is a post to consolidate some steps into 1 post for reference

install OSx clean.
turn off all the extra applications that are not needed.
when it finally finishes and boots...

###Via the GUI
install xCode tools - was on install CD/dvd #2 for me. this puts the compiler tools into linux for you.
in system settings -> sharing
  turn on screen sharing for vnc, and click computer settings. set a password if you need VNC
  Turn on remote login for SSH
  Make sure web sharing is off.
set screen saver and power features to never, and hard disk checkbox as well.
set security to disable automatic login, log out after X minutes, Require password to unlock system prefs pane, disable infrared.
turn off blue tooth if you dont need it.
turn off wifi if you dont need it.
under users, change to display login as Name and Password, to reduce external knowledge. turn off everything under guest.
download mysql,php, and apache sources into your downloads folder (default).
uncompress each of those, and delete the compressed files.

###via terminal or SSH
to make life easier so you dont have to worry about stuff while getting set up, do: sudo su
First lets make sure that apache isnt running, because if it is, the rest of this might not go well...
ps aux
  if you see anything at all in the list that is httpd, your pooched. websharing must be on, or something went bad.
  I had to reinstall.
cd /usr
mkdir local
cd local
mkdir installs
mv /users/whateveryourshortnameis/downloads/mysqlORphpORapache /usr/local/installs/mysqlORphpORapache
   your user directory is whatever your login name was you set during install of OSx.
   mysqlORphpORapache is each folder of those. you will do that 3 times obviously...
mv /usr/bin/php /usr/bin/php-leopard
mv /usr/bin/phpize /usr/bin/phpize-leopard
  you are just relocating the original OSx versions to get them out of the way, just in case.

###setting up apache
cd /usr/local/installs/yourapacheinstallfolder
vi configure.XX
  XX is your initials
in VI, you press i to insert, ESC to get out of insert, :w to save :q to quit.
enter this (or whatever custom settings you want)
   ./configure \
        --enable-rewrite \
        --enable-ssl \
        --enable-proxy \
        --enable-so
save and quit :wq
chmod 777 configure.XX
./configure.XX
  now it will run the configuration. wait until its done.
make
  wait until its done
make install
  wait until its done and they yeay, apache is installed.

###setting up mysql
cd /usr/local/installs/yourmysqlinstalldirectory
we will just use the default config, but otherwise, do the same as above, but with your settings.
./configure --prefix=/usr/local/mysql
  wait....
make
  wait....
make install
  wait.... Done with mysql
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
bin/mysql_install_db
chown -R root  .
chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe &    <<< Dont forget the ampersand
bin/mysqladmin -u root password NEWPASSWORD

###setting up PHP
cd /usr/local/installs/yourphpinstalldirectory
vi configure.XX
enter this, or your own custom version
   ./configure \
        --with-apxs2=/usr/local/apache2/bin/apxs \
        --with-mysql=/usr/local/mysql \
        --with-mysqli=/usr/local/mysql/bin/mysql_config \
        --with-pear \
        --disable-cgi \
        --enable-ftp \
        --enable-soap \
        --enable-sockets
exit by typing :wq
chmod 777 configure.XX
./configure.XX
  wait....
make
  wait....
make install
  wait.... PHP is now installed

Woot! all the junk is installed, now to make stuff go.
/usr/local/apache2/bin/apachectl start
  apache should now start, and if you "ps aux" after a minute or two, you should see a few httpd processes running.
  if it seems to be the default directories, and not /usr/local/apache2/bin/httpd
  then do apachectl stop
  wait a minute or two
/usr/local/apache2/bin/apachectl start
  wait a minute then
ps aux
  it should now show the correct path.
  the reason this is a problem is because apparently if you just type "apachectl start" from anywhere,
  including your apache dir, it will still use the default OSx install of apache... dumb.
  So you HAVE to use the full path to call it, or i guess you could cd to your dir and do ./apachectl start
  which i think will work as well now that I think about it.
because you have no hosts set yet, you need to create a virtual host. for now you probably get the apache test page if you do http://localhost or hit the IP of the machine from another.

so... now on to hosts.
I am not going to cover how to change your hosts file or dns on your desktop machine. if you dont know how to do that, frankly this thread is probably a bit beyond you. but if you are not familiar with it from memory, here you go http://en.wikipedia.org/wiki/Hosts_file

continuing in terminal on the OSx web box.
cd /
mkdir www
cd www
mkdir sites
cd sites
mkdir test.com
cd test.com
create a simple index.html file and  a php file which has <?php phpinfo(); ?> in it
cd /usr/local/apache2/conf/extra
vi httpd-vhosts.conf
 it should be pretty straight forward.
 you can set a specific IP, or just leave it *
 set the server name you want, the aliases like www, and the document root.
 change the document root to /www/sites/whatevertestdomainyouareusing
 set the servername and alias to whatevertestdomainyouareusing
 quit and save
cd ..   so you are now back in /conf
vi httpd.conf
change the DocumentRoot to "/www/sites" or where ever you chose to put your sites. its kind of like a "you can work here" directive.
change <Directory "/whatever/path/was/here"> to have the same path you set in DocumentRoot
go to the bottom of the file
uncomment (remove the #) from the line under #virtual hosts. This allows apache to load the virtual hosts file which will allow you to run your website empire.
add these 3 lines, technically anywhere, but put below the Dynamic Shared Object (DSO) Support comment block
  LoadModule php5_module        modules/libphp5.so
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
save and exit :wq

restart apache


« Last Edit: July 24, 2008, 02:02:07 PM by nutballs » Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 679



View Profile
« Reply #1 on: July 19, 2008, 07:46:34 PM »

there are no buckets. Learn how to make full use of the Linux command line, and you have total and utter control over Linux and osx, there really never is a need for windows. Not only that, you will be able to hack and do whatever you need from your iPhone. GUIs are for suckers. We all use them, but when itcomes down to the wire, if you can't hack it from the cli, your toolbox is really less than half full. Even if all you do is program, which I suspect is not your case nuts.
Logged

nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #2 on: July 19, 2008, 08:08:16 PM »

true true. I do plan on getting there, eventually. however, at the moment, i just need to get up and running and going in forward direction, and for now, limping through the shell, and supplementing with GUI is good enough.

But yes, I fully agree that I need to get myself fully shell capable, or at least to the level required for my work. Actually thats part of the point in this exercise, I enevitably will learn more than what is actually shown in this process, because that is just how I am. I am like a magic sponge. Normal sponges only absorb what they come in contact with, i absorb all its friends...

@perk
I downloaded  php5.2.6, apache2.2.9 and mysql5.0.51b sources, because I figure thats what you were gonna have me do anyway Wink
not sure if there is anything else to DL, like memcached?

The other thing is I obviously want this box to be as light as possible, so things like bluetooth and airport would be nice to uninstall Wink

How does the apple updater deal with this kind of thing? Does it get pissy if something is missing that it knows should be there, like airport?
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 5326


:sniffle: Humor was so much easier before.


View Profile
« Reply #3 on: July 19, 2008, 08:42:46 PM »

I downloaded  php5.2.6, apache2.2.9 and mysql5.0.51b sources, because I figure thats what you were gonna have me do anyway Wink
not sure if there is anything else to DL, like memcached?
As the 285 level course we'll do APC, no longer memcached. The DLs you have pulled are perfect.

In System Preferences turn Apache off. Dump the apache source in /usr/local/installs/httpd (/installs/httpd will not exist, you'll be creating them). Configure, make and make install Apache. The configuration script will look something like this:

./configure \
        --enable-rewrite \
        --enable-ssl \
        --enable-proxy \
        --enable-so


This will create a strong basic Apache instance. With MySQL you'll simply do a standard configure. With PHP I do something more like this:

./configure \
        --with-apxs2=/usr/local/apache2/bin/apxs \
        --with-mysql=/usr/local/mysql \
   --with-mysqli \
        --with-pear \
        --disable-cgi \
   --enable-ftp \
        --enable-soap \
        --enable-sockets


... that will create a strong basic PHP for you. CAVEAT: Before you compile PHP you'll want to do a "which PHP" to see where the system is pointing for the PHP instance. You can either modify that, or adjust your configure to drop the newly-created executables in the same directory. Note that you will not be able to configure PHP in this way until you've already compiled and installed Apache and MySQL.

The other thing is I obviously want this box to be as light as possible, so things like bluetooth and airport would be nice to uninstall Wink
don't need to uninstall, just shut off what you don't want on via system preferences. The amount of HD saved by trying to extract it from the OS will add unnecessary complexity and not give you enough freed up HD in return

How does the apple updater deal with this kind of thing? Does it get pissy if something is missing that it knows should be there, like airport?
Nope... that's why we'll leave it, even if it's off. And remote desktop is how you'll control updates. However, given that you will want to be behind a firewall and this is all controlled environment (not a user surfing the net) security updates will be a whole lot less important.

@ multiple IPs - you'll only have one private IP. The firewall will control your IP and route inward towards you. At this point, your goal should be getting phpMyAdmin running on your machine. On your development box, add a hosts record - something like "a.b.c.d my.phpmyadmin" where a.b.c.d is a node on your network and an address that the Mac is running. Then when you fire up a browser on your dev machine and call for my.phpmyadmin you'll be pointing at the new Mac. On the Mac, create a virtual host to answer to my.phpmyadmin on the same address. Have that point to a phpMyAdmin directory. When all is configured correctly, you'll be administering a MySQL DB vi Apache and PHP on that box and that's how you'll know you've got it all working correctly.

I have to run off to the airport, will be back in a couple hours. Or catch you tomorrow.

/perk
Logged

If I can't be Mr. Root then I don't want to play.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #4 on: July 20, 2008, 08:54:39 AM »

ok. i got to a point.

First, in the /usr directory there was no local even. So obviously I made that as well.

In the configure file for apache, there obviously was a hell of alot more than what you showed, but, I made sure those 4 things were set, which they are by default it seems.
Also mem-cache is on, which i just happened to notice as I was scrolling through the options. I assume leave that on.

At some point in the future I will go through all the options and figure out what they are, but for now, blind carebear mode.

HAHAHA i AM ReTaRdEd move along.

So, errr.... how do I install it? I have never actually compiled anything for linux, always used repositories whenever I played around.
if I type "make" i get command not found, i was hoping for a help response at least to guide me forward. lol
« Last Edit: July 20, 2008, 09:45:59 AM by nutballs » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 5326


:sniffle: Humor was so much easier before.


View Profile
« Reply #5 on: July 20, 2008, 12:00:48 PM »

If you can't do a "make" then you don't have the developer tools on your machine. Download the XCode developer's stuff from Apple, or, if this is a new machine, then it is an optional installation thing on the DVD (it may be called "developer tools" on the dvd). That has gcc, make and all the yummy ingredients for a nice dev machine.

The cycle for standard old-school install on a *nix box is:
configure
make
make install

Configure will, well, configure the make script for your machine. This is because you may have different libraries and header files on your box. make actually does the compilation and linking. make install will move everything where it's supposed to go.

The reason I supply my own configure (I always use configure.[my initials]) is that there are options I want to pass to configure and I don't want to have to remember them, or I want to see later how I built the package. So in the Apache example, I've created a tiny file called configure.xx which has what you see above, then chmod 777 configure.xx so that it can be executed. It calls configure with my parameters.

Give that all a rip and see how you get. I'll be in and out today, errands and Steely Dan at the dodge tonight.
Logged

If I can't be Mr. Root then I don't want to play.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #6 on: July 20, 2008, 06:01:11 PM »

... that will create a strong basic PHP for you. CAVEAT: Before you compile PHP you'll want to do a "which PHP" to see where the system is pointing for the PHP instance. You can either modify that, or adjust your configure to drop the newly-created executables in the same directory. Note that you will not be able to configure PHP in this way until you've already compiled and installed Apache and MySQL.

ok i moved the old php, /usr/bin/php to /usr/bin/php-leopard
And I was planning on linking the new via
ln -s /usr/local/notsurehwhereitinstalled /usr/bin/php

so where did php get installed to, so I can link it? I assume that is what you meant by the quote above?

I assumed it would install to /usr/local/something like the other 2 packages did, but i cant find it.

also, to just test if apache is running, shouldnt I be able to do http://localhost and at least a page not found or something? or is this literally a blank install, meaning not even localhost has a site?

oh and have fun at steely dan. dont reminisce too hard  Devilish
Logged
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #7 on: July 20, 2008, 06:05:08 PM »

oh and another question. is there a way to actually elevate to root without sudo everygoddamthing?
Logged
jammaster82
Expert
****
Offline Offline

Posts: 300

bloody hacker


View Profile WWW
« Reply #8 on: July 21, 2008, 05:11:02 AM »

I have a question, too. Theoretically could these
steps be followed on a linux machine and get a
resulting compatible setup?

Logged

Of course Big Brother exists, he is the embodiment of the party..... Does he exist in the same way I exist?....... You, do not exist.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 679



View Profile
« Reply #9 on: July 21, 2008, 05:41:29 AM »

oh and another question. is there a way to actually elevate to root without sudo everygoddamthing?

You can su to root, but you have to set it up.

In general, this is a very bad idea. You shouldn't have to sudo every time either, it should save your credentials.
Logged

nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #10 on: July 21, 2008, 07:23:40 AM »

yea thats what I figured VS. when I sudo, it saves my password, but each command must still be sudo'd, which of course, being a noob, I keep screwing up. I didnt mean to permanently elevate, just for that session, which is what I thought su root would do. But it seems the mac has some magic password for the root user which I don't know about?

@jam. I don't see why it wouldnt work the same exact way. this is just the very base/core way of doing things. In this case, because there is no yum/apt/rpm really for mac.

though i did find something called ports. but havent even looked at that at all, and wont until this exercise is done.
Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 679



View Profile
« Reply #11 on: July 21, 2008, 08:43:04 AM »

Er yeah sorry, I meant you shouldn't have to type your password every time.

How often do you have to sudo though? It shouldn't be all that often.
Logged

nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #12 on: July 21, 2008, 08:48:55 AM »

it wont be that often I assume once I get all set up. Its just I am really not used to it is the main problem. Being a windows guy, I can lock the box down solid, and just be admin, and do whatever I need at any time without worrying about permissions. linux, not so much.

i obviously have to for compiling and installing. and that just happens to be what I am doing right now.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 5326


:sniffle: Humor was so much easier before.


View Profile
« Reply #13 on: July 21, 2008, 09:07:20 AM »

before I read the rest, the command you want is "sudo su" then enter your password and you're root.

It may be a bad idea, but it's where I spend virtually every minute in a shell.
Logged

If I can't be Mr. Root then I don't want to play.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 5326


:sniffle: Humor was so much easier before.


View Profile
« Reply #14 on: July 21, 2008, 09:19:48 AM »

ok i moved the old php, /usr/bin/php to /usr/bin/php-leopard
And I was planning on linking the new via
ln -s /usr/local/notsurehwhereitinstalled /usr/bin/php

so where did php get installed to, so I can link it? I assume that is what you meant by the quote above?
If you don't specify a path for the install of PHP it will go into /usr/local/bin - I leave that alone for all of my installs and that's why it had me crazy at first (since OS-X placed it in /usr/bin). You'll also need to move phpize, which is a little utility for preparing php add-ons in the future. You don't need to worry about that too much ATM, but move it out of the way just for good measure.

also, to just test if apache is running, shouldnt I be able to do http://localhost and at least a page not found or something? or is this literally a blank install, meaning not even localhost has a site?
After Apache has been installed, it will still not be running on it's own. Do a ps aux to see all the processes running on the machine. If you dont see about 5 lines that look like this:

daemon    9924  0.0  0.3 391468 13812 ?        S    Jul20   0:00 /usr/local/apache2/bin/httpd -k start


then it's not running. Go to /usr/local/apache2/bin (or perhaps it will be apache, but it will probably be apache2) In this directory is the apachectl exe, which is how everything is done. There are 3 basic Apache commands you should know:
apachectl start
apachectl stop
apachectl -k graceful

The last one is double extra important, because it allows you to "power cycle" apache, but gracefully ie., existing surfers will not be disturbed and new ones will get <the new configuration> of apache - this is most often used if you add a new virtual host or capability to your server.

So, if you apachectl start, hang for a second or two, then do a ps aux you should see your handler daemons running. THEN go to a browser and enter 127.0.0.1 and your should get Apache's default page.

And then the fun begins.

There are a couple things you'll need to configure in Apache before you are really ready and rearin' to go. change dirs to /usr/local/apache2/conf and edit httpd.conf. Read the whole thing. I know, it's horrible, but it will show you all of the standard configuration options available to you. You'll have questions after that, I'm pretty sure.

First exercise: Create a directory on your box - say, /www/sites/test (I personally do sites from a /www/sites dir - /www is the root for all things www) in that directory create a hello world file named "index.html" (simple HTML, just something simple). Your mission, should you choose to accept it, is to create a virtual host record in Apache that points to that directory. Make the test web site "www.helloworld.com" or something... you'll need to put a record in your hosts file (/etc/hosts) and add things to your httpd.conf that are not listed here. You will have questions. Wink

Good luck!

(I'm around today if you're really beyond Advil)

oh and have fun at steely dan. dont reminisce too hard  Devilish
Thanks - but it was surprisingly mediocre. I was expecting incredible sound, since at Cricket last year they were spectacular. This year was kind of a "B-side" tour ... perhaps 3 hits. The energy of the concert was rather static and I was bummed because I brought my 2 boys expecting them to hear more hits and famous stuff - they heard very little recognizeable stuff but were great sports. The years have been most unkind to Donald Fagen's voice, and Walter Becker was like a bump on a log. He sang murdered "Gaucho" ... it was somewhat pathetic. But, as usual, the players were top flight and the band was tight. Not horrible all-in-all, but not what I had wanted to see.  Undecided Thanks tho Wink
« Last Edit: July 21, 2008, 09:25:02 AM by perkiset » Logged

If I can't be Mr. Root then I don't want to play.
Pages: [1] 2 3 ... 7
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!