rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 应用技术 » Web服务器

Linux+Apache+Php+Mysql完整配置方案

这个不同于网上转的文章,因为这是我自己配好并整理出来的.
我是在Centos5.2的平台上配置的. 方法如下:
先要安装Centos5.2,这里我们用最小化安装,关于怎么最小化安装我就不说了,网上资料一大把.
安装好了后要先把Yum服务配置改一下.这样才能更快的在线安装一些服务,如何配置我在前面文章有说过的

(1).先升级Yum服务器cd /etc/yum.repos.d        //这句话是指进入yum的配置目录
rm CentOS-Base.repo     //删除原先的配置文件
vi CentOS-Base.repo    //重新建立这个文件并写入如下内容 (2).把下面的这些语句写入CentOS-Base.repo这个文件 # CentOS-Base.repo # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.   You should use this for CentOS updates
# unless you are manually picking other mirrors. # If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead. #
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://centos.ustc.edu.cn/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://centos.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 保存后,最好重启一下
你的服务器yum就配置好了,你可以试试yum -y install 'services'试试. (这里面的services写入你想要装的服务,比如httpd即代表WEB服务器)

1. 升级完Yum配置后就可以升级装LAMP所需要的服务了,当然也可以Make Install,但是我觉得这种小的东东直接在线安装比较快,因为
要装的小东东也多. yum -y install wget ntsysv setuptool ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel 2. 手动安装GD2.LibXML2.LibMcrypt常用组件 (1) GD2 cd /usr/src
tar xzvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd2
make && make install (2) LibXML2 cd /usr/src
tar xzvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make && make install (3) LibMcrypt cd /usr/src
tar xzvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make && make install 3. 安装MYSQL数据库,版本我是51.33的版本.这个自己选择了. cd /usr/src
tar xzvf mysql-5.1.33.tar.gz
cd mysql-5.1.33
./configure \
"--prefix=/usr/local/mysql" \
"--localstatedir=/data/mysql/data" \
"--with-comment=Source" \
"--with-server-suffix=-LinuxTone" \
"--with-mysqld-user=mysql" \
"--without-debug" \
"--with-big-tables" \
"--with-charset=gbk" \
"--with-collation=gbk_chinese_ci" \
"--with-extra-charsets=all" \
"--with-pthread" \
"--enable-static" \
"--enable-thread-safe-client" \
"--with-client-ldflags=-all-static" \
"--with-mysqld-ldflags=-all-static" \
"--enable-assembler" \
"--without-isam" \
"--without-innodb" \
"--without-ndb-debug"
make && make install
useradd mysql -d /data/mysql -s /sbin/nologin
/usr/local/mysql/bin/mysql_install_db --user=mysql
cd /usr/local/mysql
chown -R root:mysql .
chown -R mysql /data/mysql/data
cp share/mysql/my-huge.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld 注意一点:MYSQL启动不了只要将/etc/my.cnf里面的 skip federated注释掉即可。 /etc/rc.d/init.d/mysqld start   Mysql现在就在运行中了 4. 编译安装Apache cd /usr/src
tar xzvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure \
"--prefix=/usr/local/apache2" \
"--with-included-apr" \
"--enable-so" \
"--enable-deflate=shared" \
"--enable-expires=shared" \
"--enable-rewrite=shared" \
"--enable-static-support" \
"--disable-userdir"
make && make install
echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local   这是设置开机自启动 5. 编译安装PHP,我用的是PHP5.2.5版本 cd /usr/src
tar xjvf php-5.2.5.tar.bz2
cd php-5.2.5
./configure \
"--prefix=/usr/local/php" \
"--with-apxs2=/usr/local/apache2/bin/apxs" \
"--with-config-file-path=/etc" \
"--with-mysql=/usr/local/mysql" \
"--with-libxml-dir=/usr/local/libxml2" \
"--with-gd=/usr/local/gd2" \
"--with-jpeg-dir" \
"--with-png-dir" \
"--with-bz2" \
"--with-freetype-dir" \
"--with-iconv-dir" \
"--with-zlib-dir " \
"--with-mcrypt=/usr/local/libmcrypt" \
"--enable-soap" \
"--enable-gd-native-ttf" \
"--enable-memory-limit" \
"--enable-ftp" \
"--enable-mbstring" \
"--enable-exif" \
"--disable-ipv6" \
"--disable-cgi" \
"--disable-cli"
make && make install 6. 安装好还要配置让Apache支持PHP文件,配置如下: cp php.ini-dist /etc/php.ini
vi /usr/local/apache2/conf/httpd.conf AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php 7. 安装Zend Optimizer ,这个是PHP加速的组件,好多PHP程序都要求它的支持,一定要装. cd /usr/src
tar xzvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.3.0a-linux-glibc21-i386
./install.sh 8. 安装eaccelerator,这个可装可不装,PHP缓存应用,装上后对服务器优化起到不错的用处.中大型网站还是装上. cd /usr/src
tar xf eaccelerator-0.9.5.3.tar.tar
cd eaccelerator-0.9.5.3
export PHP_PREFIX="/usr/local/php"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make && make install
cp modules/eaccelerator.so /etc
cd /
mkdir -p /data/eaccelerator
chmod -R 777 /data/eaccelerator
cd /etc
vi php.ini
在PHP.ini里面添加如下内容并保存.
[eaccelerator]
extension="/etc/eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/data/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9" 到这里,我们的LAMP的环境就架设好了,因为是完全编译出来的,所以会费些时间.

顶一下
(0)
踩一下
(0)