现在的位置: 首页 > 综合 > 正文

Solaris 10下架构MySQL + Apache + php 系统

2013年10月13日 ⁄ 综合 ⁄ 共 3797字 ⁄ 字号 评论关闭

本文介绍一下在solaris 10下安装使用MySQL + Apache + php

>安装MySQL
如果安装Solaris 10时候,选择了完全安装,那就已经安装好了MySQL。
如果没有安装的话,我们可以通过pkgadd命令安装,软件包是:SUNWmysqlr SUNWmysqlt SUNWmysqlu。
这三个软件包含在Solaris 10安装光盘中。都

>配置MySQL
在使用MySQL之前,我们还需要做一些配置。
#/usr/sfw/bin/mysql_install_db
初始化数据库

为MySQL创建用户和组
#groupadd mysql
#useradd -g mysql mysql
#chgrp -R mysql /var/mysql
#chmod -R 770 /var/mysql
将新建目录添加到软件包安装纪录中。
#installf SUNWmysqlr /var/mysql d 770 root mysql
配置mysql服务进程的配置文件,我们这里使用mysql提供的一个默认配置文件my-medium.cnf
#cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf
好了启动mysql
#/etc/sfw/mysql/mysql.server start
关闭mysql
#/usr/sfw/bin/mysqladmin shutdown

由于Solaris 10引入了SMF功能,一些服务程序都由SMF来控制托管。每个SMF托管服务程序都需要一个配置文件,
这边有一个例子供大家参考

我们将这个配置文件mysql.xml放到/var/svc/manifest/network目录中
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='cuddletech:mysql'>
<service name='application/mysql' type='service' version='4'>
<create_default_instance enabled='false'/>
<single_instance/>
<dependency name='fs-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<exec_method type='method' name='start' exec='/etc/sfw/mysql/mysql.server start' timeout_seconds='60' />
<exec_method type='method' name='stop' exec='/usr/sfw/bin/mysqladmin shutdown' timeout_seconds='60' />
<exec_method type='method' name='refresh' exec='/usr/sfw/bin/mysqladmin refresh' timeout_seconds='60' />
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>MySQL Server</loctext>
</common_name>
<documentation>
<doc_link name='mysql.org' uri='http://dev.mysql.com/doc/mysql/en/index.html' />
</documentation>
</template>
</service>
</service_bundle>

使用svccfg验证并倒入配置文件
#svccfg validate /var/svc/manifest/network/mysql.xml
#svccfg import /var/svc/manifest/network/mysql.xml

使用svcadm启动, 关闭mysql
#svcadm enable mysql
#svcadm disable mysql

>Apache
Solaris 10安装光盘中含有Apache 1.3.9和Apache 2.0。
安装好后还需要和安装php模块。我们下边以Apache 1.3.9为例。

>PHP
php的模块是SFWmphp,含在Solaris Companion CD。
我们可以免费从网上下载http://www.sun.com/software/solaris/freeware/

将php模块添加
#/opt/sfw/apache/x_postinstall
指定apache的配置文件
#cp /etc/apache/httpd.conf-php-example /etc/httpd.conf

同样我们可以使用SMF控制apache。这边有个Sun提供的配置文件:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Copyright 2004 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.

ident "@(#)http-apache.xml 1.2 04/11/11 SMI"
-->

<service_bundle type='manifest' name='SUNWapchr:apache'>

<service
name='network/http'
type='service'
version='1'>

<!--
Because we may have multiple instances of network/http
provided by different implementations, we keep dependencies
and methods within the instance.
-->

<instance name='apache' enabled='false'>
<dependency name='physical'
grouping='optional_all'
restart_on='error'
type='service'>
<service_fmri value='svc:/network/physical:default'/>
</dependency>

<exec_method
type='method'
name='start'
exec='/etc/init.d/apache start'
timeout_seconds='60' />

<exec_method
type='method'
name='stop'
exec='/etc/init.d/apache stop'
timeout_seconds='60' />

<exec_method
type='method'
name='refresh'
exec='/etc/init.d/apache restart'
timeout_seconds='60' />

<property_group name='httpd' type='application'>
<stability value='Evolving' />
<propval name='ssl' type='boolean' value='false' />
</property_group>

<property_group name='startd' type='framework'>
<!-- sub-process core dumps shouldn't restart
session -->
<propval name='ignore_error' type='astring'
value='core,signal' />
</property_group>

</instance>

<stability value='Evolving' />

<template>
<common_name>
<loctext xml:lang='C'>
Apache HTTP server
</loctext>
</common_name>
<documentation>
<manpage title='apache' section='1M' />
<doc_link name='apache.org'
uri='http://httpd.apache.org' />
</documentation>
</template>
</service>

</service_bundle>

把该文件保存到/var/svc/manifest/network/目录中,倒入到SMF。
# svccfg validate /var/svc/manifest/network/http-apache.xml
# svccfg import /var/svc/manifest/network/http-apache.xml  

抱歉!评论已关闭.