当前位置: 首页 > news >正文

受欢迎的网站建设公司seo策略有哪些

受欢迎的网站建设公司,seo策略有哪些,个人版的wordpress怎么加关键词,网站开发专家:php+mysql网站开发技术与典型案例导航文章目录 1.nginx编译安装脚本2.nginx平滑升级,以及其步骤3.nginx核心配置,及实现nginx多虚拟主机4.nginx日志格式定制5.nginx反向代理及https安全加密6.基于LNMP和Redis的phpmyadmin的会话保持,以及其完整步骤 1.nginx编译安装脚本 #编译安…

文章目录

    • 1.nginx编译安装脚本
    • 2.nginx平滑升级,以及其步骤
    • 3.nginx核心配置,及实现nginx多虚拟主机
    • 4.nginx日志格式定制
    • 5.nginx反向代理及https安全加密
    • 6.基于LNMP和Redis的phpmyadmin的会话保持,以及其完整步骤

1.nginx编译安装脚本

#编译安装脚本
#!/bin/bash
nginx_version=1.20.2
nginx_file=nginx-${nginx_version}.tar.gz
cpu=`lscpu | grep "^CPU(s):" | tr -d ' '|awk -F':' '{ print $2 }'`
install_dir=/data/web
user=nginx
group=nginx
url=https://nginx.org/download
. /etc/os-release
if [[ $ID =~ rhel|rocky|centos ]];thensystemctl disable --now firewalldyum install gcc make gcc-c++ wget pcre-devel openssl-devel zlib-devel -y
elif [[ $ID =~ 'ubuntu' ]];thenapt updateapt install gcc make gcc-c++ wget pcre-devel openssl-devel zlib-devel -y 
else      echo "不支持此系统,退出!"exit
fi       
if [ ! -f ${nginx_file} ];thenwget ${url}/${nginx_file} #下载nginx
fi
useradd -s /sbin/nologin ${user}
mkdir -p ${install_dir}
chown ${user}.${group} -R ${install_dir}
tar zxf ${nginx_file} -C /usr/local/src	#解压缩下载的nginx
cd /usr/local/src/nginx-${nginx_version} #进入下载的nginx目录
./configure --prefix=${install_dir} --without-http_rewrite_module --without-http_gzip_module --user=${user} --group=${group} --pid-path=${install_dir}/run/nginx.pid  --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module	#检查当前的环境是否满足要安装软件的依赖关系
make -j ${cpu}&& make install  #编译&&安装
echo "PATH=${install_dir}/sbin:${PATH}" > /etc/profile.d/nginx.sh
ln -s ${install_dir}/sbin/nginx /usr/sbin
echo "`hostname -I | cut -d ' ' -f1`" > ${install_dir}/html/index.html #创建web站点到初始页面
cat > /usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target[Service]
Type=forking
PIDFile=${install_dir}/run/nginx.pid
ExecStartPre=/usr/bin/rm -f ${install_dir}/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now nginx &> /dev/null
echo "安装成功!,并启动服务"
echo "请访问:http://`hostname -I | cut -d ' ' -f1`"

2.nginx平滑升级,以及其步骤

#平滑升级脚本
#!/bin/bash
old_version=1.20.1
new_version=1.22.1
nginx_file=nginx-${new_version}.tar.gz
cpu=`lscpu | grep "^CPU(s):" | tr -d ' '|awk -F':' '{ print $2 }'`
install_dir=/data/web
user=nginx
group=nginx
url=https://nginx.org/download/
if [ ! -f ${nginx_file} ];thenwget ${url}${nginx_file} #下载nginx
fi
tar zxf ${nginx_file} -C /usr/local/src	#解压缩下载的nginx
cd /usr/local/src/nginx-${new_version} #进入下载的nginx目录
./configure --prefix=${install_dir} --without-http_rewrite_module --without-http_gzip_module --user=${user} --group=${group} --pid-path=${install_dir}/run/nginx.pid  --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module	#检查当前的环境是否满足要安装软件的依赖关系
make -j ${cpu}
mv ${install_dir}/sbin/nginx ${install_dir}/sbin/nginx.old
cp /usr/local/src/nginx-${new_version}/objs/nginx ${install_dir}/sbin/
kill -s USR2 `cat ${install_dir}/run/nginx.pid`
kill -s WINCH `cat ${install_dir}/run/nginx.pid.oldbin`
kill -s QUIT `cat ${install_dir}/run/nginx.pid.oldbin` 

步骤

  1. 将旧Nginx二进制文件换成新Nginx程序文件(注意先备份)
  2. 向master进程发送USR2信号
  3. master进程修改pid文件名加上后缀.oldbin,成为nginx.pid.oldbin
  4. master进程用新Nginx文件启动新master进程成为旧master的子进程,系统中将有新旧两个Nginx
  5. 主进程共同提供Web服务,当前新的请求仍然由旧Nginx的worker进程进行处理,将新生成的master
  6. 进程的PID存放至新生成的pid文件nginx.pid
  7. 向旧的Nginx服务进程发送WINCH信号,使旧的Nginx worker进程平滑停止
  8. 向旧master进程发送QUIT信号,关闭老master,并删除Nginx.pid.oldbin文件
  9. 如果发现升级有问题,可以回滚∶向老master发送HUP,向新master发送QUIT

3.nginx核心配置,及实现nginx多虚拟主机

[root@server ~]# vim /etc/nginx/nginx.conf
user nginx nginx; #nginx的启动用户/组
worker_processes auto; #启动工作进程数数量
error_log /var/log/nginx/error.log; #nginx的错误日志路径
pid /run/nginx.pid; #Nginx的PID路径
include /usr/share/nginx/modules/*.conf;
#events设置快,主要影响nginx服务器与用户的网络连接,比如是否允许同时接受多个网络连接,使用哪种事件驱动模型处理请求,每个工作进程可以同时支持的最大连接数,是否开启对多工作进程下的网络连接进行序列化等。
events {worker_connections 1024; #设置单个nginx工作进程可以接受的最大并发,作为web服务器的时候最大并发数为worker_connections * worker_processes,作为反向代理的时候为(worker_connections * worker_processes)/2
}
#http块是Nginx服务器配置中的重要部分,缓存、代理和日志格式定义等绝大多数功能和第三方模块都可以在这设置,http块可以包含多个server块,而一个server块中又可以包含多个location块,server块可以配置文件引入、MIME-Type定义、日志自定义、是否启用sendfile、连接超时时间和单个链接的请求上限等。
http {log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"'; #日志自定义格式类型默认为该类型,可以自定义access_log  /var/log/nginx/access.log  main; ##nginx的成功日志路径以及其使用的日志格式sendfile            on;#作为web服务器的时候打开sendfile加快静态文件传输,指定是否使用sendfile系统调用来传输文件,sendfile系统调用在两个文件描述符之间直接传递数据(完全在内核中操作),从而避免了数据在内核缓冲区和用户缓冲区之间的拷贝,操作效率很高,被称之为零拷贝,硬盘 >> kernel buffer (快速拷贝到kernelsocket buffer) >>协议栈。tcp_nopush          on;tcp_nodelay         on;keepalive_timeout   65; #长连接超时时间,单位是秒types_hash_max_size 2048;include             /etc/nginx/mime.types;default_type        application/octet-stream;include /etc/nginx/conf.d/*.conf;
#设置一个虚拟机主机,可以包含自己的全局快,同时也可以包含多个location模块。比如本虚拟机监听的端口、本虚拟机的名称和IP配置,多个server 可以使用一个端口,比如都使用80端口提供web服务server {listen       80 default_server; #配置ipv4格式server监听的端口listen       [::]:80 default_server; #配置ipv6格式server监听的端口server_name  _; #本server的名称,当访问此名称的时候nginx会调用当前serevr内部的配置进程匹配。root         /usr/share/nginx/html; #相当于默认页面的目录名称,默认是安装目录的相对路径,可以使用绝对路径配置。include /etc/nginx/default.d/*.conf; #导入其他路径的配置文件location / {#location其实是server的一个指令,为nginx服务器提供比较多而且灵活的指令,都是在location中体现的,主要是基于nginx接受到的请求字符串,对用户请求的UIL进行匹配,并对特定的指令进行处理,包括地址重定向、数据缓存和应答控制等功能都是在这部分实现,另外很多第三方模块的配置也是在location模块中配置。}error_page 404 /404.html;  #错误页面的文件名称location = /40x.html {  #location处理对应的不同错误码的页面定义到/40x.html}error_page 500 502 503 504 /50x.html;  #错误页面的文件名称location = /50x.html {  #location处理对应的不同错误码的页面定义到/50x.html}}
#加密相关
# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
#和邮件相关的配置
#mail {
#               ...
#       }         mail 协议相关配置段
#stream {
#               ...
#       }       stream 服务器相关配置段        
多虚拟主机配置:
[root@server~]# vim conf.sh
#!/bin/bash
port=80
root_dir=/data/html
yum install nginx -y
cat > /etc/nginx/conf.d/web.conf << EOF
server{listen ${port};server_name www.web.com;root ${root_dir}/web/;
}
EOF
cat > /etc/nginx/conf.d/app.conf << EOF
server {listen ${port};server_name www.app.com;root ${root_dir}/app/;
}
EOF
mkdir -p ${root_dir}/{web,app}
chown -R nginx.nginx ${root_dir}
echo " this is website" > /data/html/web/index.html
echo " this is appsite" > /data/html/app/index.html
[root@server~]# nginx -s reload
[root@client ~]# echo "10.0.0.6 www.app.com" >> /etc/hosts 
[root@client ~]# echo "10.0.0.6 www.web.com" >> /etc/hosts
[root@client ~]# curl www.app.comthis is appsite
[root@client ~]# curl www.web.comthis is website

4.nginx日志格式定制

    log_format  json '{"@timestamp":"$time_iso8601",''"server_host":"$server_addr",''"client_host":"$remote_addr",''"size":$body_bytes_sent,''"responsetime":$request_time,' '"upstreamtime":"$upstream_response_time",''"upstreamhost":"$upstream_addr",'   '"http_url":"$host$uri",''"xff":"$http_x_forwarded_for",''"referer":"$http_referer",''"tcp_xff":"$proxy_protocol_addr",''"http_user_agent":"$http_user_agent",''"status":"$status"}';
主配置文件定义日志类型
在/etc/nginx/conf.d/web.conf中进行引用该日志文件格式
[root@server ~]# cat /etc/nginx/conf.d/web.conf 
server{listen 80;server_name www.web.com;root /data/html/web/;access_log  /var/log/nginx/web.log  json;
}
在客户端进行触发访问操作,并在服务器端观察日志生成情况
[root@client ~]# curl www.web.com
[root@server ~]# tail -f /var/log/nginx/web.log

5.nginx反向代理及https安全加密

https加密实现
创建证书脚本:
#!/bin/bash
CA_SUBJECT="/O=lll/CN=ca.lll.com"
SUBJECT="/C=CN/ST=HB/L=HB/O=lll/CN=www.lll.com"
SERIAL=34
EXPIRE=203006
FILE=lll.com
openssl req -x509 -newkey rsa:2048 -subj $CA_SUBJECT -keyout ca.key -nodes -days 365 -out ca.crt
openssl req -newkey rsa:2048 -nodes -keyout ${FILE}.key -subj $SUBJECT -out ${FILE}.csr
openssl x509 -req -in ${FILE}.csr -CA ca.crt -CAkey ca.key -set_serial $SERIAL -days $EXPIRE -out ${FILE}.crt
chmod 600 ${FILE}.key ca.key
[root@centos8 pki]# cat lll.com.crt ca.crt > www.lll.com.crt
[root@centos8 pki]# mv lll.com.key www.lll.com.key
[root@centos8 pki]# cat /etc/nginx/conf.d/web.conf
server{listen 80;listen 443;ssl_certificate /etc/ssl/pki/www.lll.com.crt;ssl_certificate_key /etc/ssl/pki/www.lll.com.key;ssl_session_cache shared:sslcache:20m;ssl_session_timeout 10m;server_name www.web.com;root /data/html/web/;access_log  /data/html/web/log/access_web.log  json;}

 在本机电脑更改hosts文件指向该server的地址,并用浏览器进行访问即可
nginx反向代理简单实现
 反向代理:reverse proxy,指的是代理外网用户的请求到内部的指定的服务器,并将数据返回给用户的一种方式,这是用的比较多的一种方式。

[root@proxy_server ~]# vim /etc/nginx/conf.d/web.conf
server{listen 80;server_name www.web.com;location /{proxy_pass http://10.0.0.4;}
}
[root@proxy_server ~]# nginx -s reload
[root@server ~]# yum install httpd -y
[root@server ~]# echo `hostnamectl` > /var/www/html/index.html
[root@client ~]# echo "10.0.0.6 www.web.com" >> /etc/hosts
[root@client ~]# curl www.web.com

6.基于LNMP和Redis的phpmyadmin的会话保持,以及其完整步骤

 使用的环境为Ubuntu22.04

[root@ubuntu2004 ~]# cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu

 1.安装包

[root@ubuntu2004 ~]#apt install nginx mysql-server php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-intl php8.1-xml php8.1-zip php-redis redis-server -y 

 2.对php.ini进行配置

[root@ubuntu2004 ~]#vim /etc/php/8.1/fpm/php.inidate.timezone = Asia/Shanghaipost_max_size = 8Mupload_max_filesize = 100Mdisplay_errors = Onerror_log = syslog
extension=redis.so

 3.对www.conf进行配置

[root@ubuntu2004 ~]#vim /etc/php/8.1/fpm/pool.d/www.conf
user = www-data
group = www-data
listen = 127.0.0.1:9000
pm.status_path = /php-status
ping.path = /ping
access.log = log/$pool.access.log
slowlog = log/$pool.log.slow
php_value[session.save_handler] = redis
php_value[session.save_path]    = "tcp://127.0.0.1:6379"  #指定Redis地址

 4.创建日志文件配置并授权

[root@ubuntu2004 ~]# mkdir -p /usr/log
[root@ubuntu2004 ~]# touch /usr/log/www.access.log
[root@ubuntu2004 ~]# chmod 644 /usr/log/www.access.log
[root@ubuntu2004 ~]# chown www-data:www-data /usr/log/www.access.log

 5.配置数据库创建用户

[root@ubuntu2004 ~]# mysql
mysql> create user admin@'127.0.0.1' identified with  mysql_native_password  by '123456';
mysql> grant all on *.* to admin@'127.0.0.1';
mysql> quit;

 6.创建nginx文件

[root@ubuntu2004 ~]# vim /etc/nginx/conf.d/test.conf 
server{listen 80;server_name 10.0.0.5;root /data/www;index index.php;client_max_body_size 20m;location ~ \.php$|/ping|/status {root /data/www;fastcgi_pass 127.0.0.1:9000;fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;include fastcgi_params;}}

 7.启动服务

[root@ubuntu2004 ~]# systemctl restart nginx.service redis-server.service mysql.service php8.1-fpm.service

 8.进行验证
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
 9.下载phpmyadmin

[root@ubuntu2004 ~]# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
[root@ubuntu2004 ~]# unzip  phpMyAdmin-5.2.0-all-languages.zip
[root@ubuntu2004 ~]# mv phpMyAdmin-5.2.0-all-languages/* /data/www
[root@ubuntu2004 ~]# cp /data/www/config.sample.inc.php config.inc.php
[root@ubuntu2004 ~]# vim /data/www/config.inc.php
$cfg['Servers'][$i]['host'] = '127.0.0.1'; 

在这里插入图片描述
 10.测试网站是否注销

[root@ubuntu2004 ~]# redis-cli 
127.0.0.1:6379> keys *
1) "PHPREDIS_SESSION:i5m1ikcn641d7f3mvpo3mnh1i7"
127.0.0.1:6379> type "PHPREDIS_SESSION:i5m1ikcn641d7f3mvpo3mnh1i7"
string#删除session然后刷新浏览器看是否注销
127.0.0.1:6379> flushall
OK

在这里插入图片描述

http://www.yidumall.com/news/30619.html

相关文章:

  • 广州最新疫情政策抖音seo点击软件排名
  • iis7 发布asp网站404最佳磁力吧cili8
  • 把自己做的网页发布到网站百度客服电话24小时客服电话
  • 改wordpress地址还是站点地址色盲测试图
  • 上海网站建设公司网站建设360搜索引擎网址
  • 广西南宁市网站制作公司郑志平爱站网创始人
  • 关于我们网站设计百度最新人工智能
  • 求职招聘网站排名前十名免费下载app并安装
  • 衡水市做网站网站搭建工具
  • WordPress底部栏插件百度seo搜索引擎优化
  • 建设局电话号码是多少合肥seo优化
  • 杭州高端网站建设可以直接进入网站的正能量
  • 泉州晋江网站建设费用自媒体营销模式有哪些
  • sketch网站花边怎么做百度拉新推广平台
  • 申请完域名怎么做网站网站制作公司怎么找
  • node 做的大型网站关键词有哪些关联词
  • 整合网络营销平台佛山百度seo代理
  • 手机网站在线咨询代码深圳网站建设推广方案
  • 政府网站集约化建设试点工作方案杭州龙席网络seo
  • 域名备案成功如何做网站佛山网站优化
  • 用asp.net做的网站框架北京网站优化经理
  • 用什么做公司宣传网站全能搜
  • dw怎么做鲜花网站海外市场推广方案
  • 字体图标网站营销软文范文200字
  • 做平面的网站河北百度推广客服电话
  • 湖北省建设人力资源网站首页帮人推广的平台
  • 汽车维修保养网站模板关键词分词工具
  • 手机微网站第二年续费吗网站优化策略分析
  • 996建站网站制作互联网营销有哪些方式
  • 投票网站开发如何限制ip百度账号查询