Apache2 and MySQL5 on Boot (LaunchDaemons)

Ryan Schmidt ryandesign at macports.org
Fri Jun 8 13:48:20 PDT 2007


On Jun 8, 2007, at 08:49, aucwe wrote:

> I have some trouble with the LaunchDaemons of Apache2 and Mysql5.
>
> I did install Apache2, PHP5 and Mysql5 using macports (newest version)
> on a PPC-MacMini:
>
> sudo port sync
> sudo port install apache2
> sudo port install mysql5 +server
> sudo port install php5 +apache2 +mysql5 +pear
>
> then I did:
>
> sudo launchctl load -w /Library/LaunchDaemons/ 
> org.macports.apache2.plist
> sudo launchctl load -w /Library/LaunchDaemons/ 
> org.macports.mysql5.plist
>
> After that both mysql5 and apache2 started on boot or reboot. So the
> macports standard installation works fine.
>
> In a further step I copied (using rsync) the directories
> /opt/local/apache2/htdocs  and /opt/local/var/db/mysql5 to another
> partition of my harddrive.
> And of course modified the config files properly.
>
> After theses steps both LaunchDaemons dosen't work anymore. But I can
> start both applications on the command line (mysqld_safe, apachectl)
> using the non standard configuration.
>
> Further I tried to start mysql using the wrapper script:
> sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/ 
> mysql5.wrapper start
> an got the message
> Starting MySQL ERROR! Couldn't find MySQL manager or server.
> (Is there a mysql error_log file? I couln't find any!)
>
> In case of apache2 I can start an stop apache2 using the wrapper  
> script
> on the command line:
> sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/ 
> apache2.wrapper start
> sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/ 
> apache2.wrapper stop
> but it does not work on boot time (the apache2 error_log shows a  
> sigterm
> shutting down entry)
>
> When I go back to the macports standard installation everthing  
> works fine.


You did not specify how you "modified the config files properly."  
Here's how I did it:


I am using mysql5 with the databases stored elsewhere. To set this  
up, I have a file /opt/local/etc/mysql5/my.cnf which contains this:

[mysqld]
skip-networking
pid-file=/opt/local/var/run/mysql5/mysqld.pid
log-error=/opt/local/var/log/mysql5/mysqld.err
log-slow-queries=/opt/local/var/log/mysql5/slow_queries.log
datadir=/Users/rschmidt/mysql/data
bind-address=127.0.0.1
lower_case_table_names=2
old_passwords=1
default-table-type=InnoDB
query_cache_size=32M

So I have set it up to find the databases in my home directory, and I  
have told it where to write its log files. Since I only connect to  
the server from this same machine, I turn off networking support both  
to save memory and for security. Lowercase table names 2 is  
recommended for Mac OS X and other systems with case-insensitive  
filesystems. Old passwords were needed by me at some point because I  
was still using older MySQL client libraries but I should probably  
remove that now. I like new tables to be InnoDB, and apparently I  
wanted to set the query cache size for some reason.

I did not move /opt/local/var/db/mysql5; instead, I just set up a new  
directory for the databases elsewhere.


As to Apache, you have to inform it about each directory which you  
want it to be able to serve. I did not move /opt/local/apache2/htdocs  
anywhere, since it does not contain anything I care about. I just set  
up a new directory /web/ and told Apache about it, like this:

<Directory /web>
	# Possible values for the Options directive are "None", "All",
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI  
MultiViews
#	Options Indexes FollowSymLinks
	AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

I'm not sure why I have the Options directive commented out there.

The Apache error log should contain useful information if Apache  
won't start. By default it's located at /opt/local/apache2/logs/ 
error_log though you can change it with the Error_Log directive in  
the config file if you want.





More information about the macports-users mailing list