修改主機(jī)名
# hostnamectl set-hostname <host-name>
修改密碼
# passwd
更新yum
#yum update
yum源修改為阿里
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum -y update
安裝apache
yum -y install apache
systemctl start httpd
systemctl enable httpd
其中apache的主要目錄以及用途
服務(wù)目錄 /etc/httpd
主配置文件 /etc/httpd/conf/httpd.conf
網(wǎng)站數(shù)據(jù)目錄 /var/www/html
訪問日志 /var/log/httpd/access_log
錯誤日志 /var/log/httpd/error_log
主要參數(shù)有
ServerRoot 服務(wù)目錄
ServerAdmin 管理員郵箱
User 運行服務(wù)的用戶
Group 運行服務(wù)的用戶組
ServerName 網(wǎng)站服務(wù)器的域名
DocumentRoot 網(wǎng)站數(shù)據(jù)目錄
Listen 監(jiān)聽的IP地址與端口號
DirectoryIndex 默認(rèn)的索引頁頁面
ErrorLog 錯誤日志文件
CustomLog 訪問日志文件
Timeout 網(wǎng)頁超時時間,默認(rèn)為300秒.
Include 需要加載的其他文件
配置php
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum list php*
yum -y install php72w
yum -y install php72w-cli php72w-common php72w-devel php72w-mysql
yum -y install php72w-gd php72w-imap php72w-ldap php72w-odbc php72w-pear php72w-xml php72w-xmlrpc
find / -name php.ini
find / -name httpd.conf
在httpd.conf最后加上
PHPIniDir /etc/php.ini 讓httpd知道php的配置信息
ps aux | grep httpd
打開防火墻80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --query-port=80/tcp
systemctl restart httpd
php -v