CentOS 7安裝LAMP環境及Laravel框架

一、服務器安裝源配置

sudo yum install epel-release
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum update

二、SELinux 寬容模式保證安裝過程不受影響

sudo setenforce 0

三、Apache, MariaDB, PHP 安裝

Laravel 安裝程序須要完成安裝 LAMP 整個環境,須要額外安裝 OpenSSLPDOMbstringTokenizer 等 PHP 擴展。若是 LAMP 已經安裝並正常能夠正常運行能夠跳過這一步。php

sudo yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring

Apache、Mariadb 服務開機自動啓動html

sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb

四、安裝Composer

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

五、安裝Laravel框架

這裏使用默認的apache網站目錄/var/www/htmlmysql

cd /var/www/html
sudo chmod -R 777 /var/www/html
composer create-project laravel/laravel blog 5.1.11
cd blog
sudo chmod -R 777 storage
sudo chmod -R 777 vendor

六、配置虛擬主機

進入Apache虛擬主機目錄laravel

cd /etc/httpd/conf.d

新建立一個虛擬主機配置文件,假設現有的域名爲blog.com,爲了方便識別,這裏建立blog.confweb

sudo touch blog.conf

編輯blog.confsql

sudo vi blog.conf

參照如下內容輸入,郵箱、域名和網站主目錄根據本身的狀況修改apache

<VirualHost *:80>
    ServerAdmin admin@blog.com
    ServerName blog.com
    ServerAlias www
    DocumentRoot /var/www/html/blog/public
    
    <Directory "/var/www/html/blog/public">
        Options FollowSymLinks
        AllowOverride All
    </Directory>
</VirualHost>

輸入完成保存,重啓Apache瀏覽器

sudo systemctl restart httpd

瀏覽器訪問你的域名測試!服務器

相關文章
相關標籤/搜索