系统:Centos 6.8 2.6.32-642.el6.x86_64
SELinux:关闭
iptables:打开tcp 80端口
安装依赖包(ps:yum源可以使用本地镜像,也可联网状态下直接yum安装)
# yum -y install libtool* zlib* openssl* wget gcc gcc-c++ cmake pcre* libxml2* curl* libcurl* libjpeg* libpng libpng-devel freetype freetype-devel libxslt*
编译libmcrypt解决依赖
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar zxvf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7
# ./configure && make && make install
Nginx版本1.11.3 && 编译安装
# wget http://nginx.org/download/nginx-1.11.3.tar.gz
# tar zxvf nginx-1.11.3.tar.gz && cd nginx-1.11.3
# ./configure --prefix=/usr/local/nginx
# make && make install
# ll /usr/local/nginx/
# cat /usr/local/nginx/conf/nginx.conf //在最后一行添加(最后一个 } 之前)
include vhost/*.conf;
# mkdir /usr/local/nginx/conf/vhost && cd /usr/local/nginx/conf/vhost
# cat /usr/local/nginx/conf/vhost/nginx.conf //创建nginx.conf文件,内容如下
server {
listen 80;
server_name localhost;
root html;
index index.html index.php;
error_log logs/tianhuabms_error.log;
location / {
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO /usr/local/nginx/conf/$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
}
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# /usr/local/nginx/sbin/nginx //启动nginx
# ps aux|grep nginx
root 5148 0.0 0.0 19988 692 ? Ss 19:41 0:00 nginx: master process /usr/local/nginx/
sbin/nginxnobody 5149 0.0 0.1 20460 1292 ? S 19:41 0:00 nginx: worker process
root 5151 0.0 0.0 103336 900 pts/1 S+ 19:41 0:00 grep nginx
# /usr/local/nginx/sbin/nginx -s stop //停止nginx
# /usr/locat/nginx/sbin/nginx -s reload //重新加载配置文件
PHP版本7.0.4
# wget http://cn2.php.net/distributions/php-7.0.4.tar.gz
# tar zxvf php-7.0.4.tar.gz -C /usr/local/src/ && cd /usr/local/src/php-7.0.4
# ./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-zlib-dir \
--with-mhash \
--with-mcrypt \
--with-openssl-dir \
--with-jpeg-dir \
--enable-gd-jis-conv \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-maintainer-zts \
--enable-zip \
--enable-opcache=no
# make
# make test
# make install
在包含自 /usr/local/src/php-7.0.4/ext/zip/lib/zip_add.c:36 的文件中:
/usr/local/src/php-7.0.4/ext/zip/lib/zipint.h:126:2: 错误:#error unsupported size of off_t
make: *** [ext/zip/lib/zip_add.lo] 错误 1
解决方法
# echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf && ldconfig -v
# make clean //解决错误后clean,重新configure
编译完成php后,设置配置文件
# cp php.ini-production /usr/local/php7/etc/php.ini
# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
# cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
# /etc/init.d/php-fpm start
Starting php-fpm done
测试
# cat /usr/local/nginx/html/phpinfo.php
phpinfo();
?>