1、nginx install:
下載對應當前系統版本的nginx包(package)
# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm建立nginx的yum倉庫# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm下載並安裝nginx# yum install nginx啟動nginx服務systemctl start nginx配置預設的設定檔在 /etc/nginx 路徑下,使用該配置已經可以正確地運行nginx;如需要自訂,修改其下的 nginx.conf 等檔案即可。測試在瀏覽器地址欄中輸入部署nginx環境的機器的IP,如果一切正常,應該能看到如下字樣的內容。/etc/nginx/nginx.conf delete the comment ############################################ location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params; }###########################################service nginx restart
2、redis install:
wget http://download.redis.io/releases/redis-3.0.0.tar.gztar zxvf redis-3.0.0.tar.gzcd redis-3.0.0./configure;make;make installredis-server /etc/redis.conf
3、php-redis install:
error:the GPG keys listed for the "CentOS-7 - Updates - 163.com" repository are already instarpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7cd /tmpwget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zipunzip php-redis.zip解壓後目錄是:nicolasff-phpredis-21d6614cd nicolasff-phpredis-21d6614phpize./configuremakemake install確認一下so檔案已經放置到正確目錄ll /usr/lib/php/modules/redis.sovi /etc/php.ini add the following content.extension=redis.so[root@localhost phpredis-phpredis-fc673f5]# ll /usr/lib64/php/modules/redis.so
4、php-fpm install:
so asto parse the php by nginxyum install php-fpm
5、start php-fpm nginx
vi /etc/php-fpm.conf daemonize = yesphp-fpm-c /etc/php.iniservice nginx restart
6、test nginx and php
http://localhost/test.phpecho phpinfo();?>
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
以上就介紹了Centos7 nginx+php+redis環境搭建,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。