linux下nginx+php7完整安裝,親測有效

linux版本:CentOS Linux release 7.6.1810

第一步,安裝gcc和make

安裝make依賴
yum -y install gcc automake autoconf libtool make
安裝gcc
yum install gcc gcc-c++ glibc


第二步,安裝nginx

#安裝pcre,nginx需要rewrite模塊
wget https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gz
tar -zxvf pcre-8.41.tar.gz
cd pcre-8.41.tar.gz
./configure
make
make install

#安裝zlib壓縮
wget https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz
tar –zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11.tar.gz
./configure
make
make install

#安裝ssl,nginx可能需要https
wget https://www.openssl.org/source/openssl-1.1.0b.tar.gz
tar –zxvf openssl-1.1.0b.tar.gz
cd openssl-1.1.0b.tar.gz
./config
make
make install

#創建用戶組
groupadd -r www
useradd -r -g www www

#安裝nginx包
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar –zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/

#配置nginx
./configure --prefix=/usr/local/nginx-1.12.2 --sbin-path=/usr/local/nginx-1.12.2/sbin/nginx --conf-path=/usr/local/nginx-1.12.2/nginx.conf --pid-path=/usr/local/nginx-1.12.2/nginx.pid --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_mp4_module  --with-http_stub_status_module --with-select_module --with-poll_module --error-log-path=/alidata/logs/nginx/error.log --http-log-path=/alidata/logs/nginx/access.log  --with-pcre=/root/pcre-8.41 --with-zlib=/root/zlib-1.2.11 --with-openssl=/root/openssl-1.1.0b

#編譯安裝
make
make install

#打開nginx服務
/usr/local/nginx-1.12.2/sbin/nginx -s reload
#重啓nginx服務
/usr/local/nginx-1.12.2/sbin/nginx -s reload

第三步。安裝php

安裝php包
wget http://cn2.php.net/distributions/php-7.1.11.tar.gz
tar –zxvf php-7.1.11.tar.gz

#配置php
./configure --prefix=/usr/local/php-7.1.11 --with-config-file-path=/usr/local/php-7.1.11/etc --enable-fpm --with-mcrypt --enable-mbstring --enable-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-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar

中間可能會報錯:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release
yum install -y libmcrypt-devel

#編譯安裝
make && make install

複製php.ini文件到etc下
cp /usr/local/src/php-7.1.11/php.ini-production  /usr/local/php-7.1.11/etc/php.ini

複製php-fpm.conf到etc下
cd /usr/local/php-7.1.11/etc
cp php-fpm.conf.default php-fpm.conf

cd /usr/local/php-7.1.11/etc/php-fpm.d
cp www.conf.default www.conf

使用vim命令對php-fpm.conf的內容進行如下修改
pid= /usr/local/php-7.1.11/var/run/php-fpm.pid

開啓php-fpm
/usr/local/php-7.1.11/sbin/php-fpm

參考自:https://www.cnblogs.com/python-cat/p/8435801.html


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章