PHP官网下载地址wget http://cn2.php.net/get/php-7.0.7.tar.bz2/from/this/mirror/php-7.0.7.tar.bz2解压从官方下载的压缩包
PHP官网下载地址
wget http://cn2.php.net/get/php-7.0.7.tar.bz2/from/this/mirror/php-7.0.7.tar.bz2
解压从官方下载的压缩包
tar xvf php-7.0.7.tar.bz2
安装相应的组件库,可根据需求更改
yum -y install libmcrypt-devel 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 yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
执行编译安装,可根据需求更改
./configure --prefix=/usr/local/php /--with-config-file-path=/usr/local/php/etc /--enable-mysqlnd /--with-mysqli /--with-pdo-mysql /--enable-fpm /--with-gd /--with-iconv /--with-zlib /--enable-xml /--enable-shmop /--enable-sysvsem /--enable-inline-optimization /--enable-mbregex /--enable-mbstring /--enable-ftp /--enable-gd-native-ttf /--with-openssl /--enable-pcntl /--enable-sockets /--with-xmlrpc /--enable-zip /--enable-soap /--without-pear /--with-gettext /--enable-session /--with-curl /--with-jpeg-dir /--with-freetype-dir /--enable-opcachemake && make install
拷贝一份PHP默认配置文件模板
cd /usr/local/php/etc/php-fpm.d/cp www.conf.default www.confcd /usr/local/php/etc/cp php-fpm.conf.default php-fpm.conf
修改进程默认用户
vim /usr/local/php/etc/php-fpm.d/www.conf#将user和group更改为设置的网站管理用户
在网站目录中建立php测试文件用于页面访问php测试
vim /wwwroot/html/www.test.com/index.php<?phpinfo()?>
赋予站点目录及以下文件权限为读取和执行
chmod -R 755 /wwwroot
启用php服务并加入开机自启
/usr/local/php/sbin/php-fpmecho '/usr/local/php/sbin/php-fpm' >> /etc/rc.local
更改nginx配置文件使其可以访问php文件
vim /usr/local/nginx/conf/nginx.conf
server { listen 80 ; server_name www.test.com test.com; index index.html index.htm index.php; root /wwwroot/html/www.test.com; location ~ /.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*/.(js|css)?$ { expires 12h; } location ~ //. { deny all; } error_log /wwwroot/wwwlogs/www.test.com.error.log; access_log /wwwroot/wwwlogs/www.test.com.access.log; }
重新加载nginx配置文件就可以host绑定用浏览器访问测试了
/usr/local/nginx/sbin/nginx -s reload