lnmp

时间:2022-10-15 18:53:57

首先准备3台服务器

192.168.1.200(nginx)

192.168.1.201(PHP)

192.168.1.202(mariadb)

192.168.1.200(nginx)部署

yum install nginx -y

cat>/etc/nginx/conf.d/wordpress.con<<-EOF

server {

       listen       80;

       server_name  www.wordpress.com;

       location / {

           root   /data/wordpress;

           index  index.html index.htm index.php;

       }

       location ~ \.php$ {

           root           /data/wordpress;  #注意这个路径是给PHP用的

           fastcgi_pass   192.168.1.201:9000;

           fastcgi_index  index.php;

           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

           include        fastcgi_params;

       }

}

EOF

rz 下载本机的wordpress-5.4.tar.gz

tar xf wordpress-5.4.tar.gz

mkdir /data

mv wordpress /data &&nginx

192.168.1.201(PHP)部署##这里一定要注意wordpress兼容的PHP版本

mkdir /data 

scp ​​root@192.168.1.200​​:/root/wordpress /data/

chown  nginx.  -R /data/wordpress

# 安装依赖:

​yum install gd curl curl-devel libjpeg libjpeg-devel freetype freetype-devel libxml2 libxml2-devel gcc  sqlite-devel.x86_64 -y

wget https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5-rev1.tar.gz -O onig-6.9.5.tar.gz

tar xf onig-6.9.5.tar.gz 

cd onig-6.9.5

./configure --prefix=/usr --libdir=/lib64

#安装PHP

wget ​​https://www.php.net/distributions/php-7.4.32.tar.gz​

tar xf php-7.4.32.tar.gz 

cd php-7.4.32

mkdir -p /usr/local/php/etc

# 预编译

./configure --prefix=/usr/local/php --enable-fpm  --enable-debug --with-gd  --with-jpeg-dir --with-png-dir --with-freetype-dir  --enable-mbstring  --with-curl --with-mysql=mysqlnd  --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc --with-zlib-dir

make && make install

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 sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

# 修改php-fpm的用户为nginx:

vim /usr/local/php/etc/php-fpm.d/www.conf

listen = 0.0.0.0:9000

;listen.allowed_clients = 127.0.0.1注释掉表示所有,打开ip改成需要访问的IP

user = nginx

group = nginx

#创建Nginx用户

useradd -M nginx -s /sbin/nologin

# 启动php-fpm:

/etc/init.d/php-fpm start

192.168.1.202(mariadb)

yum install mariadb mariadb-devel mariadb-server -y

systemctl start mariadb

mysql

create database wordpress charset utf8;

grant all on wordpress.* to wordpress@"192.168.1.201" identified by "123456";

flush privileges;