我尝试在Ubuntu AWS 04.04中将Laravel与Nginx一起安装在Amazon AWS中。
我遵循这个不错的教程: https://linux4one.com/how-to-install-laravel-php-framework-with-nginx-on-ubuntu-18-04/
但在最后一条指令中:
ngnix -t
我收到此错误:
nginx:[emerg] open()“ / etc / nginx / sites-enabled / laravel”失败(2:否 这样的文件或目录)在/etc/nginx/nginx.conf:62 nginx中: 配置文件/etc/nginx/nginx.conf测试失败
当我在第62行转到该文件时,我看到了:
include /etc/nginx/sites-enabled/*;
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
这是我的文件/etc/nginx/sites-available/laravel.conf
server {
listen 80;
listen [::]:80 ipv6only=on;
# Log files for Debugging
access_log /var/log/nginx/laravel-access.log;
error_log /var/log/nginx/laravel-error.log;
# Webroot Directory for Laravel project
root /var/www/laravel/public;
index index.php index.html index.htm;
# Your Domain Name
server_name 99.80.169.66;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM Configuration Nginx
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
这是我的文件/var/www/laravel/.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
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=laravel
DB_PASSWORD=66345345
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}"
答案 0 :(得分:1)
尝试一下 1.安装Nginx
`apt-get install nginx`
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json
3。安装mysql服务器
sudo apt install mysql-server
sudo mysql_secure_installation
全部输入密码和y
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password'
;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';
用于远程sql服务器的设置
nano /etc/mysql/mysql.conf.d/mysqld.cnf
绑定地址= 127.0.0.1 至: 绑定地址= 0.0.0.0
systemctl restart mysql.service
sudo mysql
CREATE USER 'sid'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON *.* TO 'sid'@'localhost'
-> WITH GRANT OPTION;
CREATE USER 'sid'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON *.* TO 'sid'@'%'
-> WITH GRANT OPTION;
apt-get install composer
apt install redis-server
nano /etc/redis/redis.conf
更改文字 `
supervised no
to
supervised systemd
重新启动Redis
systemctl restart redis.service
测试Redis redis-cli ping 回复傍
更改redis密码
nano /etc/redis/redis.conf 取消注释#requirepass foobared
完整详细信息在这里 https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04
curl -sL https://deb.nodesource.com/setup_11.x |须藤-E bash- sudo apt-get install -y nodejs
curl -sL https://deb.nodesource.com/setup_11.x |重击- apt-get install -y nodejs
8。上传站点 9,许可 sudo chown -R www-data:www-数据存储/ sudo chown -R www-data:www-data public /
server {
listen 80;
listen [::]:80;
root /home/sid/website/searustasia/public;
index index.php index.html index.htm;
listen 443 ssl;
ssl_certificate /home/sid/website/searustasia/ssl/searustasia.crt;
ssl_certificate_key /home/sid/website/searustasia/ssl/searustasia.key;
server_name api.searustasia.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
别忘了重启nginx