当前位置:
首页 > temp > 简明python教程 >
-
腾讯云centos7 从零搭建laravel项目
目标,访问网站出现:
-----------------------分割线----------------------------------------
一、Laravel Homestead 环境安装(腾讯云不支持!)
试了各种方法,一直报错,最后在旧版腾讯云贴吧里面找到官方解答
内心各种曹尼玛啊啊啊啊啊!
二、测试环境长期关闭 防火墙&SELinux
//关闭 systemctl stop firewalld //关闭开机启动 systemctl disable firewalld
//临时关闭SELinux setenforce 0 vim /etc/selinux/config 把SELINUX=enforcing 改成SELINUX=disabled
三、安装nginx
cd /etc/yum.repos.d/ vim nginx.repo
复制下列文本至 nginx.repo (文本来源)
[nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key
yum list | grep nginx yum -y install nginx nginx -v mkdir /www mkdir /www/wwwroot mkdir /www/wwwroot/default cd /www/wwwroot/default vim index.html
输入至 index.html
Hellow World!!!
cd /etc/nginx/conf.d vim default.conf
systemctl start nginx systemctl enable nginx
四、安装PHP
yum -y install epel-release rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum list | grep php72 yum -y install mod_php72w php72w-cli php72w-fpm php72w-common php72w-devel
mkdir /www/wwwroot/learn cd /www/wwwroot/learn vim index.php
输入至 index.php
<?php phpinfo(); ?>
cd /etc/nginx/conf.d vim learn.conf
输入下文,
server { listen 8080; server_name localhost; root /www/wwwroot/learn; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.php index.html index.htm; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { root /www/wwwroot/learn; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } }
systemctl restart nginx
systemctl start php-fpm
systemctl enable php-fpm
五、安装MYSQL
cd ~ rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm yum list | grep mysql yum-config-manager --disable mysql80-community yum-config-manager --enable mysql57-community yum list | grep mysql //这步安装时间长,请耐心等待,看你的网络状况 yum -y install mysql-community-server mysql-community-client systemctl start mysqld systemctl enable mysqld //设置MySQL set global validate_password_policy=0; set global validate_password_mixed_case_count=0; set global validate_password_number_count=3; set global validate_password_special_char_count=0; set global validate_password_length=3; //复制好密码 grep 'temporary password' /var/log/mysqld.log mysql -uroot -p (输入密码) set password for root@localhost = password('root'); //退出MySQL exit;
六、安装composer
cd /tmp curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer composer -v composer config -g repo.packagist composer https://packagist.phpcomposer.com
七、配置Laravel 项目(链接请都点开)
//安装 laravel composer global require laravel/installer
配置环境变量,PATH,
下载离线包, 找最新的下
上传文件夹,并解压至 '/www/wwwroot/learn2' 文件夹
cd /www/wwwroot/learn2 vim .env
写入下列内容,
APP_NAME=Laravel APP_ENV=local APP_KEY=base64:fYG9POLRD3bFB/eAfyRGNakdfbwTVDObop+imw7U42Q= APP_DEBUG=true APP_URL=http://localhost LOG_CHANNEL=stack DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD= BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
vim /etc/nginx/conf.d/learn2.conf
写入内容,
server { listen 8081; server_name localhost; root /www/wwwroot/learn2/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.php index.html index.htm; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { root /www/wwwroot/learn2/public; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } }
八、填坑
打开网页 'IP:8081', 各种报错,
先在'www/wwwroot/learn2/public/index.php' 里添加:
ini_set('display_errors',1); error_reporting(E_ALL);
cd /www/wwwroot/learn2 chmod -R 777 * yum -y install php72w-pdo yum -y install php72w-mysql systemctl restart php-fpm php artisan key:generate
OK!,出现:
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
SQL Server -- 解决存储过程传入参数作为s
关于JS定时器的整理
JS中使用Promise.all控制所有的异步请求都完
js中字符串的方法
import-local执行流程与node模块路径解析流程
检测数据类型的四种方法
js中数组的方法,32种方法
前端操作方法
数据类型
window.localStorage.setItem 和 localStorage.setIte
如何完美解决前端数字计算精度丢失与数