1. 安装系统
CentOS-7-x86_64-Minimal-1708.iso
2. 配置网络(默认没有开启网络)
//确认网卡名字
# ip addr
//修改相应网卡文件
# vi /etc/sysconfig/network-scripts/ifcfg-ens33
//网卡文件配置,添加并修改相应配置
BOOTPROTO=static
ONBOOT=yes
IPADDR0=192.167.75.254
PREFIX0=24
GATEWAY0=192.168.75.2
DNS1=114.114.114.114
//重启网络服务
# systemctl restart network
3. 修改时区
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# date
4. 安装wget(居然没有这个)
# yum -y install wget
5. 修改为阿里源
# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# cd /etc/yum.repos.d/
# wget http://mirrors.aliyun.com/repo/Centos-7.repo
# yum clean all
# yum makecache
6. 安装并配置vim
# yum -y install vim
//安装git(可以不配置,直接用,不过不显示行号)
# yum -y install git
# wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x7. 安装并开启SSH
# yum list installed | grep openssh-server
# yum -y install openssh-server
//配置ssh服务
# vim /etc/ssh/sshd-config
//修改sshd-config文件
Port 22
ListenAddress 0.0.0.0
ListenAddress : :
PasswordAuthentication yes
//开启SSH服务
# systemctl start sshd
//将SSH加入开机启动
# systemctl enable sshd
#systemctl list-unit-files | grep sshd
//使用secureCRT连接,但不要使用root连接(因为没配置该选项)
8. 安装oh-my-zsh(个人喜好,觉得没必要可以跳过此步)
//安装zsh
# yum -y install zsh
//安装curl
# yum -y install curl
//安装git
# yum -y install git
//安装oh-my-zsh
# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
9. 安装Nginx
# rpm --import http://nginx.org/keys/nginx_signing.key
# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# yum -y install nginx
# systemctl start nginx
# systemctl enable nginx
# firewall-cmd --zone=public --add-port=80/tcp --permanent
# firewall-cmd --reload
10. 安装 MySQL(MariaDB)
# yum -y install mariadb-server mariadb
# systemctl start mariadb
# systemctl enable mariadb
//配置数据库(设置root密码,后面一路回车)
# mysql_secure_installation
11. 安装PHP
# yum - y install php php-mysql php-fpm
//配置PHP处理器
# vim /etc/php.ini
cgi.fix_pathinfo=0
date.timezone = PRC
//打开 php-fpm 配置文件 www.conf
# vim /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock
isten.owner = nobody
listen.group = nobody
user = nginx
group = nginx
# systemctl start php-fpm
# systemctl enable php-fpm
12. 配置Nginx来处理PHP页面
# vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name server_domain_name_or_IP;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
//修改Nginx默认工作线程数
# grep processor /proc/cpuinfo | wc -l
# vim /etc/nginx/nginx.conf
worker_processes 2;
# systemctl enable nginx
# systemctl restart nginx
13. 测试PHP代码
# vim /usr/share/nginx/html/info.php
<?php phpinfo(); ?>
14. 浏览器打开测试页面
http://服务器IP地址
http://服务器IP地址/info.php
参考文章:
1. 《CentOS 7的网络配置以及设置主机名和绑定IP的问题》 https://www.linuxidc.com/Linux/2015-05/117703.htm
2. 《CentOS7修改时区的正确姿势》 https://blog.csdn.net/yin138/article/details/52765089
3. 《centos7 修改yum源为阿里源》 https://blog.csdn.net/jameshadoop/article/details/54881295
4. 《CentOS 7更改yum源与更新系统》 https://www.linuxidc.com/Linux/2017-01/140067.htm
5. 《Centos 7系统下的vim配置》 https://blog.csdn.net/qq_35032155/article/details/69666220
6. 《虚拟机下CentOS7开启SSH连接》 https://blog.csdn.net/tuntun1120/article/details/65443757
7. oh-my-zsh官网 http://ohmyz.sh
8. 《利用Oh-My-Zsh打造你的超级终端》 https://blog.csdn.net/czg13548930186/article/details/72858289
9. 《在CentOS服务器上安装配置LEMP的详细教程》 http://www.jb51.net/os/RedHat/343043.html
10. 《CentOS 7 上安装 LNMP(LEMP)服务 Linux,Nginx,MySQL,PHP》 https://www.linuxidc.com/Linux/2017-05/143867.htm