网站搭建

安装php

# 安装基础环境
$ dnf group install "Development Tools"
$ dnf -y install libxml2-devel openssl-devel sqlite-devel libcurl-devel libicu-devel gcc-c++ oniguruma libxslt-devel libpng-devel libjpeg-devel freetype-devel
# 编译安装iconv
$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
$ tar xvzf libiconv-1.16.tar.gz
$ cd libiconv-1.16
$ ./configure --prefix=/usr/local/libiconv-1.16
$ make && make install
$ ln -s  /usr/local/libiconv-1.16 /usr/local/libiconv
# 编译安装 oniguruma
$ wget https://github.com/kkos/oniguruma/archive/v6.9.6.tar.gz -O oniguruma-6.9.6.tar.gz
$ tar -zxvf oniguruma-6.9.6.tar.gz
$ cd oniguruma-6.9.6
$ ./autogen.sh && ./configure --prefix=/usr
$ make && make install
# 编译安装 libzip。先用dnf源,方便升级维护
$ dnf -y install libzip libzip-devel
## 模式二,编译安装libzip
$ dnf remove -y libzip
#下载编译安装
$ wget https://nih.at/libzip/libzip-1.7.3.tar.gz
$ tar -zxvf libzip-1.7.3.tar.gz
$ cd libzip-1.7.3
$ ./configure
$ make && make install
# 安装php
$ wget https://www.php.net/distributions/php-8.0.0.tar.gz
$ tar zxvf php-8.0.0.tar.gz 
$ cd php-8.0.0/
$ ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-sockets --with-zip --enable-calendar --enable-bcmath --enable-mbstring --with-zlib --with-iconv=/usr/local/libiconv --enable-gd --enable-mbstring --with-curl --with-freetype --disable-ipv6 --disable-debug --with-openssl --enable-intl --enable-opcache
$ make && make install
# 环境配置
$ ln -s /usr/local/php/bin/php /usr/bin/php 
$ cp php.ini-development /usr/local/php/etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
$ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf 

安装Nginx

# 安装基础依赖
$ dnf -y install pcre pcre-devel zlib zlib-devel
# 编译安装
$ wget http://nginx.org/download/nginx-1.19.6.tar.gz
$ tar -zxvf nginx-1.19.6.tar.gz
$ cd nginx-1.19.6
$ ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.19.6 --with-http_stub_status_module --with-http_ssl_module
$ make && make install

Nginx整合PHP

# 在nginx.config 中
# 在nginx.config 中
# 修改	
        root   /var/www/html/wordpress;
        index  index.php index.html index.htm;

        location / {
            try_files $uri $uri/ = 404;
        }
        error_page  404              /404.html;

# 放开注释
	   location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

安装Mysql

# 下载官网yum文件。很简单。不需要下庞大的安装文件
$ rpm -i mysql80-community-release-el8-1.noarch.rpm
$ dnf -y install mysql
$ dnf -y install mysql-server
$ systemctl restart mysqld.service

安装WordPress

# 下载解压安装
# 更改目录权限
$ chown nginx:root -R wordpress/

Leave a Reply

Your email address will not be published. Required fields are marked *

lWoHvYe 无悔,专一