15158846557 在线咨询 在线咨询
15158846557 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > 云主机快速建站过程(wordpress企业站,外贸站)

云主机快速建站过程(wordpress企业站,外贸站)

时间:2023-07-27 04:36:01 | 来源:网站运营

时间:2023-07-27 04:36:01 来源:网站运营

云主机快速建站过程(wordpress企业站,外贸站):演示站地址:




一、开通账号,购买vps。选购域名

国内可以选择阿里云,腾讯云。

系统版本centos7

二、centos7系统初始化配置

修改系统限制

vim /etc/security/limits.conf * soft nofile 1048576 * hard nofile 1048576


vim /etc/security/limits.d/90-nproc.conf * soft nproc unlimited root soft nproc unlimited


sysctl -p 创建目录

mkdir -p /opt/{app,conf,scripts,servicelogs,www} 防火墙

service firewalld stop systemctl disable firewalld.service yum -y remove firewalld yum -y install iptables-services iptables ipset ipset-service systemctl enable ipset systemctl enable iptables 防火墙规则

iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -F iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 2201 -j ACCEPT iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT iptables -A INPUT -p tcp -j DROP iptables -A OUTPUT -p udp -j DROP service iptables save service iptables restart iptables -nvL
修改sshd服务默认端口

sed -i 's/#Port/ 22/Port/ 2201/g' /etc/ssh/sshd_config systemctl restart sshd 修改系统时间

rm /etc/localtime ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ntpdate ntp.ntsc.ac.cn 三、安装服务模块(LNAMP架构)

php-fpm配置

配置源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 软件安装

yum -y remove php* yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
php-fpm配置、优化

sed -i 's/var//log/opt//servicelogs/g' /etc/php-fpm.conf mkdir -p /opt/servicelogs/php-fpm/ 继续配置

vim /etc/php-fpm.d/www.conf 文件内容

[www] listen = /var/run/php-fpm/php-fpm.sock ;listen = 127.0.0.1:9000 listen.allowed_clients = 127.0.0.1 listen.owner = nginx listen.group = nginx listen.mode = 0660 listen.backlog = 16384 user = nginx group = nginx pm = static pm.max_children = 20 pm.start_servers = 10 pm.min_spare_servers = 10 pm.max_spare_servers = 35 pm.max_requests = 10000 request_terminate_timeout = 180 request_slowlog_timeout = 30 slowlog = /opt/servicelogs/php-fpm/www-slow.log ;access.log = /opt/servicelogs/php-fpm/access.$pool.log ;access.format = "%R - %u %t /"%m %r%Q%q/" %s %f %{seconds}d %{megabytes}M %{user}C%%" ping.path = /php5fpm-ping pm.status_path = /php5fpm-status nginx安装与配置

软件安装

yum -y install nginx 创建目录

mkdir -p /opt/servicelogs/nginx/ nginx配置

vim /etc/nginx/nginx.conf 文件内容

user nginx; worker_processes auto; error_log /opt/servicelogs/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } 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 /opt/servicelogs/nginx/access.log main buffer=32k flush=30s; server_tokens off; client_max_body_size 100m; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; #ssl 配置 ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384; ssl_ecdh_curve secp384r1; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_session_tickets off; ssl_stapling on; # Requires nginx >= 1.3.7 ssl_stapling_verify on; # Requires nginx => 1.3.7 add_header Strict-Transport-Security "max-age=63072000; preload"; #add_header X-Frame-Options DENY; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; #启动gzip gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 7; gzip_types text/css text/plain text/javascript application/javascript application/json application/x-javascript application/xml application/xml+rss application/xhtml+xml application/x-font-ttf application/x-font-opentype application/vnd.ms-fontobject image/svg+xml image/x-icon application/rss+xml application/atom_xml image/jpeg image/gif image/png image/icon image/bmp image/jpg; gzip_vary on; # for more information. include /etc/nginx/conf.d/*.conf; } mysql数据库的安装与配置

软件安装

yum -y install libaio wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm yum -y localinstall mysql-community-release-el7-5.noarch.rpm yum -y install mysql-server mysql-client 创建目录

mkdir -p /opt/servicelogs/mysql/ mkdir -p /opt/app/mysql/ chown -R mysql:mysql /opt/servicelogs/mysql/
修改配置文件

vim /etc/my.cnf 文件内容

[mysql] port = 3306 socket = /opt/app/mysql/mysql.sock prompt = "//u@//h //D //R://m://s [//d]> tee = /opt/servicelogs/mysql/query.log [mysqld] user = mysql socket = /opt/app/mysql/mysql.sock pid-file = /opt/app/mysql/mysql.pid key-buffer-size = 32M max-allowed-packet = 16M max-connect-errors = 10000 skip-name-resolve sysdate-is-now = 1 datadir = /opt/app/mysql/ log-bin = /opt/app/mysql/mysql-bin sync-binlog = 1 tmp-table-size = 32M max-heap-table-size = 32M max-connections = 500 thread-cache-size = 50 open-files-limit = 9999 table-definition-cache = 4096 table-open-cache = 4096 innodb-flush-method = O_DIRECT innodb-log-files-in-group = 2 innodb-log-file-size = 64M innodb-flush-log-at-trx-commit = 1 innodb-file-per-table = 1 innodb-buffer-pool-size = 200M log-error = /opt/servicelogs/mysql/mysql-error.log log-queries-not-using-indexes = 1 slow-query-log = 1 slow-query-log-file = /opt/servicelogs/mysql/mysql-slow.log 数据库初始化

mysql_install_db --user=mysql --datadir=/opt/app/mysql/ systemctl start mysqld /usr/bin/mysqladmin -u root password -S /opt/app/mysql/mysql.sock root@123 四、安装wordpress程序,并配置

建库授权

CREATE DATABASE `com01` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; create user 'com01user'@'127.0.0.1' IDENTIFIED BY 'com01user123'; grant all privileges on com01.* to 'com01user'@'127.0.0.1'; flush privileges; 创建nginx配置文件

vim /etc/nginx/conf.d/com01.conf文件内容

server { listen 80; server_name com01.webzhan.xyz; charset utf-8; set $host_path "/opt/www/com01"; error_log /var/log/nginx/err_com01.log; access_log /var/log/nginx/acc_com01.log; root $host_path; # 缓存标记 set $skip_cache 0; if ($query_string != "") { set $skip_cache 1; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|sitemap(_index)?.xml") { set $skip_cache 1; } # 登录用户或发表评论者 if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; } location = / { index index.php index.html; try_files /index.php?$args /index.php?$args; } location / { index index.php index.html; try_files $uri $uri/ /index.php?$args; } location ~ ^//.user/.ini { deny all; } location ~ /.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_cache_valid 200 301 302 30m; fastcgi_cache_valid 404 10m; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache_lock on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/"; include fastcgi_params; } location ~ /.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|jpeg)$ { expires max; access_log off; try_files $uri =404; }}到此建站基本结束





关键词:企业,过程,主机

74
73
25
news

版权所有© 亿企邦 1997-2025 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭