linux下apache、mysql、php安装配置详细笔记

软件准备:
mysql-5.0.56.tar.gz
http://dev.mysql.com/get/downloads/

httpd-2.2.12.tar.gz

php-5.3.0.tar.gz

一、安装mysql

复制代码 代码如下:

groupadd mysql                               #添加一个mysql组

useradd -g mysql mysql                       #添加一个用户到mysql组中

tar zxvf mysql-5.0.56.tar.gz

cd mysql-5.0.56

cat readme | less                            #查看使用文档

cat install-source | less                    #查看安装说明

./configure –help                           #查看配置帮助

./configure –prefix=/usr/local/mysql5 –enable-thread-safe-client –with-charset=utf8 

                                             #set:设置安装目录,客户端支持线程,设置字体为utf8

                                             #–enable-thread-safe-client 若不开启,编译php时会遇到问题

make                                         #编译

make install                                 #安装

cp support-files/my-medium.cnf /etc/my.cnf   #拷贝默认配置文件

scripts/mysql_install_db –user=mysql        #初始化:一定是解压编译后的目录中才有mysql_install_db文件.

cd /usr/local/mysql                          #进入安装目录

chown -r root  .                             #给mysql5目录赋予root权限.

chown -r mysql var                           #给var目录赋予mysql权限

chgrp -r mysql .                             #给mysql5目录赋予mysql组权限

bin/mysqld_safe –user=mysql &               #启动mysql服务.

bin/mysql                                    #进入mysql操作

mysql> grant all on *.* to root@’192.168.%’ identified by ‘password’;   #设置root可管理的网段及密码

mysql> flush privileges;                                                #刷新生效.

ps: 大家可以自行修改my.cnf文件来优化mysql

二、安装apache

复制代码 代码如下:

tar zxvf httpd-2.2.12.tar.gz

cd httpd-2.2.12

vi server/mpm/worker/worker.c                #修改源文件连接数

#define default_server_limit 16              #默认子进程数

#define max_server_limit 20000               #最大子进程数

#define default_thread_limit 64              #默认链接线程数

#define max_thread_limit 20000               #最大链接线程数

####以上配置可根据自己的服务器配置修改默认值的大小.

cat readme | less                            #查看使用文档

cat install | less                           #查看安装说明

./configure –help                           #查看配置帮助

./configure \

–prefix=/usr/local/apache2 \

–enable-module=’most’                       #装一些默认常用的

–enable-mods-shared=”all”                   #全部共享.

–enable-file-cache                          #文件缓存.

–enable-cache                               #缓存

–enable-disk-cache                          #硬盘缓存

–enable-mem-cache                           #内存缓存

–enable-headers                             #http头控制模块

–enable-expires                             #过期头控制模块

–enable-proxy                               #apache代理模块

–enable-proxy-balancer                      #apache代理均衡模块

–enable-ssl                                 #https

–enable-rewrite                             #rewrite

–enable-so                                  #兼容性

–with-mpm=worker

make                                    #编译

make install                        #安装

三、安装php扩展lib库

复制代码 代码如下:

gd-2.0.35.tar.gz

jpegsrc.v7.tar.gz

libpng-1.4.0beta73.tar.gz

libxml2-sources-2.7.3.tar.gz

libxslt-1.1.24.tar.gz

zlib-1.2.3.tar.gz                            #直接./configure && make && make install 即可  默认lib目录安装都在 /usr/local/lib 下.

四、安装php

复制代码 代码如下:

tar zxvf php-5.3.0.tar.gz

cd php-5.3.0

cat readme | less                            #查看使用文档

cat install | less                           #查看安装说明

./configure –help                           #查看配置帮助

./configure \

–prefix=/usr/local/php5 \

–with-apxs2=/usr/local/apache2/bin/apxs \   #你的apache安装路径apxs是一个apache安装配置时生成的一个小小的perl脚本。它可以使象resin这种模块获得apache所有的配置路径。

–with-mysql=/usr/local/mysql5 \             #mysql安装路径

–enable-ftp \                               #开启ftp模块

–enable-debug \                             #开启debug

–enable-mbstring \                          #打开mbstring

–enable-mbregex \                           #正则

–with-gd=/usr/local \                       #gd库

–with-png-dir=/usr/local/lib \              #png

–with-zlib-dir=/usr/local/lib \             #zlib

–with-jpeg-dir=/usr/local/lib \             #jpeg

–enable-libxml \

–with-libxml-dir=/usr/local/lib \           #libxml扩展

#–with-xsl=/usr/local/lib \                  #xslt扩展

–enable-pdo \

–with-pdo-sqlite \

–with-pdo-mysql=/usr/local/mysql5/bin/mysql_config \         #pdo

–enable-soap \                              #soap服务扩展

–enable-sockets \                           #sockets扩展

–with-xmlrpc                                #xmlrpc扩展

–with-config-file-path=/etc                 #设置php.ini存放位置

./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql5

–enable-ftp –enable-debug –enable-mbstring –enable-mbregex –with-gd=/usr/local

–with-png-dir=/usr/local/lib –with-zlib-dir=/usr/local/lib –with-jpeg-dir=/usr/local/lib

–enable-libxml –with-libxml-dir=/usr/local/lib –enable-pdo –with-pdo-sqlite

–with-pdo-mysql=/usr/local/mysql5/bin/mysql_config –enable-soap

–enable-sockets –with-xmlrp

make

make install

配置apache和php、mysql启动
自动启动mysql

复制代码 代码如下:

cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld

ln -s /etc/init.d/mysqld /etc/rc3.d/kmysqld

ln -s /etc/init.d/mysqld /etc/rc3.d/smysqld

service mysqld start

/usr/local/apache2/bin/apachectl start

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐