linux LNMP 及 PHP 拓展安装

基础安装

安装redis server

# 下载源码
wget http://download.redis.io/releases/redis-3.0.5.tar.gz
tar -zxvf redis-3.0.5.tar.gz 
cd redis-3.0.5 
#编译安装
make 
cd src 
make install PREFIX=/usr/local/redis 
mkdir /usr/local/redis/etc 
cd ..
cp redis.conf /usr/local/redis/etc/redis.conf
# 创建命令链接
ln -s /usr/local/redis/bin/redis-server /usr/local/bin/
# 加入到 /etc/rc.loacl
nohup redis-server > /root/redis.log 2>&1 &

安装php 拓展

yac 安装

编译

# 下载源码
wget https://pecl.php.net/get/yac-2.0.2.tgz && tar -xvf yac-2.0.2.tgz
cd yac-2.0.2
#编译安装
phpize 
./configure --prefix=/usr/local/yac --with-php-config=/usr/local/php/bin/php-config
make && make install

修改php.ini

extension=yac.so
[yac]
yac.enable = 1 
yac.keys_memory_size = 4M 
yac.values_memory_size = 64M 
yac.compress_threshold = -1 
yac.enable_cli = 0 

redis 安装

下载编译

wget http://pecl.php.net/get/redis-4.0.2.tgz
tar -xvf redis-4.0.2.tgz
cd redis-4.0.2
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

修改php.ini

extension=redis.so

swoole 安装

hiredis 依赖 安装
下载编译

wget -c https://github.com/redis/hiredis/archive/v0.13.3.tar.gz  && tar -xvf v0.13.3.tar.gz && cd hiredis-0.13.3/
make -j
sudo make install
sudo ldconfig

swoole
下载编译

wget -c https://github.com/swoole/swoole-src/archive/v2.0.8.tar.gz && mv v2.0.8.tar.gz php-swoole-2.0.8.tar.gz && tar -xvf php-swoole-2.0.8.tar.gz && cd swoole-src-2.0.8/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

修改php.ini

extension=swoole.so

xdebug 安装

下载编译

wget https://pecl.php.net/get/xdebug-2.6.0.tgz
tar -xvf xdebug-2.6.0.tgz && cd xdebug-2.6.0
phpize
./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config 
make clean && make -j
make install

修改php.ini

zend_extension="xdebug.so"
[xdebug]
xdebug.remote_autostart = On
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= 192.168.18.1
xdebug.remote_port = 9500

;xdebug.show_local_vars=0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 1
;xdebug.profiler_output_name = cachegrind.out.%t.%p
;xdebug.profiler_output_dir = "d:/logs/xdebug"
;xdebug.idekey = 1
;xdebug.auto_trace = on
;xdebug.trace_options=0
;xdebug.trace_output_dir="D:/logs/xdebug"
;xdebug.trace_output_name=trace.%c

一些报错

php| php.ini中的open_basedir仍报错open_basedir restriction in effect

修改.user.ini:

.user.ini文件无法直接修改
如要修改,需要先执行:chattr -i /网站目录/.user.ini
修改完成后再执行:chattr +i /网站目录/.user.ini
.user.ini不需要重启一般5分钟左右生效,也可以重启一下php-fpm立即生效。

去除防跨目录

如果不想用防跨目录的限制:
LNMP 1.4以下,直接删除.user.ini 再重启php-fpm即可。
LNMP 1.4上 还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 删除,需要重启nginx。

LNMPA或LAMP 1.2上的防跨目录的设置

使用的对应apache虚拟主机配置文件里的php_admin_value open_basedir参数进行设置。
如果不需要设置可以在前面加 # 进行注释,或自行修改目录的限制。
重启apache生效。

参考

猜你喜欢

转载自blog.csdn.net/diandianzhangda/article/details/80651710