当前位置:网站首页>Using LNMP to build WordPress sites
Using LNMP to build WordPress sites
2022-07-05 23:00:00 【wwzroom】
utilize LNMP Realization wordpress Site construction
1. Prepare resources
[[email protected]:~]#
cd /usr/local/src
# And then use it lrzsz Realization windows Upload the corresponding file
[[email protected]:/usr/local/src]#
ll
-rw-r--r-- 1 root root 661718255 Sep 1 2021 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
-rw-r--r-- 1 root root 1039530 Sep 1 2021 nginx-1.18.0.tar.gz
-rw-r--r-- 1 root root 16866582 Jun 6 17:38 php-7.4.29.tar.gz
-rw-r--r-- 1 root root 21861227 May 31 14:22 wordpress-6.0-zh_CN.tar.gz
2. Write a script
[[email protected]:/usr/local/src]#
vim install_lnmpcentos7.sh
#!/bin/bash
SRC_DIR=/usr/local/src
NGINX='nginx-1.18.0.tar.gz'
MYSQL='mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz'
PHP='php-7.4.29.tar.gz'
APP='wordpress-6.0-zh_CN.tar.gz'
COLOR="echo -e \\033[01;31m"
END='\033[0m'
MYSQL_ROOT_PASSWORD=laowang
MYSQL_WORDPRESS_PASSWORD=laowang
CPU=`lscpu| awk '/^CPU\(s\):/{print $NF}'`
${COLOR}' Start installation based on LNMP Of wordpress'$END
sleep 3
check_file (){
cd $SRC_DIR
$COLOR" Please put the relevant software in ${SRC_DIR} Under the table of contents "$END
if [ ! -e $NGINX ];then
$COLOR" The lack of ${NGINX} file "$END
exit
elif [ ! -e $MYSQL ];then
$COLOR" The lack of ${MYSQL} file "$END
exit
elif [ ! -e $PHP ];then
$COLOR" The lack of ${PHP} file "$END
exit
elif [ ! -e $APP ];then
$COLOR" The lack of ${APP} file "$END
exit
else
$COLOR" Relevant documents are ready "$END
fi
}
install_mysql(){
$COLOR" Start installation MySQL database "$END
cd $SRC_DIR
tar xf $MYSQL -C /usr/local/
if [ -e /usr/local/mysql ];then
$COLOR" Database already exists , Installation failed "$END
exit
fi
MYSQL_DIR=`echo $MYSQL| sed -nr 's/^(.*[0-9]).*/\1/p'`
ln -s /usr/local/$MYSQL_DIR /usr/local/mysql
chown -R root.root /usr/local/mysql/
id mysql &> /dev/null || {
useradd -s /sbin/nologin -r mysql ; $COLOR" establish mysql user "$END; }
yum -y -q install numactl-libs libaio &> /dev/null
echo 'PATH=/usr/local/mysql/bin/:$PATH' > /etc/profile.d/lamp.sh
. /etc/profile.d/lamp.sh
cat > /etc/my.cnf <<-EOF [mysqld] server-id=1 log-bin datadir=/data/mysql socket=/data/mysql/mysql.sock log-error=/data/mysql/mysql.log pid-file=/data/mysql/mysql.pid [client] socket=/data/mysql/mysql.sock EOF
[ -d /data ] || mkdir /data
[ -d /data ] || mkdir /data
mysqld --initialize --user=mysql --datadir=/data/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
[ $? -ne 0 ] && {
$COLOR" Database startup failed , sign out !"$END;exit; }
MYSQL_OLDPASSWORD=`awk '/A temporary password/{print $NF}' /data/mysql/mysql.log`
mysqladmin -uroot -p$MYSQL_OLDPASSWORD password $MYSQL_ROOT_PASSWORD &>/dev/null
$COLOR" Database installation complete "$END
}
install_nginx(){
${COLOR}" Start installation NGINX"$END
id nginx &> /dev/null || {
useradd -s /sbin/nologin -r nginx; $COLOR" establish nginx user "$END; }
$COLOR" install nginx Related packages "$END
yum -q -y install gcc pcre-devel openssl-devel zlib-devel perl-ExtUtils-Embed git &> /dev/null
cd $SRC_DIR
tar xf $NGINX
# git clone https://github.com/openresty/echo-nginx-module.git || { $COLOR" download NGINX The third-party module failed , sign out !"$END;exit; }
NGINX_DIR=`echo $NGINX| sed -nr 's/^(.*[0-9]).*/\1/p'`
cd $NGINX_DIR
./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
make -j $CPU && make install
[ $? -eq 0 ] && $COLOR"NGINX Compile and install successfully "$END || {
$COLOR"NGINX Compilation and installation failed , sign out !"$END;exit; }
[ -d /data/www ] || mkdir -pv /data/www/
cat > /apps/nginx/conf/nginx.conf <<EOF worker_processes auto; events { worker_connections 10240; } http { include mime.types; default_type application/octet-stream; server_tokens off; log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" ' sendfile on; client_max_body_size 100m; keepalive_timeout 65; server { listen 80 default_server; server_name localhost ; root /data/www ; access_log logs/nginx.access.log main; location / { root /data/www/; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root /data/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; include fastcgi_params; } } } EOF
echo 'PATH=/apps/nginx/sbin:$PATH' >> /etc/profile.d/lamp.sh
cat > /usr/lib/systemd/system/nginx.service <<EOF [Unit] After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/apps/nginx/sbin/nginx ExecReload=/apps/nginx/sbin/nginx -s reload ExecStop=/apps/nginx/sbin/nginx -s stop [Install] WantedBy=multi-user.target EOF
systemctl daemon-reload
systemctl start nginx
systemctl is-active nginx &> /dev/null || {
$COLOR"NGINX Boot failure , sign out !"$END ; exit; }
$COLOR"NGINX installation is complete "
}
install_php (){
${COLOR}" Start installation PHP"$END
yum -y -q install gcc make libxml2-devel bzip2-devel libmcrypt-devel libsqlite3x-devel oniguruma-devel &>/dev/null
cd $SRC_DIR
tar xf $PHP
PHP_DIR=`echo $PHP| sed -nr 's/^(.*[0-9]).*/\1/p'`
cd $PHP_DIR
./configure --prefix=/apps/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
make -j $CPU && make install
[ $? -eq 0 ] && $COLOR"PHP Compile and install successfully "$END || {
$COLOR"PHP Compilation and installation failed , sign out !"$END;exit; }
cp php.ini-production /etc/php.ini
mkdir /etc/php.d/
cat > /etc/php.d/opcache.ini <<EOF [opcache] zend_extension=opcache.so opcache.enable=1 EOF
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
cd /apps/php74/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf
id nginx &> /dev/null || {
useradd -s /sbin/nologin -r nginx; $COLOR" establish nginx user "$END; }
sed -i.bak -e 's/^user.*/user = nginx/' -e 's/^group.*/group = nginx/' /apps/php74/etc/php-fpm.d/www.conf
systemctl daemon-reload
systemctl start php-fpm
systemctl is-active php-fpm &> /dev/null || {
$COLOR"PHP-FPM Boot failure , sign out !"$END ; exit; }
$COLOR"PHP installation is complete "
}
install_wordpress(){
cd $SRC_DIR
tar xf $APP
[ -d /data/www ] || mkdir -pv /data/www
mv wordpress/* /data/www/
chown -R nginx.nginx /data/www/wp-content/
cd /data/www/
mv wp-config-sample.php wp-config.php
mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "create database wordpress;grant all on wordpress.* to [email protected]'127.0.0.1' identified by '$MYSQL_WORDPRESS_PASSWORD'" &>/dev/null
sed -i.bak -e 's/database_name_here/wordpress/' -e 's/username_here/wordpress/' -e 's/password_here/'''$MYSQL_WORDPRESS_PASSWORD'''/' -e 's/localhost/127.0.0.1/' wp-config.php
$COLOR"WORDPRESS installation is complete "
}
check_file
install_mysql
install_nginx
install_php
install_wordpress
3. Execute script one click deployment
[[email protected]:/usr/local/src]#
bash install_lnmpcentos7.sh
4. host hosts File to add dns Address resolution
C:\Windows\System32\drivers\etc\hosts Add in 10.0.0.17 blog.wwzroom.org,
5. Access registration login http://blog.wwzroom.org
As shown in the figure below
6. Tips
1. hide PHP edition
[[email protected]:/usr/local/src]#
vim /etc/php.ini
expose_php = off # It's just for you off
[[email protected]:/usr/local/src]#
systemctl restart php-fpm
2. Upload big pictures
1) modify php-fpm The configuration file , Adjust the allowed picture size .
[[email protected]:/usr/local/src]#
vim /etc/php.ini
post_max_size = 20M
upload_max_filesize = 20M
[[email protected]:/usr/local/src]#
systemctl restart php-fpm
2) modify nginx The configuration file ( It has been set in the script , You don't need to set it anymore )
[[email protected]:/usr/local/src]#
vim /apps/nginx/conf/nginx.conf
client_max_body_size 100m;
边栏推荐
- Getting started stm32--gpio (running lantern) (nanny level)
- Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
- Yiwen gets rid of the garbage collector
- Usage Summary of scriptable object in unity
- Leetcode daily question 1189 The maximum number of "balloons" simple simulation questions~
- 傅里叶分析概述
- Arduino measures AC current
- Evolution of APK reinforcement technology, APK reinforcement technology and shortcomings
- 利用LNMP实现wordpress站点搭建
- PLC编程基础之数据类型、变量声明、全局变量和I/O映射(CODESYS篇 )
猜你喜欢
MoCo: Momentum Contrast for Unsupervised Visual Representation Learning
基于STM32的ADC采样序列频谱分析
Error when LabVIEW opens Ni instance finder
Exponential weighted average and its deviation elimination
Marginal probability and conditional probability
终于搞懂什么是动态规划的
[speech processing] speech signal denoising and denoising based on Matlab GUI low-pass filter [including Matlab source code 1708]
openresty ngx_ Lua request response
fibonacci search
How can easycvr cluster deployment solve the massive video access and concurrency requirements in the project?
随机推荐
记录几个常见问题(202207)
Activate function and its gradient
基于STM32的ADC采样序列频谱分析
Alibaba Tianchi SQL training camp task4 learning notes
[speech processing] speech signal denoising and denoising based on MATLAB low-pass filter [including Matlab source code 1709]
Vision Transformer (ViT)
openresty ngx_lua正则表达式
傅里叶分析概述
audiopolicy
SPSS analysis of employment problems of college graduates
H5c3 advanced - player
2022 registration examination for safety management personnel of hazardous chemical business units and simulated reexamination examination for safety management personnel of hazardous chemical busines
The code generator has deoptimised the styling of xx/typescript.js as it exceeds the max of 500kb
视频标准二三事
Metaverse ape ape community was invited to attend the 2022 Guangdong Hong Kong Macao Great Bay metauniverse and Web3.0 theme summit to share the evolution of ape community civilization from technology
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
Three. Js-01 getting started
a-tree 树的全部展开和收起
Thoroughly understand JVM class loading subsystem
Event trigger requirements of the function called by the event trigger