做以下步骤以前,检查阿里云相关端口,及服务器防火墙
1、更新包:apt update
2、安装git
1)apt-get install git
2) 检查是否安装成功:git --version
3) 安装项目:git clone 仓库地址,如果是码云仓库需要配置ssh公钥
3、安装systemctl:服务管理,apt-get install systemctl
4、安装php、php-fpm:api-get install php php-fpm
5、安装composer:
1) curl -sS https://getcomposer.org/installer | php
2) mv composer.phar /usr/local/bin/composer
3) 配置阿里云:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
6、使用composer安装项目:
composer install
报错:requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
解决:apt-get install php-mbstring
报错:requires ext-curl * -> the requested PHP extension curl is missing from your system.
解决: apt-get install php-curl
报错:requires ext-dom * -> the requested PHP extension dom is missing from your system.
解决:apt-get install php-dom
报错:requires ext-gd * -> the requested PHP extension gd is missing from your system.
解决:apt-get install php-gd
报错:requires ext-zip * -> the requested PHP extension zip is missing from your system.
解决:apt-get install php-zip
报错:requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
解决:apt-get install php-bcmath
7、nginx
1) 安装:apt-get install nginx
2) 检查安装:nginx -v
3) 检查配置文件:nginx -t
4) 配置:
server {
listen 443;
server_name 域名;
index index.html index.htm index.php;
root 项目根目录;
charset utf-8;
ssl on;
ssl_certificate 证书地址;
ssl_certificate_key 证书私钥地址;
ssl_session_timeout 5m;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log 日志文件地址;
error_log 错误日志地址;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /storage {
alias /home/shanhu_travel/storage/app/public;
autoindex on;
}
sendfile off;
client_max_body_size 100m;#请求体最大值
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
}
#http转https
server {
listen 80;
server_name 域名;
return 307 https://$server_name$request_uri;#该出只能为307,否则http转到https时请求方法及请求数据没有
#rewrite ^(.*)$ https://$host$1;
}
8、mysql8.0:
1)安装:apt-get install mysql-server mysql-client
2) 设置密码: mysql_secure_installation,按提示操作,如果没法设置,则执行mysqld --initialize --user=mysql --console
操作https://www.cnblogs.com/llb123/p/13398701.html
3) 远程连接:ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '密码';FLUSH PRIVILEGES;
本文详细介绍了在阿里云服务器上部署PHP项目的步骤,包括更新包、安装Git、Composer、PHP及其扩展、Nginx、MySQL等,解决了在安装过程中可能遇到的常见问题。

1345

被折叠的 条评论
为什么被折叠?



