centos7系统上架设nginx+php7+redis

首先直接用yum安装基础依赖库和工具
yum -y install gcc gcc-c++ autoconf automake make libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd-devel wget git

1、安装nginx

wget http://nginx.org/download/nginx-1.14.0.tar.gz

tar -zxvf nginx-1.14.0.tar.gz

cd nginx-1.14.0

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module


make && make install

groupadd -r www
useradd -r -g www -s /bin/false -M www

配置nginx自启动文件

vi /usr/lib/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

chmod +x /usr/lib/systemd/system/nginx.service

systemctl enable nginx

systemctl start nginx

2、安装php

到php官网下载相应的php7版本,然后解压

tar zxvf php-7.1.18.tar.gz

cd php-7.1.18

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-mbstring --enable-ftp --with-curl --enable-sockets --enable-soap --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-gd-native-ttf --enable-exif --enable-libxml --enable-fpm --enable-pcntl --with-openssl

make && make install

设置php配置文件

cp php.ini-production /usr/local/php/etc/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf

vi php-fpm.conf
    pid = run/php-fpm.pid

cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf

配置php自启动文件

vi /usr/lib/systemd/system/php-fpm.service

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

chmod +x /usr/lib/systemd/system/php-fpm.service

systemctl enable php-fpm

systemctl start php-fpm

3、安装php的redis扩展

wget http://pecl.php.net/get/redis-4.0.2.tgz

tar zxvf redis-4.0.2.tgz

cd redis-4.0.2

/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

安装完成后,编辑php的配置文件
vi /usr/local/php/etc/php.ini

在最的一行添加
extension=redis.so

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值