配置nginx.conf
vim /usr/local/nginx/conf/nginx.conf
#找到 location ~ \.php$,把fastcgi_param改成如下
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#在最后一行加上
include vhosts.conf
#创建一个 vhosts.conf
vim /usr/local/nginx/conf/vhosts.conf
参考:https://learnku.com/articles/20443
vhosts.conf 配置如下
server {
listen 80;
server_name localhost;
root /usr/local/nginx/html/www/laravel/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$ {
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;
}
}
防火墙端口开放
安装防火墙
yum -y install firewalld
yum -y install firewall-config
如果防火墙未开启,则开启
systemctl start firewalld
查看目前开放了哪些端口
firewall-cmd --list-ports
永久开发开放80端口
firewall-cmd --add-port=80/tcp --permanent
重新加载防火墙
firewall-cmd --reload
文件权限
chown -R 755 项目路径/storage
chmod -R 755 项目路径/bootstrap/cache
// 访问项目时提示

// 如果使用centos作为服务器,要关闭SELinux
查看状态,如果Current
sestatus
可以看见当前为强制模式,现在需要改为宽容模式:setenforce Permissive,每次重启服务器都要改


// 或者修改文件
vim /etc/selinux/config
SELINUX=disabled
访问网站

