一.安装nginx
1.yum -y install epel-release
QQ图片20191018105057.png
2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm ##更新安装包
image.png
3. yum install -y nginx ##直接安装nginx
出现 Installed 代表安装成功
image.png
4、启动Nginx并设置开机自动运行
systemctl start nginx.service ##启动nginx服务
systemctl enable nginx.service ##设置nginx开机启动
二.安装mysql5.7
前提上有在上面安装nginx过程中,更新过安装源与安装包
1
1. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
##下载并安装MySQL官方的 Yum Repository,提示 wget: command not found 就自己安装wget ; yum -y install wget
2. yum -y install mysql57-community-release-el7-10.noarch.rpm ##更新安装包
3. yum -y install mysql-community-server #开始安装MySQL服务
4. systemctl enable mysqld.service #设置MySQL开机启动
三.安装php
前提上有在上面安装nginx过程中,更新过安装源与安装包
1.yum install php72w ##安装php7.2
2.yum install php72w-fpm ##安装php-fpm
6.systemctl start php-fpm ##之后 systemctl enable php-fpm 将php服务设置为启动
7.yum install php72w-cli ##安装php客户端,支持控制台php命令
centos7及其以上系统。
安装vimplus(建议在普通用户下安装 ,更强大的vim编辑器,可以跳过此步骤)
git clone https://github.com/chxuan/vimplus.git ~/.vimplus
cd ~/.vimplus
./install.sh
nginx 与php关联:
在http模块中添加配置:
server {
listen 80;
server_name www.nginx.com;
root /usr/share/nginx/html;
location / {
index index.html index.htm index.php;
}
location ~ \.php(.*)$ {
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}