CentOS7上搭建LNMP+Laravel

简介

最近有点痴迷Laravel,用上了阿里云的199一年的活动主机,各种安装。

安装前的准备

安装screen
yum install screen
安装wget
yum install wget
更新yum
yum update
安装额外资源库
yum install epel-release
下载最新的ius
wget https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-15.ius.centos7.noarch.rpm
安装ius
rpm -ivh ius-release-1.0-15.ius.centos7.noarch.rpm 
新建www用户
adduser www
设置密码
passwd www
添加到组
usermod -aG wheel www

安装Nginx

安装nginx
sudo yum install nginx
启动nginx
sudo systemctl start nginx
设置为开机启动
sudo systemctl enable nginx.service

安装MySQL(MariaDB)

安装MariaDB
sudo yum install mariadb-server
启动MariaDB
sudo systemctl start mariadb
设置
sudo /usr/bin/mysql_secure_installation
设置开机启动
sudo systemctl enable mariadb

安装PHP7 ( PHP7.1 )

搜索php-fpm
yum search php71w-fpm
安装
yum install php71w-fpm
查看状态
systemctl status php-fpm
启动
systemctl start php-fpm
设置开机启动
systemctl enable php-fpm
安装常用扩展
yum install php71w-gd php71w-mysqlnd php71w-pdo php71w-mcrypt php71w-mbstring php71w-json php71w-cli -y
重新加载
systemctl reload php-fpm

安装Composer

依次执行
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

全局安装
sudo mv composer.phar /usr/local/bin/composer

别忘记使用中国镜像

参考