centos 7系统下安装laravel运行环境的步骤详解

Laravel框架对于开发网页应用来说是一个绝好的的工具,最近正好又在学习linux系统,所以下面这篇文章主要给大家介绍了在centos 7系统下安装laravel运行环境的步骤,需要的朋友可以参考借鉴,下面跟着小编来一起学习学习吧。

前言

因为最近在学习linux,而最好的学习就是实践,学习linux同时安装LAMP的环境搭配,跑了度娘都没找到我想要的文章。那我就简单的写写我在centos7下安装laravel的安装过程。

网络设置

ping 114.114.114.144 网络连接失败,将虚拟机的网络适配器改成桥接模式(自动),然后设置开启启动

打开 /etc/sysconfig/network-scripts/ifcfg-eno16777736,ifcfg-eno16777736是自己对应的配置文件

将里面的ONBOOT改为yes,重启网络服务`systemctl restart network`, 再ping就ok了

升级

 //升级所有包同时也升级软件和系统内核 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状态 systemctl status httpd // 配置Apache开机启动项 /*chkconfig --add httpd (在服务清单中添加httpd服务)*/ chkconfig httpd on

安装MySql

 //如果必须要安装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

 //系统默认安装的是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

修改完毕,现在可以用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 //在创建项目的时候注意,在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

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对html中文网的支持。

以上就是centos 7系统下安装laravel运行环境的步骤详解的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » PHP编程