Centos7下nginx+php+redis环境搭建
时间:2015-08-30 00:03 来源:linux.it.net.cn 作者:IT
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.gz
tar zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
./configure;make;make install
redis-server /etc/redis.conf
3、php-redis install:
error:the GPG keys listed for the "CentOS-7 - Updates - 163.com" repository are already insta
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
cd /tmp
wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip
unzip php-redis.zip
解压后目录是:nicolasff-phpredis-21d6614
cd nicolasff-phpredis-21d6614
phpize
./configure
make
make install
确认一下so文件已经放置到正确目录
ll /usr/lib/php/modules/redis.so
vi /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 as to parse the php by nginx
yum install php-fpm
5、start php-fpm nginx
vi /etc/php-fpm.conf daemonize = yes
php-fpm -c /etc/php.ini
service nginx restart
6、test nginx and php
http://localhost/test.php
<?php
echo phpinfo();
?>
(责任编辑:IT)
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.gz tar zxvf redis-3.0.0.tar.gz cd redis-3.0.0 ./configure;make;make install redis-server /etc/redis.conf 3、php-redis install: error:the GPG keys listed for the "CentOS-7 - Updates - 163.com" repository are already insta rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 cd /tmp wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip unzip php-redis.zip 解压后目录是:nicolasff-phpredis-21d6614 cd nicolasff-phpredis-21d6614 phpize ./configure make make install 确认一下so文件已经放置到正确目录 ll /usr/lib/php/modules/redis.so vi /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 as to parse the php by nginx yum install php-fpm 5、start php-fpm nginx vi /etc/php-fpm.conf daemonize = yes php-fpm -c /etc/php.ini service nginx restart 6、test nginx and php http://localhost/test.php <?php echo phpinfo(); ?> (责任编辑:IT) |