如何在CentOS和RHEL上安裝Laravel5

laravel是一個(gè)開源的php框架,設(shè)計(jì)用于在php中更快地開發(fā)mvc web應(yīng)用程序。本篇文章將介紹在centos和rhel系統(tǒng)上安裝laravel5的方法步驟。

如何在CentOS和RHEL上安裝Laravel5

步驟1:設(shè)置yum存儲(chǔ)庫(kù)

首先,需要在系統(tǒng)中添加REMI和EPELRPM存儲(chǔ)庫(kù)。這些存儲(chǔ)庫(kù)已經(jīng)更新了包。根據(jù)你的操作系統(tǒng)版本和系統(tǒng)架構(gòu)使用以下命令之一。

###?On?CentOS/RHEL?-?7?### #?rpm?-Uvh?http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm #?rpm?-Uvh?http://rpms.famillecollet.com/enterprise/remi-release-7.rpm   ###?On?CentOS/RHEL?-?6?### #?rpm?-Uvh?http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #?rpm?-Uvh?http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

步驟2:安裝apachemysql和PHP

安裝Apache

#?yum?--enablerepo=remi,epel?install?httpd

安裝 MySQL

#?yum?--enablerepo=remi,epel?install?mysql-server #?service?mysqld?start #?/usr/bin/mysql_secure_installation

安裝PHP

#?yum?--enablerepo=remi,epel?install?php?php-zip?php-mysql?php-mcrypt?php-xml?php-mbstring #?service?httpd?restart

步驟3:安裝composer

安裝laravel依賴項(xiàng)需要composer。因此,使用下面的命令下載并在我們的系統(tǒng)中使用命令。

#?curl?-sS?https://getcomposer.org/installer?|?php #?mv?composer.phar?/usr/bin/composer #?chmod?+x?/usr/bin/composer

步驟4:安裝Laravel

要下載最新版本的Laravel,請(qǐng)使用下面的命令從github克隆Laravel的主頁(yè)

#?cd?/var/www #?git?clone?https://github.com/laravel/laravel.git

導(dǎo)航到laravel代碼目錄,并使用composer安裝laravel框架所需的所有依賴項(xiàng)。

#?cd?/var/www/laravel #?composer?install

依賴項(xiàng)安裝需要一些時(shí)間。之后,對(duì)文件設(shè)置適當(dāng)?shù)臋?quán)限。

#?chown?-R?apache.apache?/var/www/laravel #?chmod?-R?755?/var/www/laravel #?chmod?-R?755?/var/www/laravel/storage

啟用SELinux的系統(tǒng)還運(yùn)行下面的命令以允許對(duì)存儲(chǔ)目錄進(jìn)行寫入。

#?chcon?-R?-t?httpd_sys_rw_content_t?/var/www/laravel/storage

步驟5:設(shè)置加密密鑰

Laravel使用.evn文件進(jìn)行環(huán)境配置。使用.evn文件配置應(yīng)用程序的所有環(huán)境變量,如數(shù)據(jù)庫(kù)、SMTP、安全密鑰等。

#?cp?.env.example?.env

現(xiàn)在設(shè)置32位長(zhǎng)的隨機(jī)數(shù)加密密鑰,該密鑰由照明加密服務(wù)使用。

#?php?artisan?key:generate Application?key?set?successfully.

你可以查看.env文件以查找已配置的應(yīng)用程序密鑰。

步驟6:創(chuàng)建Apache虛擬主機(jī)

現(xiàn)在在Apache配置文件中添加一個(gè)虛擬主機(jī),以便從Web瀏覽器訪問(wèn)Laravel框架。為此,編輯apache配置文件/etc/httpd/conf/httpd.conf并在文件末尾添加以下代碼

#?vim?/etc/httpd/conf/httpd.conf

File: /etc/httpd/conf/httpd.conf

<virtualhost> ???????ServerName?laravel.example.com ???????DocumentRoot?/var/www/laravel/public  ???????<directory> ??????????????AllowOverride?All ???????</directory></virtualhost>

重新啟動(dòng)Apache服務(wù),使用你最喜歡的Web瀏覽器訪問(wèn)Laravel框架,并開始開發(fā)一個(gè)Web應(yīng)用程序。

#?service?httpd?restart

現(xiàn)在可以在網(wǎng)絡(luò)瀏覽器中訪問(wèn)Laravel網(wǎng)站。

本篇文章到這里就已經(jīng)全部結(jié)束了,更多其他精彩內(nèi)容大家可以關(guān)注PHP中文網(wǎng)的PHP視頻教程欄目!

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊15 分享