手动搭建服务器配置[LNMP]

BBRPlus

wget https://github.com/cx9208/bbrplus/raw/master/centos7/x86_64/kernel-4.14.129-bbrplus.rpm

yum install -y kernel-4.14.129-bbrplus.rpm

grub2-set-default 'CentOS Linux (4.14.129-bbrplus) 7 (Core)'

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf

echo "net.ipv4.tcp_congestion_control=bbrplus" >> /etc/sysctl.conf

reboot

uname -r

rm -f kernel-4.14.129-bbrplus.rpm

Nginx

sudo yum install yum-utils vim

vim /etc/yum.repos.d/nginx.repo
# 粘贴下一个代码块的内容
sudo yum install nginx

firewall-cmd --zone=public --add-port=80/tcp --permanent

systemctl restart firewalld
# 开放 firewalld 的端口,也可以关闭 firewalld 服务一劳永逸
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

acme.sh

cd ~

mkdir .acme.sh

cd .acme.sh

curl  https://get.acme.sh | sh

alias acme.sh=~/.acme.sh/acme.sh

acme.sh  --issue  -d mydomain.com -d www.mydomain.com  --webroot  /home/wwwroot/mydomain.com/
# mydomain.com 修改为域名, /home/wwwroot/mydomain.com 修改为网站根目录
# 随后会显示证书的目录信息,拷贝至需要的地方即可

SSL For Nginx

cd /etc/nginx/conf.d

firewall-cmd --zone=public --add-port=443/tcp --permanent

systemctl restart firewalld

vim web.conf
# 粘贴下一个代码块的内容

systemctl restart nginx
server {
    listen       443 ssl;
    server_name  mydomain.com ssl; # 修改为自己的域名

    ssl_certificate     /root/.acme.sh/mydomain.com/mydomain.com.cer;
    ssl_certificate_key  /root/.acme.sh/mydomain.com/mydomain.com.key;
    # 修改为自己的域名
    ssl_session_timeout  5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

PHP

sudo yum install epel-release
# 安装 EPEL 软件包
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
# 安装 remi 源 与 安装 yum 扩展包
sudo yum-config-manager --enable remi-php74
# 启用 remi 仓库
sudo yum install php74
# 安装 PHP7.2
sudo yum install php74-php-fpm php74-php-gd php74-php-json php74-php-mbstring php74-php-mysqlnd php74-php-xml php74-php-xmlrpc php74-php-opcache
# 安装 php-fpm 和一些其他模块
sudo systemctl enable php74-php-fpm.service
sudo systemctl start php74-php-fpm.service
# 设置开机自启

MySQL

cd /

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar

tar -xvf mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar

useradd -s /sbin/nologin -M mysql

id mysql

yum -y install gcc-c++ ncurses ncurses-devel perl bison openssl openssl-devel gcc* libxml2 libxml2-devel

rpm -e --nodeps mariadb-libs

rpm -ivh --nodeps mysql-community-common-8.0.23-1.el7.x86_64.rpm

rpm -ivh --nodeps mysql-community-libs-8.0.23-1.el7.x86_64.rpm

rpm -ivh --nodeps mysql-community-client-8.0.23-1.el7.x86_64.rpm

rpm -ivh --nodeps mysql-community-server-8.0.23-1.el7.x86_64.rpm

yum install -y libaio

mysqld --initialize --user=mysql

cat /var/log/mysqld.log
# 查看数据库密码,为显示的最后一段
systemctl start mysqld

systemctl enable mysqld

mysql -u root -p

alter user 'root'@'localhost' identified by '123123';
# 修改密码
flush privileges;
# 清空
quit

rm -f *.rpm

WordPress

cd /usr/share/nginx/html/

rm -f *

wget https://wordpress.org/latest.tar.gz

tar -zxvf latest.tar.gz

rm -f latest.tar.gz

mv ./wordpress/* ./

rmdir wordpress

vim /etc/nginx/conf.d/web.conf
# 粘贴下一个代码框的内容
chown apache:apache -R /usr/share/nginx/html

mysql -u root -p

CREATE DATABASE WordPress;
# 创建一个名叫 WordPress 的数据库,访问网页时填写即可
server {
    listen       443 ssl;
    server_name  mydomain.com ssl; # 修改为自己的域名

    ssl_certificate     /root/.acme.sh/mydomain.com/mydomain.com.cer;
    ssl_certificate_key  /root/.acme.sh/mydomain.com/mydomain.com.key;
    # 修改为自己的域名
    ssl_session_timeout  5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Close Firewalld

systemctl stop firewalld
# 关闭
systemctl disable firewalld
# 关闭开机自启
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇