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.
