cat /etc/yum.repos.d/nginx.repo
nginx.repo を追加または編集します
vi /etc/yum.repos.d/nginx.repo
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/$basearch/gpgcheck=0enabled=1ログイン後にコピー
nginx をインストールする
えーファイアウォールポート80を開く
yum install epel-releaseyum install nginx
必要な依存関係をインストール
firewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --zone=trusted --add-port=80/tcpfirewall-cmd --reload
php-7.0.7をダウンロード
yum install -y \gcc-c++ autoconf \libjpeg libjpeg-devel libpng \libpng-devel freetype freetype-devel \libpng libpng-devel libxml2 libxml2-devel \zlib zlib-devel glibc glibc-devel \glib2 glib2-devel bzip2 bzip2-devel \ncurses curl openssl-devel \gdbm-devel db4-devel libXpm-devel \libX11-devel gd-devel gmp-devel \readline-devel libxslt-devel \expat-devel xmlrpc-c xmlrpc-c-devel \libicu-devel libmcrypt-devel \libmemcached-devel
コンパイルphp
cd /usr/src/wget http://cn2.php.net/distributions/php-7.0.7.tar.bz2tar -xjf php-7.0.7.tar.bz2mv php-7.0.7 php7cd /usr/src/php7
php
# 视情况增删参数,以下为一些常用的./configure --prefix=/usr/local/php7 \--with-mysql-sock --with-mysqli \--enable-fpm --enable-soap \--with-libxml-dir --with-openssl \--with-mcrypt --with-mhash \--with-pcre-regex --with-zlib \--enable-bcmath --with-iconv \--with-bz2 --enable-calendar \--with-curl --with-cdb --enable-dom \--enable-exif --enable-fileinfo \--enable-filter --with-pcre-dir \--enable-ftp --with-gd \--with-openssl-dir --with-jpeg-dir \--with-png-dir --with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv --with-gettext \--with-gmp --with-mhash \--enable-json --enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl --with-onig \--enable-pdo --with-pdo-mysql \--with-zlib-dir --with-readline \--enable-session --enable-shmop \--enable-simplexml --enable-sockets \--enable-sysvmsg --enable-sysvsem \--enable-sysvshm --enable-wddx \--with-libxml-dir --with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear --enable-intl --enable-pcntl
インストールが成功したかどうかをテストします
makemake install
php
/usr/local/php7/bin/php -v
Verify
ln -sf /usr/local/php7/bin/php /usr/local/bin/php
設定ファイルをコピー
php -v
Configure php-fpm
cp /usr/src/php7/php.ini-development /usr/local/php7/lib/php.ini
Start php-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.confcp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.confcp /usr/src/php7/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpm
nginxを構成する
service php-fpm start
/etc/nginx/nginx.conf のサーバー ブロックに次の設定を追加します。 注: root 設定をサーバーに追加する必要があります。追加しないと $document_root が無効になります
vi /etc/nginx/nginx.confログイン後にコピー
nginx を再起動します
root /www/;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;}
service nginx restart
http://127.0.0.1/info.php
echo '<?php phpinfo();' > /usr/share/nginx/html/info.php
cd /usr/srcgit clone https://github.com/php-memcached-dev/php-memcached.gitcd php-memcached/git checkout php7/usr/local/php7/bin/phpize./configure --with-php-config=/usr/local/php7/bin/php-configmakemake install
を変更します
vi /usr/local/php7/lib/php.ini#在最下面加上extension=memcached.so
を再起動します