nginx 安装
执行命令安装 EPEL
yum install epel-release -y
现在执行安装nginx,命令如下:
yum install nginx -y
设置开机启动nginx:
systemctl start nginx
systemctl enable nginx.service
现在输入你服务器的 IP 地址就能见到 Nginx 的欢迎页了
MariaDB 的安装
执行命令安装数据库:
yum install mariadb-server mariadb -y
安装完毕后,和nginx 一样,设置开机启动,并初始化:
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
设置数据库密码 ,之后的全部回车默认选择
安装PHP
设置centos7的php7安装源:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php7.2和各种扩展:
yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
启动php 然后 设置开机启动
systemctl start php-fpm
systemctl enable php-fpm.service
安装composer
curl -sS https://getcomposer.org/installer | php
把composer.phar移动到环境下让其变成可执行
mv composer.phar /usr/local/bin/composer
测试
composer -V
设置 composer 国内镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
配置nginx支持php
执行命令 修改nginx配置
vim /etc/nginx/conf.d/default.conf
server段中去掉下面的注释,并更改成如下配置:
location ~ \.php$ {root /usr/share/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
修改配置完成后,重启nginx 服务:
systemctl reload nginx