虚拟机安装 PHPHub5(一)
访问GITHUB图标 -->> 去往PHPHUB5的GITHUB项目
虚拟机环境
nginx version 1.10.0 need Nginx 1.8+
php version 7.0.7 need PHP 5.6+
mysql version 5.7.11 need Mysql 5.7+
redis version 3.2.0 need Redis 3.0+
memcached version 1.4.25 need Memcached 1.4+
完全符合PHPHUB5的要求
1、克隆代码到本地
2、由于不知道什么是HOMESTEAD,所以我直接进行COMPOSER安装依赖包(如果COMPOSER是外库,可以去喝杯茶了)
cd phphub5
composer install
- Generating optimized class loader
- Compiling common classes
- 提示上面的两行,表示COMPOSER安装成功
3、生成配置文件(我更愿意说复制一份配置文件)
cp .env.example .env
4、使用安装命令
php artisan est:install
- php artisan key:generate
- [ErrorException]
- shell_exec() has been disabled for security reasons
- 使用上述命令后,提示错误,意思为shell_exec()未开启,请找到php.ini开启。
- 上述修改完成后,继续运行会卡住。输入:
- yes
- 并回车。
- 提示错误
- Application In Production! *
- Do you really wish to run this command? (yes/no) [no]:
- [PDOException]
- SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
- php artisan est:init-rbac
- [PDOException]
- SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
- 以上错误未mysql,提示没有这个用户(homestead),请返回第3步,在你复制完.env文件后,修改此文件内mysql的配置
6、配置HOST文件我这里写的是127.0.0.1,在虚拟机外面我可以也绑定这个域名,到这个虚拟机的内网或局域网IP
echo "127.0.0.1 phphub5.app" | sudo tee -a /etc/hosts
7、php部分安装完成(测试在本机配置域名指向虚拟机IP成功,需要添加NGINX里的SERVER来配对域名)
共享一份phphub5或算是laravel的nginx.server配置
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name phphub5.app;
index index.html index.htm index.php;
root /home/wwwroot/default/phphub5/public;
#error_page 404 /404.html;
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /home/wwwlogs/phphub5.access.log;
}
- 请修改 .env 文件为 APP_ENV=local 和 APP_DEBUG=true 。
- 首页地址:http://phphub5.app/
- 管理后台:http://phphub5.app/admin/
- 在开发环境下,直接访问后台地址即可登录 1 号用户。
- 在使用上述方法后访问phphub5.app的时候,提示error
- Connection timed out [tcp://127.0.0.1:6379]
- 上面的redis问题,1是请求不到,有可能是redis启动不完善。2是redis有警报什么的,我设置完重启下好了。
- 访问 phphub5.app/admin/ 报404错误
- 是由于没有在nginx.server中加上最重要的一个路由,所有请求都走index.php。如下:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
今天暂时书写到这里,明天继续,先睡觉了。
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: