安装CentOS7
由云平台提供,此步骤略过
安装Nginx
yum install nginx -y
systemctl start nginx #启动nginx
systemctl enable nginx #开机自动启动
测试:开启云平台80端口,直接浏览器输入IP地址,即可显示nginx初始页面
安装PHP
yum install php php-devel php-fpm php-gd php-mbstring php-mysql -y
systemctl start php-fpm #启动php-fpm
systemctl enable php-fpm #开机自动启动
若采用SQLite方式,可能还需要以下步骤
yum install php-pdo -y
查看php运行状况,使用情况:
netstat -tln|grep 9000 #php-fpm默认使用9000端口
若无netstat命令,可能需要安装工具包
yum install net-tools #安装net-tools工具包
安装说明:
Nginx:提供nginx主程序
Php:PHP主程序含给apache使用的模块
Php-devel:PHP的发展工具,这个与PHP外挂的加速软件有关
Php-mysql:提供给PHP程序读取mysql数据库的模块
php-gd:php处理图形的扩展库,使用GD库可以处理图片或生成图片。如验证码
php-mbstring:扩展库,用于处理多字节字符串
php-fpm:使用PHP-FPM来控制PHP-CGI的FastCGI进程
安装MySQL
因使用SQLite,此步省略
参数配置
配置PHP
vim /etc/php-fpm.d/www.conf #修改php-fpm配置文件,把apache改为nginx
查找apache,修改user和group的执行用户为nginx
配置Nginx
cd /etc/nginx/ #配置目录
cp nginx.conf nginx.conf.bak #备份
vim nginx.conf #修改
修改server如下:
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
index index.html index.htm index.php;#添加首页
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# 添加参数
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location ~ .*\.php(\/.*)*$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
上传typecho(1.1.17)
wget http://typecho.org/downloads/1.1-17.10.30-release.tar.gz #下载
tar -zxvf 1.1-17.10.30-release.tar.gz #解压
rm /usr/share/nginx/html/* -Rf #删除原有所有文件,可选
mv build/* /usr/share/nginx/html/
chown nginx:nginx /usr/share/nginx/html/ #修改文件所属,未验证
chown nginx:nginx /usr/share/nginx/html/* #修改文件所属
进入首页正常即可访问
评论 (0)