《PHP應用:centos 7系統下安裝laravel運行環境的步驟詳解》要點:
本文介紹了PHP應用:centos 7系統下安裝laravel運行環境的步驟詳解,希望對您有用。如果有疑問,可以聯系我們。
前言PHP學習
因為最近在學習linux,而最好的學習就是實踐,學習linux同時安裝LAMP的環境搭配,跑了度娘都沒找到我想要的文章.那我就簡單的寫寫我在centos7下安裝laravel的安裝過程.PHP學習
網絡設置PHP學習
ping 114.114.114.144 網絡連接失敗,將虛擬機的網絡適配器改成橋接模式(自動),然后設置開啟啟動
PHP學習
打開 /etc/sysconfig/network-scripts/ifcfg-eno16777736,ifcfg-eno16777736是自己對應的配置文件
PHP學習
將里面的ONBOOT改為yes,重啟網絡服務`systemctl restart network`, 再ping就ok了
PHP學習
升級
PHP學習
//升級所有包同時也升級軟件和系統內核 yum -y update
SELinux 寬容模式保證安裝過程不受影響,其次在項目中,也要關閉PHP學習
setenforce 0
安裝Apache
PHP學習
//安裝 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狀態 systemctl status httpd // 配置Apache開機啟動項 /*chkconfig --add httpd (在服務清單中添加httpd服務)*/ chkconfig httpd on
安裝MySqlPHP學習
//如果必須要安裝MySQL,首先必須添加mysql社區repo通過輸入命 sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm //最后使用像安裝MySQL的常規方法一樣安裝 //安裝mysql命令 yum -y installmysql mysql-devel mysql-server mysql-libs //創建root用戶密碼 mysqladmin -u root password 密碼 //如果要用外部軟件連接數據庫關閉防火墻 systemctl stop firewalld //查看防火墻狀態 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
PHP學習
//系統默認安裝的是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
安裝redisPHP學習
//檢查安裝依賴程序 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]PHP學習
安裝composer
PHP學習
sudo curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer sudo chmod +x /usr/local/bin/composer
用戶操作獲得root權限
PHP學習
//添加一個名為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
修改完畢,現在可以用darry帳號登錄,然后用命令 su - darry
,即可獲得root權限進行操作.PHP學習
通過composer安裝laravelPHP學習
//這里使用默認的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 //在創建項目的時候注意,在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
總結PHP學習
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持.PHP學習
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/264.html