Laravel从Homestead开发环境移到Ubuntu生产环境(1) - Ubuntu16.04 生产环境安装

谷梁翰飞
2023-12-01

1. 参考 https://github.com/summerblue/laravel-ubuntu-init

其中会遇到问题:Error in `appstreamcli': double free or corruption (fasttop): 0x0000000002122000

解决办法:https://blog.csdn.net/taosera/article/details/78148845

 

2. 之后按照laravel-ubuntu-init里面的创建站点项目monitor,再创建sql的root用户名,默认生成一串难记的密码,为了和自己的项目匹配,按照下贴修改mysql的root用户名的密码:

https://www.cnblogs.com/roadofstudy/p/7446690.html

其中最关键的几条命令:

> use mysql;

update user set authentication_string=PASSWORD("这里输入你要改的密码"where User='root'; #更改密码

update user set plugin="mysql_native_password"; #如果没这一行可能也会报一个错误,因此需要运行这一行

> flush privileges; #更新所有操作权限

> quit;

 

3. 修改/etc/hosts,添加

127.0.0.1    monitor.com
127.0.0.1    localhost

为了让输入localhost和127.0.0.1以及monitor.com都坊问的是monitor这个站点而不是default站点,要将nginx.conf里面包括的default的server信息去掉,

gedit nginx.conf

将include /etc/nginx/sites-enabled/*;

换成:

include /etc/nginx/sites-enabled/monitor.conf;

 

4. 在/etc/nginx/sites-enable下面有两个配置文件,一个是default,一个是创建monitor站点时生成的monitor.conf。折腾了很久始终无法通过monitor.com的域名访问自己的monitor站点,最后发现是server_name monitor.com后面少打了一个分号。

編辑完monitor.conf之后要重启一下nginx:  service nginx reload

gedit sites-enabled/monitor.conf

server {
    listen 80;
    server_name monitor.com;
    root /var/www/monitor/public;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
    #root /var/www/monitor/public;
        try_files $uri $uri/ /index.php?$query_string;

    #add_header Cache-Control no-cache;
    #add_header Cache-Control private;
    #expires 0s;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log /var/log/nginx/monitor.log;
    error_log /var/log/nginx/monitor-error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }
}

 

 类似资料: