安裝lnmp環境
安裝redis
安裝nodejs npm
nodejs分8.x和10.x,這里用10.x的,如果需要用8.x,就換成setup_8.x
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
yum -y install nodejs npm
參考:Linuxhint - CentOS安裝nodejs、npm
服務器運行Laravel
創建.env文件,並配置相關參數
1、創建.env
文件(從模板.env.example
文件復制來)
cp .env.example .env
2、配置參數
(1)默認文件中是沒有app_key的,需要手動生成APP_KEY
php artisan key:generate
(2)生成后訪問網站
遇到的問題
【1】、修改了虛擬主機配置文件后,重啟nginxservice nginx restart
的時候,報錯:
Redirecting to /bin/systemctl restart nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
原因: 配置文件末尾少了';'
操作:在缺少分號結尾的行尾加上分號
參考:
DigitalOcean - Can't start Nginx - Job for nginx.service failed
【2】、執行yum install
時,返回yum except KeyboardInterrupt, e
錯誤
原因: /usr/bin/yum
執行程序是使用python命令進行執行的,由於之前操作,將python默認的2.7版本替換成了3.7,導致yum
程序的語法不支持,繼而報錯。
參考: CSDN - yum except KeyboardInterrupt, e: 錯誤
【3】、加載好laravel項目后,執行composer install
后報The Process class relies on proc_open, which is not available on your PHP installation.
原因:php.ini
文件配置中,禁用了proc_open
、proc_get_status
等方法。
解決:vim /usr/local/php72/etc/php.ini,找到disable_functions
,然后刪除proc_open
、proc_get_status
,然后再執行composer install
。(如果執行后還有其他輸出信息說方法disabled,同樣的在相應位置刪除即可)