软件包准备
文中所涉及到的所有安装包,都已经打包上传优快云,点击下载
nginx-1.0.15.tar.gz
php-5.2.17.tar.gz
php-5.2.17-fpm-0.5.14.diff.gz
mysql-5.1.35.tar.gz
libiconv-1.13.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
memcache-2.2.5.tgz
mhash-0.9.9.9.tar.gz
eaccelerator-0.9.5.3.tar.bz2
PDO_MYSQL-1.0.2.tgz
ImageMagick-6.7.5-10.tar.gz
imagick-2.2.2.tgz
gd-2.0.33.tar.gz
jpegsrc.v8b.tar.gz
libpng-1.6.10.tar.xz
ncurses-5.9.tar.gz
openssl-1.0.0l.tar.gz
安装PHP支持库
安装libiconv
对文本进行编码间的转换,用它来处理中文各种编码之间的转换。tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local #这个路径很重要
make
make install
cd ../
安装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 ..
安装mhash
(哈稀函数库)
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
安装mcrypt
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
建立链接
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
安装GD库
安装zlib.
这个linux系统一般都有,可以不用安装.可以用以下命令查看
rpm -qa | grep zlib
安装libpng
tar zxvf libpng-1.6.10.tar.tar
cd libpng-1.6.10
./configure
make
make install
安装freetype
tar zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure
make
make install
安装Jpeg
tar zxvf jpegsrc.v8b.tar.gz
cd jpeg-8b/
./configure --enable-shared
make
make test
make install
安装GD库
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd2 --with-png --with-freetype --with-jpeg #注意: 安装路径的指定很重要,后面要使用
make
make install
安装Openssl
fedora20已经默认安装了openssl,但是它的路径是分散的,而在后面的php的安装或者mysql的安装中,经常因为openssl找不到而失败,因此需要重新安装以下openssl
tar zxvf openssl-1.0.0l.tar.gz
cd openssl-1.0.0l/
./configure --prefix=/usr/local/openssl #这个路径在后面将会经常用到
make && make install
在安装时如果出现如下错误:POD document had syntax errors at /usr/bin/pod2man line 69. make .那么,解决反感如下:
rm /usr/bin/pod2man
安装Mysql
fedora20里面已经默认集成了MariaDB,但是在实际使用起来与原来的Mysql有一点区别,不太习惯,于是想要换成Mysql
但是,并不能直接安装Mysql,需要先卸载MariaDB.
首先利用以下命令找到本机安装的所有MariaDB
rpm -qa | grep -i mariadb
根据列出来的所有的包的名称,逐个使用以下命令
rpm -e [package name] --nodeps
安装mysql依赖项
tar zxvf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure
make
make install
随后建立mysql组,并添加用户mysql
groupadd mysql
useradd mysql -g mysql
开始安装
tar zxvf mysql-5.1.35.tar.gz
cd mysql-5.1.35
./configure --prefix=/usr/local/mysql
--without-debug
--with-extra-charsets=gbk
--with-extra-charsets=all
--enable-assembler
--with-pthread
--enable-thread-safe-client
--with-mysqld-ldflags=-all-static /*不带共享库的形式编译mysqld*/
--with-client-ldflags=-all-static
--with-big-tables
--with-readline /*要采用rpm方式安装ncurses或tar包安装*/
--with-ssl /*要采用rpm方式安装openssl*//*注意,若编译中关于SSL报错,请将此句修改为: --with-ssl=/usr/local/openssl*/
--with-embedded-server
--enable-local-infile
--with-plugins=innobase
make && make install
配置Mysql数据库
/usr/local/mysql/bin/mysql_install_db --user=mysql
#以mysql身份初始化数据库
cp ./support-files/mysql.server /etc/init.d/mysql
#复制Mysql启动服务至系统
cp ./support-files/my-medium.cnf /etc/my.cnf
chmod 755 /etc/init.d/mysql
cd /usr/local/mysql/ #切换到cd /usr/local/mysql/目录下
chown -R mysql . #改变当前目录下的所有者为mysql用户
chown -R mysql var #修改数据库目录的权限
chgrp -R mysql . #改变当前目录下的mysql用户的文件为mysql组
/usr/local/mysql/bin/mysqld_safe --user=mysql&
/usr/local/mysql/bin/mysqladmin -u root password 'admin' #设置管理员密码
/usr/local/mysql/bin/mysql -u root -p #测试密码输入
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.35-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \q /*退出mysql*/
chkconfig --add mysql #添加mysqld服务到系统
chkconfig mysql on #打开myslqd服务
service mysql start #启动Mysql
/usr/local/mysql/bin/mysqladmin shutdown #关闭数据库
#查看mysql端口的打开情况
netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/P name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2936/
#查看是否启动:
ps -ef | grep mysql
注意:
如果在安装中有do_abi_check的报错,那是因为mysql的bug,mysql 5.1.14以上版本跟gcc 4.5不太兼容导致的
解决办法:configure完成之后,编辑Makefile,查找do_abi_check: 将do_abi_check: 后到done 都删除,保存.(注意do_abi_check:需要保留). 随后开始make && make install
安装PHP
因为默认情况下Nginx和PHP他俩之间是一点感觉没有的。在之前搭建过Apache+PHP,Apache+PHP编译后生成的是 模块文件,而Nginx+PHP需要PHP生成可执行文件才可以,所以要利用fastcgi技术来实现Nginx与PHP的整合,这个只要我们安装时启用 FastCGI即可。此次我们安装PHP不仅使用了FastCGI,而且还使用了PHP-FPM这么一个东东,PHP-FPM说白了是一个管理 FastCGI的一个管理器,它作为PHP的插件存在,在安装PHP时要想使用PHP-FPM就需要把PHP-FPM以补丁的形式安装到PHP中,而且 PHP要与PHP-FPM版本一致,这是必须的,切记!
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.11.diff.gz | patch -d php-5.2.17 -p1
curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
cd php-5.2.17
patch -p0 -b <../php-5.2.17.patch
编译PHP
./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-iconv-dir=/usr/local
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-gd=/usr/local/gd2 #这个路径也必须手动指定,不然找不到GD库
--enable-gd-native-ttf
--with-libxml-dir=/usr
--enable-xml
--disable-rpath
--enable-discard-path
--enable-safe-mode
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--with-curl
--with-curlwrappers
--enable-mbregex
--enable-fastcgi
--enable-fpm
--enable-force-cgi-redirect
--enable-mbstring
--with-mcrypt
--with-openssl=/usr/local/openssl #这里的路径很重要,必须指定,不然后面的make会失败
--with-mhash
--enable-pcntl
--enable-sockets
--with-ldap
--with-ldap-sasl
--with-xmlrpc
--enable-zip
--enable-soap
--without-pear
注:Nginx+PHP整合,在安装时必须启用-–enable-fastcgi和--enable-fpm,这两个选项是做什么的上面已经描述。执行完后系统会提示-–enable-fastcgi是一个未知选项,我们不必理会。
错误解决:
若出现CONFIGURE: ERROR: XML2-CONFIG NOT FOUND. PLEASE CHECK YOUR LIBXML2 INSTALLATION.错误,那么,是因为libxml2-dev没有安装. 直接安装即可:
yum install libxml2-dev
若出现Cannot find ldap.h错误,是因为openldap或者openldap-dev没有安装,先安装即可
yum install openldap
yum install openldap-devel
开始安装
#注:make的时候一定要加上后面的参数,才能成功。
make ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
注意,如果在make test中出现 invalid PHP executable specified by TEST_PHP_EXECUTABLE错误,这个可以直接忽略,直接开始make install
如果在make test中出现error while loading shared libraries: libssl.so.的错误,那是因为找不到openssl的库文件.这个文件存在于/usr/local/openssl/lib/内.
解决方案: 在/etc/ld.so.conf.d/目录下新建任何以.conf为后缀的文件,在该文件中加入库文件所在的目录;运行ldconfig,以更新/etc/ld.so.cache文件;
安装PHP扩展模块
安装memcache
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..
安装eaccelerator php加速
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
安装PDO_MYSQL(数据库连接的支持)
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
cd ../
安装ImageMagick
ImageMagick是Linux下非常强大的图象处理函数与GD类似.
记住不可安装 ImageMagick-6.5.1-2版本,据说是因为 It compiles against Zlib 1.2.6,所以在make的时候会出错.详见这里http://www.imagemagick.org/discourse-server/viewtopic.php?t=20267
tar zxvf ImageMagick-6.7.5-10.tar.gz
cd ImageMagick-6.7.5-10/
./configure --prefix=/usr/local/ImageMagick #记住这个路径指定很重要
make
make install
cd ../
安装imagick
连接PHP和ImageMagick的通道
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/ImageMagick
make
make install
cd ../
修改php.ini文件,已使php支持扩展的功能
vi /usr/local/php/etc/php.ini
#查找
extension_dir = "./"
#修改为
extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
#并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
#再查找output_buffering = Off
#修改为output_buffering = On
配置eAccelerator加速PHP
mkdir -p /usr/local/eaccelerator_cache
vi /usr/local/php/etc/php.ini
到配置文件的最末尾,粘上以下内容:
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
PHP-fpm配置
创建php-fpm配置文件
php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi:在/usr/local/php/etc/目录中创建php-fpm.conf文件,也可以在原有的基础上进行修改。
如果您安装 Nginx + PHP 用于程序调试
请将以下的
<value name="display_errors">0</value>改为
<value name="display_errors">1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页。
说明:创建www用户与组,这里创建了下面就不用创建了。
/usr/sbin/groupadd www -g 48
/usr/sbin/useradd -u 48 -g www www
rm -f /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
###############################
#输入或者是修改为以下内容:
###############################
<?xml version="1.0" ?>
<configuration>
<section name="global_options">
<value name="pid_file">/usr/local/php/logs/php-fpm.pid</value>
<value name="error_log">/usr/local/php/logs/php-fpm.log</value>
<value name="log_level">notice</value>
<value name="emergency_restart_threshold">10</value>
<value name="emergency_restart_interval">1m</value>
<value name="process_control_timeout">5s</value>
<value name="daemonize">yes</value>
</section>
<workers>
<section name="pool">
<value name="name">default</value>
<value name="listen_address">127.0.0.1:9000</value>
<value name="listen_options">
<value name="backlog">-1</value>
<value name="owner"></value>
<value name="group"></value>
<value name="mode">0666</value>
</value>
<value name="php_defines">
<value name="sendmail_path">/usr/sbin/sendmail -t -i</value>
<value name="display_errors">1</value>
</value>
<value name="user">www</value>
<value name="group">www</value>
<value name="pm">
<value name="style">static</value>
<value name="max_children">128</value>
<value name="apache_like">
<value name="StartServers">20</value>
<value name="MinSpareServers">5</value>
<value name="MaxSpareServers">35</value>
</value>
</value>
<value name="request_terminate_timeout">0s</value>
<value name="request_slowlog_timeout">0s</value>
<value name="slowlog">logs/slow.log</value>
<value name="rlimit_files">51200</value>
<value name="rlimit_core">0</value>
<value name="chroot"></value>
<value name="chdir"></value>
<value name="catch_workers_output">yes</value>
<value name="max_requests">500</value>
<value name="allowed_clients">127.0.0.1</value>
<value name="environment">
<value name="HOSTNAME">$HOSTNAME</value>
<value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
<value name="TMP">/tmp</value>
<value name="TMPDIR">/tmp</value>
<value name="TEMP">/tmp</value>
<value name="OSTYPE">$OSTYPE</value>
<value name="MACHTYPE">$MACHTYPE</value>
<value name="MALLOC_CHECK_">2</value>
</value>
</section>
</workers>
</configuration>
php-fpm启动与管理
/usr/local/php/sbin/php-fpm start
注:/usr/local/php/sbin/php-fpm还有其他参数,包括:
start|stop|quit|restart|reload|logrotate,修改php.ini后不重启php-cgi,重新加载配置文件使用reload,就保持了在php的fastcgi进程持续运行的状态下,又重新加载了php.ini。
Nginx安装
Nginx只是web服务器,配合php技术实现的fastcgi来提高性能
安装rewrite模块支持包pcre库
pcre是perl所用到的正则表达式,目的是让所装的软件支持正则表达式。默认情况下,Nginx只处理静态的网页请求,也就是html.如果是来自动态的网页请求,比如*.php,那么Nginx就要根据正则表达式查询路径,然后把*.PHP交给PHP去处理。
yum install pcre
安装Nginx
说明:创建www用户组及www用户,如果之前php-fpm没有创建,这里要创建。
tar zxvf nginx-1.0.15.tar.gz
cd nginx-1.0.15/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
Nginx 安装后只有一个程序文件,本身并不提供各种管理程序,它是使用参数和系统信号机制对 Nginx 进程本身进行控制的。
Nginx 的参数包括有如下几个:
-c <path_to_config>:使用指定的配置文件而不是 conf 目录下的 nginx.conf 。
-t:测试配置文件是否正确,在运行时需要重新加载配置的时候,此命令非常重要,用来检测所修改的配置文件是否有语法错误。
-v:显示 nginx 版本号。
-V:显示 nginx 的版本号以及编译环境信息以及编译时的参数。
例如我们要测试某个配置文件是否书写正确,我们可以使用以下命令
sbin/nginx -t -c conf/nginx.conf
nginx配置
在/usr/local/nginx/conf/目录中创建nginx.conf文件
rm -f /usr/local/nginx/conf/nginx.conf
vi /usr/local/nginx/conf/nginx.conf
=======================================
nginx.conf才是nginx web服务器的配置文件
=======================================
user www www;
worker_processes 1;
error_log logs/nginx_error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#通过FastCGI方式支持PHP,php页面由fastcgi代理处理,这也是反向代理的一个应用,这里可以是jsp/asp等脚本。
#
# #Nginx是通过本机的9000端口将PHP请求转发给PHP的,PHP自己是从本机的9000端口侦听数据,Nginx与PHP通过本机的9000端口完成了数据请求。
#
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#对于某一类型的文件,设置过期时间,静态的页面通常设置长一点。
#静态文件,nginx自己处理
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
{
expires 30d;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
说明:以上配置文件只是基本配置文件,要实现其它功能的话,需要在此基础上进行修改
说明:可以直接粘贴以下内容。
vi /usr/local/nginx/conf/fcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
nginx启动与管理
启动nginx
/usr/local/nginx/sbin/nginx
注意,启动nginx后,还必须同时启动php-fpm,否则,Nginx不支持php
命令如下:
/usr/local/php/sbin/php-fpm start
测试nginx配置文件
修改/usr/local/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确
/usr/local/nginx/sbin/nginx -t
如果屏幕显示以下两行信息,说明配置文件正确:
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
查看Nginx主进程号
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
屏幕显示的即为Nginx主进程号,例如:
6302
这时,执行以下命令即可使修改过的Nginx配置文件生效:
kill -HUP 6302
或者无需这么麻烦,找到Nginx的Pid文件:
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
配置开机自动启动Nginx + PHP
vi /etc/rc.local
加入以下内容:
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
测试nginx
vi /usr/local/nginx/html/phpinfo.php
<?
phpinfo();
?>
在浏览器输入http://localhost/ 屏幕显示Welcome to Nginx
在浏览器输入http://localhost/phpinfo.php 屏幕显示php相关信息