部署LNMP+memcached环境

部署LNMP环境
[ root@proxy ~] # yum - y install gcc openssl - devel pcre - devel zlib - devel
[ root@proxy ~] # tar - xf nginx -1.12.2 . tar . gz
[ root@proxy ~] # cd nginx -1.12.2
[ root@proxy nginx -1.12.2 ] # ./ configure \
> -- with - http_ssl_module
[ root@proxy nginx -1.12.2 ] # make && make install
[ root@proxy ~] # yum - y install mariadb mariadb - server mariadb - devel
[ root@proxy ~] # yum - y install php php - mysql
[ root@proxy ~] # yum - y install php - fpm -5.4.16-42 . el7 . x86_64 . rpm
[ root@proxy ~] # vim / usr / local / nginx / conf / nginx . conf
location / {
root html ;
index index . php index . html index . htm ;
}
location ~ \. php$ {
root html ;
fastcgi_pass 127.0.0.1 : 9000 ;
fastcgi_index index . php ;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
include fastcgi . conf ;
}
[ root@proxy ~] # systemctl stop httpd                 //如果该服务存在,则关闭该服务
[ root@proxy ~] # /usr/ local / nginx / sbin / nginx
[ root@proxy ~] # netstat - utnlp | grep : 80
tcp     0      0 0.0.0.0 : 80          0.0.0.0 :*         LISTEN         32428 / nginx
[ root@proxy ~] # systemctl start mariadb
[ root@proxy ~] # systemctl status mariadb
[ root@proxy ~] # systemctl start php - fpm
[ root@proxy ~] # systemctl status php - fpm
[ root@proxy ~] # setenforce 0
[ root@proxy ~] # firewall - cmd -- set - default - zone = trusted
[ root@proxy ~] # yum - y install php - pecl - memcache
[ root@proxy ~] # systemctl restart php - fpm

部署 memcached环境(参考 https://blog.csdn.net/zhydream77/article/details/81022155
[ root@proxy ~] # vim / usr / local / nginx / html / test . php
<? php
$memcache = new Memcache ;                  //创建memcache对象
$memcache -> connect ( 'localhost' , 11211 ) or die ( 'could not connect!!' );
$memcache -> set ( 'key' , 'test' );          //定义变量
$get_values = $memcache -> get ( 'key' );      //获取变量值
echo $get_values ;
?>
[ root@client ~] # firefox http : //192.168.4.6/test.php



















猜你喜欢

转载自blog.csdn.net/zhydream77/article/details/81025242