需要的源代码:apache mysql php
编译环境:
#yum grouplist //查看开发环境
1.源代码配置(安装目录,配置文件目录,可选选项)
2.编译
3.安装(放到指定的位置)上传包
一.mysaql绿色版安装配置
#tar zxvf mysql -C /usr/local //usr/local,一般额外软件安装位置
#cd /usr/local
#ln -s mysql mysql //做软链接,方便访问
#cd mysql
#ll //区分源代码还是绿色软件,一般无.config可执行脚本,即为绿色版
INSTALL-BINARY //安装指导
模板
# less INSTALL-BINARY
To install and use a MySQL binary distribution, the basic command
sequence looks like this:
shell> groupadd mysql
shell> useradd -r -g mysql mysql //-r创建系统账号,-M不创建账号家目录
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql //生产mysql数据库的原数据,数据库的初始化
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf //my-medium.cnf为mysql的配置
shell> bin/mysqld_safe --user=mysql & //运行mysql
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server //mysql服务的控制脚本,用service,chkconfig进行控制mysqld,相当于service httpd start 有/etc/init.d/httpd控制脚本,然后可用service进行控制
#groupadd mysql
……
#
注释:
#scripts/mysql_install_db --help //查看一些命令
修改环境变量的搜索路径,让mysql可在任意地方运行,环境变量的定义一共由四个文件来完成,系统两个,个人两个编辑系统的
#vim /etc/profile
45行输出路径 ,user ,logname,mail,hostname,histsize,inputrc
加一行 PATH=$PATH:/usr/local/mysql/bin
#. /etc/profile //让更改的环境变量生效
#echo $PATH //查看环境变量
#mysqld_safe --user=mysql &
#netstat -tupln |grep mysql
#cp
#chkconfig --add mysqld
#chkcongig --list |grep mysql
#vim /etc/init.d/mysqld //检查
完成部分
********************************************************************************************
#cd /usr/local/mysql
#ll
include //表示头文件,一般头文件放置位置:/usr/include(此为特别默认),/usr/local/include
lib //库文件,所谓库就是一个或多个系统的调用的构成,一般库遵循标准,默认位置:/lib/ /usr/lib/ /usr/local/lib/
要把mysql头文件非标准路径拷贝到默认路径下,或者建立链接,让系统可查找到
#cd /usr/include
#ln -s /usr/local/mysql/include mysql //对目录做链接
ldd查看某一个程序或指令需要依赖的库
#vim /etc/ld.so.conf //库文件的配置路径
#cd /etc/ld.so.conf.d/
#ll
#vim mysqld.conf
/usr/local/mysql/lib
mysql绿色版配置完成
********************************************************************************************
apache源码安装
#tar jxvf httpd -C /usr/local/src //一般源代码位置
#cd /usr/local/src/
#ls //configure表示为源代码
#./configure --help //./表示在当前目录下运行,./configure配置
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX //安装的目标目录
[/usr/local/apache2]默认安装位置
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify
an installation prefix other than `/usr/local/apache2' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR .conf(配置文件)位置 [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
Optional Features:可选特性--enable打开,--disable关闭
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-layout=LAYOUT
--enable-v4-mapped Allow IPv6 sockets to handle IPv4 connections
--enable-exception-hook Enable fatal exception hook
--enable-maintainer-mode
Turn on debugging and compile time warnings
--enable-pie Build httpd as a Position Independent Executable
--enable-modules=MODULE-LIST //把一些功能做成模块
Space-separated list of modules to enable | "all" |
"most"
--enable-mods-shared=MODULE-LIST //做成普通模块或者动态共享对象
aoache rpm包中做成动态共享对象dso
Space-separated list of shared modules to enable |
"all" | "most"
--disable-authn-file file-based authentication control
--enable-authn-dbm DBM-based authentication control
--enable-authn-anon anonymous user authentication control
--enable-authn-dbd SQL-based authentication control
--disable-authn-default authentication backstopper
--enable-authn-alias auth provider alias
--disable-authz-host host-based authorization control
--disable-authz-groupfile
'require group' authorization control
--disable-authz-user 'require user' authorization control
--enable-authz-dbm DBM-based authorization control
--enable-authz-owner 'require file-owner' authorization control
--enable-authnz-ldap LDAP based authentication
--disable-authz-default authorization control backstopper
--disable-auth-basic basic authentication
--enable-auth-digest RFC2617 Digest authentication
--enable-isapi isapi extension support
--enable-file-cache File cache
--enable-cache dynamic file caching
--enable-disk-cache disk caching module
--enable-mem-cache memory caching module
--enable-dbd Apache DBD Framework
--enable-bucketeer buckets manipulation filter
--enable-dumpio I/O dump filter
--enable-echo ECHO server
--enable-example example and demo module
--enable-case-filter example uppercase conversion filter
--enable-case-filter-in example uppercase conversion input filter
--enable-reqtimeout Limit time waiting for request from client
--enable-ext-filter external filter module
--disable-include Server Side Includes
--disable-filter Smart Filtering
--enable-substitute response content rewrite-like filtering
--disable-charset-lite character set translation
--enable-charset-lite character set translation
--enable-deflate Deflate transfer encoding support
--enable-ldap LDAP caching and connection pooling services
--disable-log-config logging configuration
--enable-log-forensic forensic logging
--enable-logio input and output logging
--disable-env clearing/setting of ENV vars
--enable-mime-magic automagically determining MIME type
--enable-cern-meta CERN-type meta files
--enable-expires Expires header control
--enable-headers HTTP header control
--enable-ident RFC 1413 identity check
--enable-usertrack user-session tracking
--enable-unique-id per-request unique ids
--disable-setenvif basing ENV vars on headers
--disable-version determining httpd version in config files
--enable-proxy Apache proxy module
--enable-proxy-connect Apache proxy CONNECT module
--enable-proxy-ftp Apache proxy FTP module
--enable-proxy-http //启用代理功能Apache proxy HTTP module
--enable-proxy-scgi Apache proxy SCGI module
--enable-proxy-ajp Apache proxy AJP module
--enable-proxy-balancer Apache proxy BALANCER module
--enable-ssl //启用ssl加密SSL/TLS support (mod_ssl)
--enable-distcache Select distcache support in mod_ssl
--enable-optional-hook-export
example optional hook exporter
--enable-optional-hook-import
example optional hook importer
--enable-optional-fn-import
example optional function importer
--enable-optional-fn-export
example optional function exporter
--enable-static-support Build a statically linked version of the support
binaries
--enable-static-htpasswd
Build a statically linked version of htpasswd
--enable-static-htdigest
Build a statically linked version of htdigest
--enable-static-rotatelogs
Build a statically linked version of rotatelogs
--enable-static-logresolve
Build a statically linked version of logresolve
--enable-static-htdbm Build a statically linked version of htdbm
--enable-static-ab Build a statically linked version of ab
--enable-static-checkgid
Build a statically linked version of checkgid
--enable-static-htcacheclean
Build a statically linked version of htcacheclean
--enable-static-httxt2dbm
Build a statically linked version of httxt2dbm
--enable-http HTTP protocol handling
--disable-mime mapping of file-extension to MIME
--enable-dav WebDAV protocol handling
--disable-status process/thread monitoring
--disable-autoindex directory listing
--disable-asis as-is filetypes
--enable-info server information
--enable-suexec set uid and gid for spawned processes
--disable-cgid CGI scripts
--enable-cgi CGI scripts
--disable-cgi CGI scripts
--enable-cgid CGI scripts
--enable-dav-fs DAV provider for the filesystem
--enable-dav-lock DAV provider for generic locking
--enable-vhost-alias mass virtual hosting module
--disable-negotiation content negotiation
--disable-dir directory request handling
--enable-imagemap server-side imagemaps
--disable-actions Action triggering on requests
--enable-speling correct common URL misspellings
--disable-userdir mapping of requests to user-specific directories
--disable-alias mapping of requests to different filesystem parts
--enable-rewrite //支持URL的重定向rule based URL manipulation
--enable-so //启用动态共享对象DSO capability
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-included-apr Use bundled copies of APR/APR-Util
--with-apr=PATH prefix for installed APR or the full path to
apr-config
--with-apr-util=PATH prefix for installed APU or the full path to
apu-config
--with-pcre=PATH Use external PCRE library
--with-port=PORT Port on which to listen (default is 80)
--with-sslport=SSLPORT Port on which to securelisten (default is 443)
--with-z=DIR //传递数据时可以使用zlib压缩,或者是调用zlib库use a specific zlib library
--with-sslc=DIR RSA SSL-C SSL/TLS toolkit
--with-ssl=DIR //指明ssl安装路径 OpenSSL SSL/TLS toolkit
默认openssl已经安装,不需要再指明路径
--with-mpm=MPM //多进程处理机制 Choose the process model for Apache to use.
MPM={beos|event|worker|prefork|mpmt_os2|winnt}
域派生机制
--with-module=module-type:module-file
Enable module-file in the modules/<module-type>
directory.
--with-program-name alternate executable name
--with-suexec-bin Path to suexec binary
--with-suexec-caller =daemon(用户名) User allowed to call SuExec
--with-suexec-userdir User subdirectory
--with-suexec-docroot SuExec root directory
--with-suexec-uidmin Minimal allowed UID
--with-suexec-gidmin Minimal allowed GID
--with-suexec-logfile Set the logfile
--with-suexec-safepath Set the safepath
--with-suexec-umask umask for suexec'd process
修改的选项:
--prefix=/usr/local/appache
--sysconfdir=/etc/httpd
--enable-so
--enable-ssl
--with-ssl=/usr/local/ssl //额外安装的ssl,可以不要
--enable-rewrite
--with-z
--enable-modes-shared=most
#make //编译,有错误会显示error
#make install //安装,把编译的二进制文件放到相应的位置
#cd /etc/httpd
#ll
#vim httpd.conf
ServerRoot "/usr/local/apache" 服务器的根位置,区别
Documen=Root "/usr/local/apache/htdocs" 基本站点主目录
#cd /usr/local/apache/htdocs/
#ll
#cd ..
#bin/apachectl start //启动apache
#netstat -tupln |grep httpd
#vim /etc/profile //修改环境变量
增加
PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin
#. /etc/profile //重新读取文件
#echo $PATH
#cd /etc/ld.so.conf.d/
#ll
#vim httpd.conf
/usr/local/apache/lib
#ldconfig -v //系统加载头文件
#ldconfig -v |grep mysql
#cd /usr/include/
#ln -s /usr/local/apache/include httpd
apache配置完成
********************************************************************************************
********************************************************************************************
PHP的安装编译
#tar jxvf php -C /usr/local/src
#cd /usr/local/src/php
#./configure
说明:
--prefix 表明PHP安装路径
--sysconfdir 表明配置文件的路径,由于PHP构成为HTTP的模块,因此不要此项
--with-apxs2 把PHP做成模块,指明调用者:/usr/local/apache/bin/apxs
注释:#cd /usr/local/apache/bin/apxs
修改的选项:
--prefix=/usr/local/php
--with-apxs2=/usr/local/appache/bin/apxs
将php编译成apache的模块,允许apache的apxx调用该模块
--with-mysql=/usr/local/mysql
指明mysql的安装位置
--with-mysqli=/usr/local/mysql/bin/mysql_config 调用mysql接口(php和mysql间的接口)
--enable-mbstring=all //支持多种字符集
--with-xml
--with-png
--with-jpeg
--with-zlib
--with-gd
--with-freetype
#make
//#make test 测试
#make install
#vim /etc/httpd/httpd.conf
53 LoadModule php5_module modules/libphp5.sc
#apachectl stop
#apachectl start //启动apache
站点主目录:
#cd /usr/local/apache/htdocs/
#mv index.html index.php
#vim index.php
<?php
phpinfo();
?>
#vim /etc/httpd/httpd.conf
309 AddType application/x-httpd-php .php 增加一行
处理httpd php 处理.php类型的文件
#apachectl stop
#apachectl start
************************************************************************************************