centos 7系統(tǒng)下安裝laravel運行環(huán)境的步驟詳解
前言
因為最近在學習linux,而最好的學習就是實踐,學習linux同時安裝LAMP的環(huán)境搭配,跑了度娘都沒找到我想要的文章。那我就簡單的寫寫我在centos7下安裝laravel的安裝過程。
網絡設置
ping 114.114.114.144 網絡連接失敗,將虛擬機的網絡適配器改成橋接模式(自動),然后設置開啟啟動
打開 /etc/sysconfig/network-scripts/ifcfg-eno16777736,ifcfg-eno16777736是自己對應的配置文件
將里面的ONBOOT改為yes,重啟網絡服務`systemctl restart network`, 再ping就ok了
升級
//升級所有包同時也升級軟件和系統(tǒng)內核 yum -y update
SELinux 寬容模式保證安裝過程不受影響,其次在項目中,也要關閉
setenforce 0
安裝Apache
//安裝 yum -y install httpd //同時安裝vim yum install vim //修改Apache配置文件指向路徑 /etc/httpd/conf/httpd.conf //啟動Apache systemctl start httpd //停止Apache systemctl stop httpd //重啟Apache systemctl restart httpd //查看Apache狀態(tài) systemctl status httpd // 配置Apache開機啟動項 /*chkconfig --add httpd (在服務清單中添加httpd服務)*/ chkconfig httpd on
安裝MySql
//如果必須要安裝MySQL,首先必須添加mysql社區(qū)repo通過輸入命 sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm //最后使用像安裝MySQL的常規(guī)方法一樣安裝 //安裝mysql命令 yum -y installmysql mysql-devel mysql-server mysql-libs //創(chuàng)建root用戶密碼 mysqladmin -u root password 密碼 //如果要用外部軟件連接數(shù)據庫關閉防火墻 systemctl stop firewalld //查看防火墻狀態(tài) firewall-cmd --state //禁止firewall開機啟動 systemctl disable firewalld //設置遠程連接 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; //重啟mysql systemctl restart mysqld cd ..//
安裝PHP5.6
//系統(tǒng)默認安裝的是php5.4,對于使用laravel就不行的,以下是CentOS 7.0的epel及remi源。 yum -y install epel-release rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm //使用yum list命令查看可安裝的包(Packege)。 yum list --enablerepo=remi --enablerepo=remi-php56 | grep php //安裝php5.6及部分擴展 yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof //查看版本 php-v
安裝redis
//檢查安裝依賴程序 yum install gcc-c++ yum install -y tcl //獲取安裝文件 wget http://download.redis.io/releases/redis-3.2.9.tar.gz tar xzf redis-3.2.9.tar.gz mv redis-3.2.9 /usr/local/redis //進入目錄 cd /usr/local/redis //編譯安裝 make && make install (可能需要 make test 根據提示) //設置配置文件目錄 mkdir -p /etc/redis cp redis.conf /etc/redis //修改配置文件 vim /etc/redis/redis.conf daemonize yes (no -> yes) //啟動 /usr/local/bin/redis-server /etc/redis/redis.conf //查看啟動 ps -ef | grep redis //使用客戶端測試 redis-cli set name darry Ok get name 'darry' //關閉客戶端 redis-cli shutdown
沒有設置開機自啟動,要設置[點擊這里][1]
安裝composer
sudo curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer sudo chmod +x /usr/local/bin/composer
用戶操作獲得root權限
//添加一個名為darry的用戶 adduser darry //修改密碼 passwd darry //修改密碼 Changing password for user darry New UNIX password: //在這里輸入新密碼 Retype new UNIX password: //再次輸入新密碼 passwd: all authentication tokens updated successfully. //修改用戶權限 修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示: ## Allow root to run any commands anywhere root ALL=(ALL) ALL darry ALL=(ALL) ALL
修改完畢,現(xiàn)在可以用darry帳號登錄,然后用命令 su - darry
,即可獲得root權限進行操作。
通過composer安裝laravel
//這里使用默認的apache網站目錄var/www/html,根據個人項目情況 //修改 composer 的全局配置文件(推薦方式) composer config -g repo.packagist composer https://packagist.phpcomposer.com cd /var/www/html sudo chmod -R 777 /var/www/html //在創(chuàng)建項目的時候注意,在root用戶下避免不安全,composer會提示,然后用另外用戶登錄 composer create-project laravel/laravel blog 5.1.11 //安裝5.1 composer create-project laravel/laravel=5.2.* blog --prefer-dist //安裝的5.2 //修改laravel權限 cd blog sudo chmod -R 777 storage sudo chmod -R 777 vendor //檢查安裝依賴程序 yum install gcc-c++ yum install -y tcl
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關文章
Laravel 在views中加載公共頁面的實現(xiàn)代碼
今天小編就為大家分享一篇Laravel 在views中加載公共頁面的實現(xiàn)代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10thinkphp在php7環(huán)境下提示Cannot use ‘String’ as class name as it is
這篇文章主要介紹了thinkphp在php7環(huán)境下提示Cannot use ‘String’ as class name as it is reserved的解決方法,涉及thinkPHP針對php7關鍵字判定的相關底層代碼修改技巧,需要的朋友可以參考下2016-09-09PHP使用Session遇到的一個Permission denied Notice解決辦法
這篇文章主要介紹了PHP使用Session遇到的一個Permission denied Notice解決辦法,本文系統(tǒng)環(huán)境是ubuntu、Debian系統(tǒng),有很小的概率會遇到這個提示,需要的朋友可以參考下2014-07-07laravel框架使用FormRequest進行表單驗證,驗證異常返回JSON操作示例
這篇文章主要介紹了laravel框架使用FormRequest進行表單驗證,驗證異常返回JSON操作,涉及l(fā)aravel表單請求類的創(chuàng)建、使用及異常處理相關操作技巧,需要的朋友可以參考下2020-02-02Thinkphp5.0 框架實現(xiàn)控制器向視圖view賦值及視圖view取值操作示例
這篇文章主要介紹了Thinkphp5.0 框架實現(xiàn)控制器向視圖view賦值及視圖view取值操作,結合實例形式分析了thinkPHP控制器向視圖傳值及從視圖取值相關操作技巧,需要的朋友可以參考下2019-10-10