1. ecs 购买
地域: 华北 2
可用区: 随机分配
安全组 ID: sg-2533jog6k
I/O 优化实例: I/O 优化实例
实例规格: 1 核 1GB
网络类型: 经典网络
带宽: 1Mbps(按固定带宽)
镜像: CentOS 7.2 64位
系统盘: 40GB 高效云盘
密码: 已设置
实例名称: test_server
2. php安装
最新版本7.1.4不支持mcrypy等
下载地址: http://am1.php.net/get/php-7.0.18.tar.gz/from/this/mirror
安装依赖库
yum install openssl openssl-devel
yum install -y curl-devel
yum -y install libxslt-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel pcre-dev
安装PHP:
./configure --prefix=/usr/local/servers/php7 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --with-jpeg-dir
make && make install
设置环境变量:
vi /etc/profile 在文件末尾添加
export PATH=$PATH:/usr/local/servers/php7/bin
执行 source /etc/profile
3. php-fpm
a. 更改配置便于管理进程
cp /usr/local/servers/php7/etc/php-fpm.conf.default php-fpm.conf
vi /usr/local/servers/php7/etc/php-fpm.conf
打开pid = run/php-fpm.pid前的注释,这样fpm的进程就会被写入这个文件:/usr/local/php5/var/run/php-fpm.pid
b. conf配置
cp etc/www.conf.default www.conf
useradd -g yqzdev www
vi修改.conf:
user =www
group =yqzdev
c. 相关命令
启动php-fpm
/usr/local/servers/php7/sbin/php-fpm
查看是否启动成功:
netstat -lnt | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
或者使用如下命令,查看是否9000端口被php-fpm占用:
netstat -tunpl | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2124/php-fpm
php-fpm 关闭:
kill -INT `cat /usr/local/servers/php7/var/run/php-fpm.pid`
或者:pkill php-fpm
php-fpm 重启:
kill -USR2 `cat /usr/local/servers/php7/var/run/php-fpm.pid`
4. openresty安装
下载: wget https://openresty.org/download/openresty-1.11.2.2.tar.gz
安装依赖:
yum install readline-devel pcre-devel openssl-devel gcc
安装:
./configure --prefix=/usr/local/servers/openresty --with-luajit
make && make install
ln -s /usr/local/servers/openresty/nginx/sbin/nginx /usr/sbin/nginx // 建立软连接
/usr/sbin/nginx -c /usr/local/servers/openresty/nginx/conf/nginx.conf // 启动nginx
/usr/sbin/nginx -t // 测试
/usr/sbin/nginx -s reload // 重启
5. php 扩展安装
a. mcrypt
yum install libmcrypt libmcrypt-devel mcrypt mhash
进入目录 :
/root/software/servers/php/php-7.0.18/ext/mcrypt
yum install php-devel
./configure --with-php-config=/usr/bin/php-config (报错fatal error: Zend/zend_smart_str.h: No such file or directory)
或 ./configure --with-php-config=/usr/local/servers/php7/bin/php-config
make && make install
重启ptm
查看:
# php -m
...
libxml
mbstring
mcrypt
mysql
...
[Zend Modules]
已安装成功!
再次查看 phpinfo ,可以看到mcrypt 扩展详情。
b. msgpack
wget http://pecl.php.net/get/msgpack-2.0.2.tgz
tar zxf msgpack-2.0.2.tgz
cd msgpack-2.0.2
phpize
./configure --with-php-config=/usr/local/servers/php7/bin/php-config
make && make install
添加extension=msgpack.so 到 /usr/local/servers/php7/lib/php.ini
重启fpm.