目标,访问网站出现:
-----------------------分割线----------------------------------------
一、Laravel Homestead 环境安装(腾讯云不支持!)
试了各种方法,一直报错,最后在旧版腾讯云贴吧里面找到官方解答
内心各种曹尼玛啊啊啊啊啊!
二、测试环境长期关闭 防火墙&SELinux
//关闭systemctl stop firewalld
//关闭开机启动systemctl disable firewalld
//临时关闭SELinux setenforce 0vim /etc/selinux/config
把SELINUX=enforcing 改成SELINUX=disabled
三、安装nginx
cd /etc/yum.repos.d/vim nginx.repo
复制下列文本至 nginx.repo
[nginx-stable]
name=nginx stable repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=1enabled=1gpgkey=https://nginx.org/keys/nginx_signing.key[nginx-mainline]
namename=nginx mainline repobaseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/gpgcheck=1enabled=0gpgkey=https://nginx.org/keys/nginx_signing.key
yum list | grep nginx
yum -y install nginxnginx -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 nginxsystemctl enable nginx
四、安装PHP
yum -y install epel-releaserpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmyum list | grep php72
yum 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
cd /etc/nginx/conf.dvim 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-fpmsystemctl 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');//退出MySQLexit;
六、安装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 项目(链接请都点开)
//安装 laravelcomposer 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=trueAPP_URL=http://localhostLOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=BROADCAST_DRIVER=log
CACHE_DRIVER=fileQUEUE_CONNECTION=syncSESSION_DRIVER=fileSESSION_LIFETIME=120REDIS_HOST=127.0.0.1REDIS_PASSWORD=nullREDIS_PORT=6379MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_ENCRYPTION=nullAWS_ACCESS_KEY_ID=AWS_SECRET_ACCESS_KEY=AWS_DEFAULT_REGION=us-east-1AWS_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/learn2chmod -R 777 *yum -y install php72w-pdoyum -y install php72w-mysql
systemctl restart php-fpm
php artisan key:generate
OK!,出现: