配置Lnmp+redis-创新互联
配置Lnmp+redis
成都创新互联是一家集网站建设,浦东企业网站建设,浦东品牌网站建设,网站定制,浦东网站建设报价,网络营销,网络优化,浦东网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。[root@40 ~]# yum -y install gcc gcc-c++ pcre-devel zlib-devel
[root@40 lnmp]# tar -xf nginx-1.12.2.tar.gz
[root@40 lnmp]# cd nginx-1.12.2/
[root@40 nginx-1.12.2]# ./configure
[root@40 nginx-1.12.2]# make && make install
[root@40 nginx-1.12.2]# ln -s /usr/local/nginx/sbin/* /sbin/
[root@40 nginx-1.12.2]# nginx
[root@40 nginx-1.12.2]# ss -antulp | grep nginx
Tcp LISTEN 0 128 :80:* users (("nginx",pid=8346,fd=6),("nginx",pid=8345,fd=6))
[root@40 nginx-1.12.2]# yum -y install php-common
[root@40 lnmp]# rpm -ivh php-fpm-5.4.16-42.el7.x86_64.rpm
[root@40 lnmp]# systemctl start php-fpm
[root@40 lnmp]# systemctl enable php-fpm
[root@40 lnmp]# vim /usr/local/nginx/conf/nginx.conf
65 location ~ .php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
70 include fastcgi.conf;
71 }
[root@40 lnmp]# nginx -s reload
[root@40 lnmp]# ss -antulp | grep nginx
tcp LISTEN 0 128 :80:* users:(("nginx",pid=8646,fd=6),("nginx",pid=8345,fd=6))
[root@40 lnmp]# vim /usr/local/nginx/html/index.php
phpinfo();
?>
[root@40 redis]# yum -y install autoconf automake
[root@40 redis]# yum -y install php-devel-5.4.16-42.el7.x86_64.rpm
[root@40 redis]# tar -xf php-redis-2.2.4.tar.gz
[root@40 redis]# cd phpredis-2.2.4/
[root@40 phpredis-2.2.4]# phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100425
Zend Extension Api No: 220100425
[root@40 phpredis-2.2.4]# ll /usr/bin/php-config
-rwxr-xr-x. 1 root root 4424 11月 6 2016 /usr/bin/php-config
[root@40 phpredis-2.2.4]# ./configure --with-php-config=/usr/bin/php-config
[root@40 phpredis-2.2.4]# make && make install
...
....
Build complete.
Don't forget to run 'make test'. 安装到此会出现如下报错
解决办法:
1.make install 查看路径
Installing shared extensions: /usr/lib64/php/modules/
[root@40 phpredis-2.2.4]# ls /usr/lib64/php/modules/
curl.so fileinfo.so json.so phar.so redis.so zip.so
2.更改php配置文件
[root@40 phpredis-2.2.4]# vim /etc/php.ini
728 extension_dir = "/usr/lib64/php/modules/"
729 ; On windows:
730 extension_dir = "redis.so"
[root@40 phpredis-2.2.4]# systemctl restart php-fpm
php -m | grep -i redis 查看是否支持redis
如果输入上面命令出现以下问题:
[root@43 phpredis-2.2.4]# php -m | grep redis
PHP Warning: PHP Startup: Unable to load dynamic library 'redis.so/curl.so' - redis.so/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
解决办法:
[root@43 phpredis-2.2.4]# vim /etc/php.ini
把extension_dir = "redis.so" >> extension = "redis.so"
[root@40 phpredis-2.2.4]# vim /usr/local/nginx/html/test1.php
$redis = new redis();
$redis->connect('192.168.4.40',6040);
$redis->set('redistest','666666');
echo $redis->get('redistest');
?>
[root@40 phpredis-2.2.4]# redis-cli -h 192.168.4.40 -p 6040
192.168.4.40:6040> keys *
1) "redistest"
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站题目:配置Lnmp+redis-创新互联
网页链接:http://scyanting.com/article/dchdii.html