軟體 | 版本 | |
PHP | php7.3 | |
WebService | nginx | |
FRAMEWORK | Laravel8 | |
OS | centos7.2 |
1.安裝相關套件
yum update
yum install wget
yum install epel-release //更新後才可執行 sudo yum install php-mcrypt*
sudo yum install php-mcrypt* //laravel 會使用到的套件
sudo yum install php-xml //laravel 會使用到的套件
2.安裝 nginx
//nginx install
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
開通80port服務
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
vi /etc/nginx/conf.d/default.conf
將內容整個砍掉 ,複製貼上底下內容即可
( 注記得修改 root /usr/share/nginx/html/{app-name}/public 位置)
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html/APP-name/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_connect_timeout 159s;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_pass_header Set-Cookie;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_ignore_headers Cache-Control Expires;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
3.安裝PHP7.3
安裝 php5.4
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install php-mbstring //laravel 會使用到的套件
yum install php php-mysql php-fpm
更新到 php7.2
yum install epel-release yum-utils -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php72
yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql -y
更新到 php7.3
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install epel-release yum-utils
sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73
4.修改PHP設定檔
修改 php設定檔
/etc/php7/fpm/php-fpm.d/www.conf
有些是放在 /etc/php-fpm.d/www.conf
如果你是用nginx就改成nginx 是apache就改apache
user = nginx
group = nginx
listen = /var/run/php7.3-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
5.調整nginx conf設定
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php7.3-fpm.sock;
fastcgi_pass 調整為 /var/run/php7.3-fpm.sock
6.安裝 composer
sudo yum install php-cli php-zip wget unzip
找一位置放置 composer-setup
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
並在此位置下 執行
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
7.使用composer建立專案
composer create-project laravel/laravel app-name --ignore-platform-reqs
php artisan --version //確認安裝版本
Laravel Framework 8.28.1
沒有留言:
張貼留言