最近把vps系统重新安装了一下,更换了系统模版为CentOS7。命令和CentOS6有所不同。
1、更新系统
yum makecache fast
yum update
2、安装apache
yum install httpd
3、安装数据库mariadb
yum install mariadb mariadb-server mariadb-devel
4、安装php和常用库
php php-devel php-common php-cli php-mbstring php-gd php-bcmath php-pdo php-pear php-xml php-xmlrpc php-mysqlnd
5、启动httpd、mysqld
systemctl start httpd.service
systemctl start mariadb.service
6、设置开机自启动服务
systemctl enable httpd.service
systemctl enable mariadb.service
7、配置apache
vim /etc/httpd/conf/httpd.conf
1)添加php支持
找到:
DirectoryIndex index.html
改为:
DirectoryIndex index.html index.php
找到:
AddType application/x-gzip .gz .tgz
在其下面加上以下内容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2)添加伪静态
AllowOverride All
# Allow open access:
Require all granted
3)在文件末尾添加虚拟主机配置
DocumentRoot "/home/live-in.org"
ServerName www.live-in.org
ErrorLog logs/live-in.org-error_log
CustomLog logs/live-in.org-access_log common
DeflateCompressionLevel 5
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/x-javascript
DocumentRoot "/var/www/html"
ServerName xxx.xxx.xxx.xxx
PS:xxx.xxx.xxx.xxx填服务器IP
4)调整prefork进程数
StartServers 2
MinSpareServers 2
MaxSpareServers 3
MaxClients 4
MaxRequestsPerChild 500