1、在VMware下安装CentOS(略)
2、若不能上网
2.1、将网络适配器改为“桥连模式(B):直接连接物理网络”
2.2、修改/etc/sysconfig/network-script/ifcfg-eth0文件,将onboot=no 改为onboot=yes
2.3、重启系统 ->reboot
3、使用XSell连接CentOS
3.1、最好在win下安装ssh客户端,这样可以直接copy脚本代码
3.2、查看CentOS的IP ->ifconfig
4、前期准备
4.1、安装make:yum -y install gcc gcc-c++ automake autoconf libtool make
4.2、安装wget(若未安装):yum -y install wget
4.3、编译安装pcre库:
4.3.1、在home目录下创建文件夹soft,用于存放下载的安装包:mkdir -p /home/soft
4.3.2、切换至该目录:cd /home/soft
4.3.3、下载安装包:wgethttp://ftp.exim.llorien.org/pcre/pcre-8.36.tar.gz
wgethttp://ftp.exim.llorien.org/pcre/pcre2-10.22.tar.gz
4.3.4、解压安装包:tar -zvxf pcre-8.36.tar.gz
4.3.5、切换至该目录:cd pcre-8.36
4.3.6、写入配置文件:./configure
4.3.7、编译:make
4.3.8、安装:make install
4.4、编译安装zlib库:
4.4.1、切换至安装包目录:cd /home/soft
4.4.2、下载安装包:wget http://zlib.net/zlib-1.2.10.tar.gz//如果提示找不到数据,就去http://zlib.net找最新的版本下载,官网会删除旧版本
http://zlib.net/zlib-1.2.10.tar.gz
4.4.3、解压安装包:tar -zvxf zlib-1.2.10.tar.gz
4.4.4、切换至该目录:cd zlib-1.2.10
4.4.5、写入配置文件:./configure
4.4.6、编译:make
4.4.7、安装:make install
4.5、下载openssl并安装openssl:
4.5.1、切换至安装包目录:cd /home/soft
4.5.2、下载安装包:wgethttp://www.openssl.org/source/openssl-1.0.1c.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
4.5.3、解压安装包:tar -zvxf openssl-1.0.1c.tar.gz,待会配置nginx用到
4.5.4、安装openssl:yum -y install openssl openssl-devel
5、安装nginx
5.1、切换至安装包目录:cd /home/soft
5.2、下载安装包:wgethttp://nginx.org/download/nginx-1.4.2.tar.gz提示不安全的话就换成wget --no-check-certificatehttp://nginx.org/download/nginx-1.4.2.tar.gz
最新版 wgethttp://nginx.org/download/nginx-1.9.9.tar.gz
5.3、解压安装包:tar -zvxf nginx-1.4.2.tar.gz
5.4、切换至该目录:cd nginx-1.4.2
5.5、写入配置文件(将nginx安装到/usr/local/nginx目录下):
./configure --sbin-path=/usr/local/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/home/soft/pcre2-10.22\
--with-openssl=/home/soft/openssl-1.0.1c
--with-zlib=/home/soft/zlib-1.2.10 \
./configure --sbin-path=/usr/local/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-pcre=/home/soft/pcre2-10.22\
5.6、编译:make
5.7、安装:make install
5.8、启动nginx:/usr/local/nginx/nginx
5.9、关闭防火墙:
5.9.1、临时(重启失效):service iptables stop
5.9.2、永久:chkconfig iptables off
5.10、检测是否已正确安装:访问CentOS的IP显示Welcome to nginx即安装成功!
6、安装php-fpm
6.1、前期安装一堆类库:
yum -y install mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel \
bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel \
e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn \
libidn-devel openssl openssl-devel
6.2、安装mcrypt:
6.2.1、切换至安装包目录:cd /home/soft
6.2.2、下载安装包:wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz(点击下载)
6.2.3、解压安装包:tar -vxf libmcrypt-2.5.7.tar.gz
6.2.4、切换至该目录:cd libmcrypt-2.5.7
6.2.5、写入配置文件(将mcrypt安装到/usr/local目录下):./configure --prefix=/usr/local
6.2.6、编译:make
6.2.7、安装:make install
6.3、安装php-fpm:
6.3.1、切换至安装包目录:cd /home/soft
6.3.2、下载安装包:wget http://museum.php.net/php5/php-5.4.7.tar.gz
6.3.3、解压安装包:tar -zvxf php-5.4.7.tar.gz
6.3.4、切换至该目录:cd php-5.4.7
6.3.5、写入配置文件(将php安装到/usr/local/php目录下):
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug \
--disable-rpath --enable-inline-optimization --with-bz2 --with-zlib \
--enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl \
--enable-mbregex --with-mhash --enable-zip --with-pcre-regex \
--with-mysql --with-mysqli --with-gd --with-jpeg-dir
6.3.6、编译:make
6.3.7、安装:make install
6.4、修改nginx配置文件:
6.4.1、修改nginx.conf配置文件:vi /usr/local/nginx/nginx.conf
//找到该配置信息
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
# include fastcgi_params;
#}
//去掉注释,并将"/script" 改为 "$document_root"
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
6.5、配置php-fpm文件:
6.5.1、切换至php目录:cd /usr/local/php/etc
6.5.2、复制一个配置信息:cp php-fpm.conf.default php-fpm.conf
7、重启nginx并启动php-fpm
7.1、重启nginx:/usr/local/nginx/nginx -s reload
7.2、启动php-fpm:/usr/local/php/sbin/php-fpm
8、测试是否安装正确
8.1、编写测试文件:vi /usr/local/nginx/html/index.php
8.2、写入:
8.3、访问http://CentOS的IP/index.php,出现php信息即正确安装
9、为nginx和php-fpm添加系统服务