搭建博客

优化

# 防火墙
sudo systemctl disable firewalld.service
sudo systemctl stop firewalld.service
# 关闭selinux 2个路径哪个都可以进去修改
/etc/selinux/config
/etc/sysconfig/selinux
# 换源
cd /etc/yum.repos.d/
rm -f /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 最大那个啥 忘记了
echo '* - nofile 65535' >> /etc/security/limits.conf
# 安装依赖
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel  openldap-clients openldap-servers libxslt-devel libevent-devel ntp  libtool-ltdl bison libtool vim-enhanced patch
# 安装一些命令
yum install net-tools vim tree htop iftop gcc gcc-c++ glibc\
  iotop lrzsz sl wget unzip telnet nmap nc psmisc \
  dos2unix bash-completion bash-completion-extra sysstat \
  rsync nfs-utils httpd-tools ntpdate -y
# 外网网卡的配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.100
PREFIX=24
GATEWAY=10.0.0.2
DNS1=223.5.5.5
DNS2=223.6.6.6
# 内网网卡的配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.1.100
NETMASK=255.255.255.0
# 让命令行花里胡哨的
/etc/profile 
PS1="\[\e[31;1m\][\[\e[33;1m\]\u\[\e[32;40m\]@\[\e[36;40m\]\h \[\e[35;40m\]\W]\\$ \[\e[0m\]"
# 同步时间
ntpdate ntp.aliyun.com

创建用户

[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M

官方源安装nginx

[root@web01 ~]# vim /etc/yum.repos.d/nginx.repo 
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@web01 ~]# yum install -y nginx

修改nginx用户

[root@web01 ~]# vim /etc/nginx/nginx.conf 
user  www;

卸载原来php

[root@web01 ~]# yum remove php-mysql-5.4 php php-fpm php-common
## 上传rpm包,先创建个目录
[root@web01 ~]# mkdir /package
[root@web01 ~]# cd /package
[root@web01 package]# rz php.tar.gz
[root@web01 package]# tar xf php.tar.gz
[root@web01 package]# yum localinstall -y *.rpm

修改php用户

[root@web01 package]# vim /etc/php-fpm.d/www.conf
user = www
group = www

密码配置文件

[root@web01 ~]# htpasswd -c /etc/nginx/auth_basic dzy
#查看
[root@web02 ~]# vim /etc/nginx/auth_basic

写nginx配置文件

## 把默认的配置文件压缩
[root@web01 ~]# gzip /etc/nginx/conf.d/default.conf 
[root@web01 ~]# vim /etc/nginx/conf.d/www.wp.com.conf 
#连接限制模块
#limit_conn_zone $remote_addr zone=conn_zone:1m;
#请求限制模块
#limit_req_zone $remote_addr zone=req_zone:1m rate=1r/s;
server {
		#监听端口
        listen 80;
        ##域名
        server_name www.wp.com.com;
        #连接限制
        #limit_conn conn_zone 1;
        #请求限制
        #limit_req zone=req_zone;
        #中文字符集
        charset utf-8;
        #日志目录
        access_log /var/log/nginx/www.wp.com.log main;
        try_files $uri $uri/ /index.php?$args;
        #站点目录
        location / {
                root /code/wp;
                index index.php;
        }
        location ~* \.php$ {
                root /code/wp;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        #下载站点目录
                location /package {
                #开启站点
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
                index index.html;
        }
                location /note {
                #开启站点
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
                index index.html;
        }
                location /other {
                #开启站点
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
                index index.html;
        }
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
		#是否开启密码登录
		#auth_basic "输入用户名和密码";
		#auth_basic_user_file /etc/nginx/auth_basic;
		##访问控制模块
		#allow 10.0.0.1;
		#deny all;
}

创建数据库

[root@web01 code]# yum install -y mariadb-server
[root@web01 ~]# systemctl start mariadb
[root@db01 ~]# mysqladmin -uroot password '123'
[root@web01 ~]# mysql -uroot -p123
## 创建wp数据库
MariaDB [(none)]> create database wp;
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wp                 |
+--------------------+
5 rows in set (0.00 sec)

创建wp

[root@web01 ~]# mkdir /code
[root@web01 ~]# cd /code
[root@web01 code]# rz wordpress-5.5.zip
[root@web01 code]# unzip wordpress-5.5.zip
[root@web01 code]# mv wordpress wp
##添加主题
[root@web01 ~]# cd /code/wp/wp-content/themes
[root@web01 themes]# rz 主题.zip
[root@web01 themes]# unzip 主题.zip
[root@web01 themes]# rm -fr 主题.zip

创建下载目录

[root@web01 ~]# mkdir -p /code/wp/{package,note,other}
## 你可以rz上传自己的一些文件

修改上传文件大小限制

[root@web01 ~]# vim /etc/nginx/nginx.conf
http {
	... ...
    client_max_body_size 100M;
    ... ...
}
#修改php上传文件大小
[root@web01 ~]# vim /etc/php.ini
post_max_size = 100M
upload_max_filesize = 100M

统一目录权限

[root@web01 ~]# chown -R www.www /code
[root@web01 ~]# systemctl start php-fpm nginx

加入开机自启

[root@web01 ~]# systemctl enable nginx php-fpm mariadb

本文作者:ycmyay

本文链接:https://www.cnblogs.com/ycmyay/p/17383832.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   也曾滿眼愛意丶  阅读(15)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑