1. 云栖社区>
  2. PHP教程>
  3. 正文

CentOS Nginx PHP MySQL Memcached 安装 配置 优化

作者:用户 来源:互联网 时间:2017-12-01 15:03:33

mysqlphp安装centosnginx优化memcached配置

CentOS Nginx PHP MySQL Memcached 安装 配置 优化 - 摘要: 本文讲的是CentOS Nginx PHP MySQL Memcached 安装 配置 优化, http://www.phpplay.com/thread-118293-1-1.html     按照版本Nginx 0.8.52 PHP 5.3.3MySQL 5.5.6 Memcached一、安装centos这个比较容易,安装过程可


http://www.phpplay.com/thread-118293-1-1.html


 


 


按照版本
Nginx 0.8.52 PHP 5.3.3
MySQL 5.5.6 Memcached
一、安装centos
这个比较容易,安装过程可以在如下几个帖子中找到。


centos安装过程全记录 虚拟机安装配置

http://www.phpplay.com/thread-118283-1-1.html


CentOs按照过程全记录 (二) 添加sudo用户

  http://www.phpplay.com/thread-118286-1-1.html


Centos安装全记录(三)用OpenSSH构建SSH服务器

   http://www.phpplay.com/thread-118287-1-1.html
二、准备篇
2.1 修改CentOS的yum源


vi /etc/yum.repos.d/CentOS-Base.repo
复制代码

为了加快速度,我们采用网易的源地址,文件内容参照以下修改:变颜色的为需要修改的地方
1. # CentOS-Base.repo
2. #
3. # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
4. # The mirror system uses the connecting IP address of the client and the
5. # update status of each mirror to pick mirrors that are updated to and
6. # geographically close to the client. You should use this for CentOS updates
7. # unless you are manually picking other mirrors.
8. #
9. # If the mirrorlist= does not work for you, as a fall back you can try the
10. # remarked out baseurl= line instead.
11. #
12. #
13. [base]
14. name=CentOS-$releasever - Base
15. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
16. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
17.baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
18. gpgcheck=1
19. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
20. #released updates
21. [updates]
22. name=CentOS-$releasever - Updates
23. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
24. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
25.baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
26. gpgcheck=1
27. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
28. #packages used/produced in the build but not released
29. [addons]
vi /etc/yum.repos.d/CentOS-Base.repo
30. name=CentOS-$releasever - Addons
31. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
32. #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
33.baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
34. gpgcheck=1
35. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
36. #additional packages that may be useful
37. [extras]
38. name=CentOS-$releasever - Extras
39. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
40. #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
41.baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
42. gpgcheck=1
43. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
44. #additional packages that extend functionality of existing packages
45. [centosplus]
46. name=CentOS-$releasever - Plus
47. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
48. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
49.baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
50. gpgcheck=1
51. enabled=0
52. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
2.2更新yum


yum -y update
复制代码

2.3使用yum更新所需要的程序库


sudo -s
复制代码

安装libevent,memcached需要


yum -y install libevent libevent-devel
复制代码

三、下载所需文件
说明:使用wget将下载的程序统一放到路径 /usr/src/ 下面。原文地址已经有些过期,这里更新为最新的。


cd /usr/src/
wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget http://cn.php.net/get/php-5.3.3.tar.gz/from/this/mirror
#wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz/from/http://mysql.he.net/
wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.2-m2-linux-i686-glibc23.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?use_mirror=ncu
wget http://downloads.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.tar.gz?use_mirror=ncu
#wget http://downloads.sourceforge.net/project/imagemagick/ImageMagick/00-6.6.5/ImageMagick-6.6.5-0.tar.gz?use_mirror=ncu
wget http://sourceforge.net/projects/imagemagick/files/6.7.7-sources/ImageMagick-6.7.7-5.tar.gz/download
wget http://pecl.php.net/get/APC-3.1.4.tgz
wget http://pecl.php.net/get/memcache-2.2.6.tg
wget http://pecl.php.net/get/imagick-3.0.1RC2.tgz
复制代码

三、安装篇
1. 安装libiconv


cd /usr/src/tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
复制代码

2. 修改动态链接载入的目录查找文件


vi /etc/ld.so.conf复制代码

在文件最后添加一行内容/usr/local/lib,然后运行以下命令


/sbin/ldconfig
复制代码

3. 安装libmcrypt


tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../复制代码

4. 安装mhash


tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config复制代码

5. 安装mcrypt


tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../复制代码

6. 安装memcached


tar xvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local/memcached
make
make install
cd ../复制代码

7. 安装pcre


tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make
make install
cd ../复制代码

8. 安装Nginx


/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
tar zxvf nginx-0.8.52.tar.gz
cd nginx-0.8.52/
./configure --user=www --group=www
--prefix=/usr/local/nginx
--with-http_stub_status_module
--with-http_ssl_module
make
make install
cd ../复制代码

9. 安装PHP


tar zxvf php-5.3.3.tar.gz
cd php-5.3.3
./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc
--with-curl --with-curlwrappers
--with-freetype-dir
--with-jpeg-dir --with-png-dir
--with-gd --enable-gd-native-ttf
--with-iconv-dir=/usr/local/libiconv
--with-libxml-dir=/usr/local
--with-mhash --with-mcrypt
--with-mysql=mysqlnd --with-mysqli=mysqlnd
--with-openssl
--with-xmlrpc
--with-zlib
--disable-debug --disable-rpath
--enable-bcmath
--enable-fpm
--enable-inline-optimization
--enable-mbregex
--enable-mbstring
--enable-pcntl
--enable-safe-mode
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvsem
--enable-xml
--enable-zip
--with-libdir=lib64 ←64位操作系统需要添加此项,否则去除此项
--without-pear
make ZEND_EXTRA_LIBS='-liconv'
make install
cp ./php.ini-production /usr/local/php/etc/php.ini
cd ../复制代码

10. 安装ImageMagick


tar zxvf ImageMagick-6.6.5-0.tar.gz
cd ImageMagick-6.6.5-0/
./configure
make
make install
cd ../
复制代码

11. 安装PHP扩展imagick


tar zxvf imagick-3.0.1RC2.tgz
cd imagick-3.0.1RC2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
复制代码

12. 安装PHP扩展memcache


tar zxvf memcache-2.2.6.tgz
cd memcache-2.2.6/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
复制代码

13. 安装PHP扩展APC


tar zxvf APC-3.1.4.tgz
cd APC-3.1.4/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
复制代码

14. 安装MySQL


/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar xvf mysql-5.5.6-rc.tar.gz
cd mysql-5.5.6-rc/
./configure --prefix=/usr/local/mysql/
--with-unix-socket-path=/tmp/mysql.sock
--with-big-tables
--with-charset=utf8
--with-collation=utf8_general_ci
--with-extra-charsets=gbk,gb2312,utf8
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
--with-plugins=partition,innobase,myisammrg
--with-pthread
--with-readline
--without-debug
--without-isam
--enable-assembler
--enable-local-infile
--enable-thread-safe-client
make
make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
cd ../
复制代码

全部安装的过程已经结束,下一篇结束配置。

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索mysql , php , 安装 , centos , nginx , 优化 , memcached 配置 ,以便于您获取更多的相关知识。

弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率

40+云计算产品,6个月免费体验

稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一

云服务器9.9元/月,大学必备