首页 文章 精选 留言 我的

精选列表

搜索[构建环境],共10000篇文章
优秀的个人博客,低调大师

LEMP环境下WordPress建站教程

LEMP 代表的是(L:Linux OS,E:Nginx,M:MySQL/MariaDB, P:PHP),与之对应的是 LAMP(唯一不同的是 A,代表 Apache 网络服务器),由于Nginx轻量、高效的特性,LEMP 在近来的 Web 服务中的出镜率越来越高。 为了追随潮流,在之前LAMP 搭建 WordPress的基础上,我又尝试了使用 Nginx 作为 WordPress 的网络服务器,尽管遇到了各种各样的问题,但是取得了不错的效果。由于 Nginx 的配置比较复杂,于是有很多需要注意的地方。 常见网络服务器的优缺点 1. Nginx Nginx 是十分轻量级的 HTTP 服务器,是一个高性能的 HTTP 和反向代理服务器,Nginx 以事件驱动的方式编写,所以有非常好的性能,同时也是一个非常高效的反向代理、负载平衡。其拥有匹敌 Lighttpd 的性能,同时还没有 Lighttpd 的内存泄漏问题。 优点:轻量级,处理请求异步非阻塞,抗并发,高度模块化,有着 Lighttpd 的性能,且更稳定。 缺点:Nginx 在处理动态请求方面不如 Apache。 2. Apache Apache 是世界使用排名第一的 Web 服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的 Web 服务器端软件之一。但是对于那些需要更强大的 Web 应用服务器(比如大小、可定制、响应速度、可扩展性等方面)的人而言,Apache 明显不符合他们的要求。 优点:兼容性和稳定性强,处理动态请求能力好。 缺点:体量大,在速度、性能不及其他轻量级 Web 服务器,并且消费内存较高。 3. Lighttpd Lighttpd 是一个具有非常低的内存开销,CPU 占用率低,效能好,以及丰富的模块等特点。Lighttpd 是众多 开源的轻量级的网络服务器中较为优秀的一个。支持 FastCGI、 CGI、 Auth、 输出压缩、URL 重写、Alias 等重要功能。 优点:轻量级,CPU 占用低,效能好,模块丰富,对FastCGI 支持非常好,比 Apache 性能更高。 缺点:稳定性没有 Apache 和 Nginx 好。 如果考虑网站的综合状况的话,比较理想的做法是用 Nginx 做高并发、缓存、代理前端内容,而使用 Apache 处理后台动态内容。不过如果只是驱动 WordPress,单独使用 Nginx 就够了。 安装 LEMP 安装过程和 LAMP 差不多,只是几个地方稍微不同。 安装 Nginx # 安装Nginx sudo apt install nginx # 检查Nginx运行状况 sudo systemctl status nginx.service 安装 PHP7 # 安装PHP7和PHPFastCGI管理器PHP-FPM sudo apt install php7.0 php7.0-fpm 安装 MariaDB 数据库 # 安装MariaDB sudo apt install mariadb-server mariadb-client php7.0-mysql # 重启PHP-FPM服务以便使用MySQL模块与数据库通信 sudo systemctl restart php7.0-fpm.service 为了安全加固 MariaDB,运行来自 Ubuntu 软件仓库中的二进制包提供的安全脚本,这会询问你设置一个 root 密码,移除匿名用户,禁用 root 用户远程登录,移除测试数据库等。 # 使用安全脚本 sudo mysql_secure_installation # 配置MariaDB以便普通用户能够不使用root权限来访问数据库 sudo mysql MariaDB> use mysql; MariaDB> update user set plugin='' where User='root'; MariaDB> flush privileges; MariaDB> exit # 然后使用如下命令执行数据库命令 mysql -u root -p -e 'show databases' 安装其他模块 还有一些 WordPress 会用到的模块,比如 mcrypt、mbstring,安装完后需要重启 PHP-FPM。 # 其他模块 sudo apt install php7.0-mcrypt php7.0-mbstring 到这里 LEMP 的安装工作就已经基本搞定了,接下来是最重要的配置环节。 配置 Nginx 主配置 首先是主配置文件/etc/nginx/nginx.conf: # Set user and group. user www-data www-data; # Usually equal to number of CPUs you have. worker_processes 1; # Global error log [ debug | info | notice | warn | error | crit ]. error_log /var/log/nginx/error.log warn; # Pid file pid /run/nginx.pid; events { worker_connections 1024; } http { ### Basic Settings ### include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 60; client_max_body_size 15m; # Limit the max size of plugin in WordPress. ### SSL Settings ### ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ### Logging Settings ### access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ### Gzip Settings ### gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ### FastCGI Settings ### fastcgi_cache_path /tmp/wpcache levels=1:2 keys_zone=WORDPRESS:250m inactive=1d max_size=1G; fastcgi_temp_path /tmp/wpcache/temp; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; ### Virtual Host Configs ### include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } 子配置 然后是 WordPress 的配置文件/etc/site-enabled/wordpress.conf: server { listen 80 default_server; listen [::]:80 default_server; root /home/ubuntu/wordpress; index index.html index.php; server_name www.infiniture.cn; access_log /var/log/nginx/infiniture.com.access.log; error_log /var/log/nginx/infiniture.com.error.log; # Managed by Certbot listen 443 ssl; ssl_certificate /etc/letsencrypt/live/www.infiniture.cn/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.infiniture.cn/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; if ($scheme != "https") { return 301 https://$host$request_uri; } # Add rewrite support for wordpress location / { try_files $uri $uri/ /index.php?$args; rewrite /wp-admin$ $scheme://$host$uri/ permanent; } # Cache strategy set $no_cache 0; # POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $no_cache 1; } if ($query_string != "") { set $no_cache 1; } # Don't cache uris containing the following segments if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $no_cache 1; } # Don't use the cache for logged in users or recent commenters if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $no_cache 1; } location ~ /wp-admin { location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; # Making the updates in WordPress real time. fastcgi_buffering off; add_header X-Accel-Buffering "no"; } } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_connect_timeout 600; fastcgi_send_timeout 600; fastcgi_read_timeout 600; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; fastcgi_cache WORDPRESS; fastcgi_cache_valid 200 301 302 1d; add_header X-Cache "$upstream_cache_status From $host"; } # Purge cache(Nginx Helper Purge Method: Using a Get) location ~ /purge(/.*) { allow 127.0.0.1; allow 182.254.246.42; deny all; fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~ /\. { deny all; } # Deny access to any files with a .php extension in the uploads directory # Works in sub-directory installs and also in multisite network # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~* /(?:uploads|files)/.*\.php$ { deny all; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; access_log off; } } 配置说明 以上配置中,需要说明的几个: client_max_body_size 15m;因为 WordPress 里很多插件的体积比较大,如果不设置这个值的大小,会导致插件或者主题安装失败。 fastcgi_cache_path /tmp/wpcache levels=1:2 keys_zone=WORDPRESS:250m inactive=1d max_size=1G;这个包括下面的所有内容都是为了使 Nginx 缓存动态文件,参数对应的是缓存位置,缓存级别,缓存标识及大小,有效期,最大容量。 由于 Nginx 不支持 Apache 的.htaccess文件,因此无法使用 WordPress 自带的地址重写功能,需要自己添加相应的功能。 # Add rewrite support for wordpress location / { try_files $uri $uri/ /index.php?$args; rewrite /wp-admin$ $scheme://$host$uri/ permanent; } fastcgi_buffering off;这个选项默认是开启的,它会把 FastCGI 返回的内容缓存起来,直到缓存空间满了之后一并输出,这会导致 WordPress 下更新时不会实时显示,而是更新完成后全部一起显示。关掉这个选项即可解决这个问题。 由于在线安装插件、主题需要等待的时间有时候会很长,因此如果不设置 FastCGI 的读写等待时长,很容易导致安装或者更新失败,因此需要设置如下内容。 fastcgi_connect_timeout 600; fastcgi_send_timeout 600; fastcgi_read_timeout 600; 为了更好管理动态文件缓存,我用了一个名为 “Nginx hleper” 的插件,为此增加了如下配置。 # Purge cache(Nginx Helper Purge Method: Using a Get) location ~ /purge(/.*) { allow 127.0.0.1; allow xxx.xxx.xxx.xxx; # 你的服务器地址 deny all; fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; } 总结 这样就在 LEMP 平台上搭建好了 WordPress 站点。

优秀的个人博客,低调大师

CentOS环境下搭建VPS服务

说明 由于大部分VPN被封,FQ过程中无意间接触到了VPS(Virtual Private Server 虚拟专用服务器,可用于FQ),所以简单记录下VPS服务搭建流程。 此教程基于centos7,本人选择使用阿里云服务器(香港区域,可访问外网)进行搭建。 安装组件 安装python组件:yuminstall m2crypto python-setuptools easy_install pip 安装shadowsocks:pip install shadowsocks 配置参数 新建并编辑文件:vim/etc/shadowsocks.json 拷贝如下配置至文件末尾: { "server":"0.0.0.0", "server_port":8388, "local_address":"127.0.0.1", "local_port":1080, "password":"password", "timeout":300, "method":"aes-256-cfb", "fast_open":false, "workers":1 } 主要参数说明:server_port表示开放VPS服务端口,password表示登录密码。 启动服务 启动命令:ssserver-c/etc/shadowsocks.json 启动成功结果如下: 连接VPS windows:使用shadowsocks客户端进行连接,由于百度无法直接搜索和下载,github下载地址:https://github.com/shadowsocks/shadowsocks-windows/releases;软件使用非常简单,首先安装,然后将VPS服务器IP、端口、密码都填写正确就可以连接了,系统代理模式启用PAC模式或全局模式即可使用。 iPhone/iPad:下载Shadowrocket简单配置后即可使用,目前appstore上搜索不到该软件,使用pp助手可下载该软件。 后台运行 由于以上启动方式为直接启动,如果关闭会话窗口即关闭服务,所以我们使用supervisor实现后台运行(如果要详细了解supervisor,请搜索supervisor教程,本篇仅为简单应用)。 安装python工具:yuminstall python-setuptools 安装supervisor:easy_install supervisor 创建配置文件:echo_supervisord_conf>/etc/supervisord.conf 添加任务:vi /etc/supervisord.conf 拷贝如下配置至文件末尾: [program:ssserver]command = ssserver -c /etc/shadowsocks.json autostart=true autorestart=true startsecs=3 测试配置是否成功:supervisord -c/etc/supervisord.conf,再使用ps -ef | grep shadowsocks查看进程是否存在,如果进程存在则配置成功。 配置开机启动:vi /etc/rc.d/rc.local 在末尾行添加supervisord,此外centos7还需要配置文件权限:chmod+x/etc/rc.local,重启服务器即可自动运行。 PS 没想到第一篇博客写的是VPS搭建,而不是代码阅读学习。缘,妙不可言。

优秀的个人博客,低调大师

2-openstack基础环境准备

说明: linux-node1 控制节点 linux-node2 计算节点 2.1.两台centos7服务器 1 2 3 4 5 主机名: [root@linux-node1~] #hostname linux-node1 [root@linux-node2~] #hostname linux-node2 1 2 3 IP: linux-node1192.168.56.11 /24 linux-node2192.168.56.12 /24 1 2 3 4 5 6 host解析 cat /etc/hosts 127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4 ::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6 192.168.56.11linux-node1linux-node1.oldboyedu.com 192.168.56.12linux-node2linux-node2.oldboyedu.com 2.2 selinux 和防火墙关闭 1 2 3 4 5 6 7 8 9 [root@linux-node2~] #getenforce Disabled [root@linux-node1~] #getenforce Disabled #可以用sed sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config 防火墙: systemctlstopfirewalld systemctldisablefirewalld 2.3 配置时间同步(两台都做) 1 2 3 4 5 6 yum–y install chrony grep "allow" /etc/chrony .conf #打开 allow192.168 /16 systemctl enable chronyd.service #设置开机自启 systemctlstartchronyd.service #启动 timedatectl set -timezoneAsia /Shanghai #同步时区 2.4 在linux-node1 上安装数据库 1 2 3 4 5 6 7 8 9 10 11 yum install -ymariadbmariadb-serverMySQl-python #安装数据库 \ cp /usr/share/mysql/my-medium .cnf /etc/my .cnf #拷贝配置文件 在 vi /etc/my .cnf添加如下几行 [mysqld] default-storage-engine=innodb #默认的存储引擎 innodb_file_per_table #使用独享的表空间 collation-server=utf8_general_ci #设置校对规则 init-connect= 'SETNAMESutf8' #设置链接的字符集 character- set -server=utf8 #设置默认的字符集 systemctl enable mariadb.service #开机启动数据库 systemctlstartmariadb.service #立马启动数据库 2.5 初始化数据库 2.6 为各个组件创建数据库并收授权 2.6.1 keystone 1 2 3 4 5 6 MariaDB[(none)]>createdatabasekeystone; QueryOK,1rowaffected(0.01sec) MariaDB[(none)]>grantallonkeystone.*to 'keystone' @ 'localhost' identifiedby 'keystonne' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>grantallonkeystone.*to 'keystone' @ '%' identifiedby 'keystone' ; QueryOK,0rowsaffected(0.00sec) 2.6.2 glance 1 2 3 4 5 MariaDB[(none)]>createdatabaseglance; QueryOK,1rowaffected(0.00sec) MariaDB[(none)]>grantallonglance.*to 'glance' @ '%' identifiedby 'glance' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>grantallonglance.*to 'glance' @ 'localhost' identifiedby 'glance' ; 2.6.3 nova和nova_api 1 2 3 4 5 6 7 8 9 10 11 MariaDB[(none)]>createdatabasenova; QueryOK,1rowaffected(0.00sec) MariaDB[(none)]>grantallonnova.*to 'nova' @ '%' identifiedby 'nova' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>grantallonnova.*to 'nova' @ 'localhost' identifiedby 'nova' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>createdatabasenova_api; QueryOK,1rowaffected(0.00sec) MariaDB[(none)]>grantallonnova_api.*to 'nova' @ 'localhost' identifiedby 'nova' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>grantallonnova_api.*to 'nova' @ '%' identifiedby 'nova' ; 2.6.4 neutron 1 2 3 4 5 6 7 8 MariaDB[(none)]>createdatabaseneutron; QueryOK,1rowaffected(0.00sec) MariaDB[(none)]>grantallonneutron.*to 'neutron' @ '%' identifiedby 'neutron' ; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>grantallonneutron.*to 'neutron' @ 'localhost' identifiedby 'neutron' ;; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>flushprivileges; QueryOK,0rowsaffected(0.00sec) 2.6.5 检验数据库 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 MariaDB[(none)]>showdatabases; +--------------------+ |Database| +--------------------+ |information_schema| |glance| |keystone| |mysql| |neutron| |nova| |nova_api| |performance_schema| +--------------------+ 8rowsinset(0.00sec) MariaDB[(none)]> 2.7 安装消息队列(rabbitmq) 2.7.1 基本安装 1 2 3 4 5 6 7 8 9 10 11 yuminstallrabbitmq-server-y systemctl enable rabbitmq-server.service systemctlstartrabbitmq-server.service [root@linux-node1~] #rabbitmqctladd_useropenstackopenstack#创建消息队列认证用户 Creatinguser "openstack" ... ... done . [root@linux-node1~] # #创建的用户得授权才能使用 [root@linux-node1~] #rabbitmqctlset_permissionsopenstack".*"".*"".*"#授权用户才能使用 Settingpermissions for user "openstack" in vhost "/" ... ... done . 2.7.2 web界面安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 查看组件 [root@linux-node1~] #rabbitmq-pluginslist []amqp_client3.3.5 []cowboy0.5.0-rmq3.3.5-git4b93c2d []eldap3.3.5-gite309de4 []mochiweb2.7.0-rmq3.3.5-git680dba8 []rabbitmq_amqp1_03.3.5 []rabbitmq_auth_backend_ldap3.3.5 []rabbitmq_auth_mechanism_ssl3.3.5 []rabbitmq_consistent_hash_exchange3.3.5 []rabbitmq_federation3.3.5 []rabbitmq_federation_management3.3.5 []rabbitmq_management3.3.5 []rabbitmq_management_agent3.3.5 []rabbitmq_management_visualiser3.3.5 []rabbitmq_mqtt3.3.5 []rabbitmq_shovel3.3.5 []rabbitmq_shovel_management3.3.5 []rabbitmq_stomp3.3.5 []rabbitmq_test3.3.5 []rabbitmq_tracing3.3.5 []rabbitmq_web_dispatch3.3.5 []rabbitmq_web_stomp3.3.5 []rabbitmq_web_stomp_examples3.3.5 []sockjs0.3.4-rmq3.3.5-git3132eb9 []webmachine1.10.3-rmq3.3.5-gite9359c7 加载组件 rabbitmq-plugins enable rabbitmq_management systemctlrestartrabbitmq-server.service #重启消息队列 说明 rabbitmq监听的是5672 rabbitmq的管理界面监听的是15672 2.7.3 访问测试 默认是用户guest 密码是guest 让openstack用户拥有admistrator的权限进行登录 本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/1883586,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册