ubuntu16系统
装php
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt update
apt install php7.1 php7.1-xml php7.1-dev php7.1-mbstring php7.1-curl php7.1-zip
装redis
apt install redis-tools
apt install redis-server
pecl install redis
vim /etc/php/7.1/fpm/php.ini 添加 extension=redis.so
/etc/php/7.1/fpm/pool.d/www.conf 更改端口号为 127.0.0.1:9000
装mysql
apt install php7.1-mysql
apt install mysql-server
# 设置内网访问
# vim /etc/mysql/mysql.conf.d/mysqld.cnf
把 bind_address = 0.0.0.0 //这里设置所有人能访问,正常要设置内网访问
# 登录 mysql 修改权限
mysql -u root
use mysql;
grant all privileges on *.* to root@"%" identified by "{password}" with grant option;
flush privileges;
装nginx
apt install nginx
装mongodb 因为这个框架用mongdb存储数据需要mongdb版本大于3.0
Mongdb适配php7安装
which php 得到目录 /usr/bin/php
/usr/bin/pecl install mongodb //此时装的mongdb版本可能只有2.X
升级mongdb
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl unmask mongodb
把extension=mongodb.so放到php.ini
连接mongdb可能失败,因为配置文件没有允许其他人访问
bindIp: 0.0.0.0//这里是所有人都能访问,肯定不行的,改成内网访问之类的。
前端web框架
git clone https://github.com/laynefyc/xhgui-branch.git
cd xhgui-branch
php install.php //这个框架用的tideways扩展坑人,会报错找不到一个方法,所以用不了,把tideways扩展换称tideways_xhprof
框架里面config.default.php使用的扩展记得改掉
安装tideways_xhprof
git clone https://github.com/tideways/php-profiler-extension.git
cd php-profiler-extension
phpize
./configure
make
sudo make install
把extension=tideways_xhprof.so放到php.ini
配置nginx
在nginx的要监听的端口的server里加一行
fastcgi_param PHP_VALUE "auto_prepend_file=/Users/markstory/Sites/xhgui/external/header.php";
用php-fpm的话因为上面进行了这步 /etc/php/7.1/fpm/pool.d/www.conf 更改端口号为 127.0.0.1:9000
所以nginx里面要改
fastcgi_pass 127.0.0.1:9001;
//路径肯定要改,这里又有一个坑,如果用php-fpm因为它会有缓存,所以其他的端口用了php-fpm,哪怕你没有加上这句话,还是会被监听。自己修改代码,在header.php里判断下是不是你要的端口,如果不是return就行了。
然后前端web框架也是需要nginx才能访问的,需要额外一个端口配置前端框架,类似于
root那行就是对应的web框架的index.php
server {
listen 8085;
charset utf-8;
root /usr/local/var/www/;
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
#root /Users/USERNAME/workspace/www/$file_path/public;
fastcgi_pass 127.0.0.1:9000; # PHP-FPM default running on this port.
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
最后
重启nginx
service nginx restart
重启php-fpm
service php7-fpm restart