微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

LNMP配置

编译安装LNMP,并安装wordpress

  1. 安装mariadb和PHP-fpm
    yum install mariadb-server PHP-fpm PHP-MysqL -y
  2. 配置mariadb

        systemctl start mariadb
        MysqL_secure_installation
        MysqL -p123 -e "CREATE DATABASE wpdb;GRANT ALL ON wpdb.* TO 'wpdb'@'%' IDENTIFIED BY '123';"
  3. 下载并编译Nginx源码1.16版

        # 安装编译环境
        yum install gcc pcre-devel openssl-devel zlib-devel -y
        # 解包
        tar -zxvf Nginx-1.16.1.tar.gz
        # 增加Nginx用户
        useradd -r -s /sbin/nologin Nginx
        # 开始编译
        ./configure --prefix=/opt/Nginx \
            --user=Nginx \
            --group=Nginx \
            --with-http_ssl_module \
            --with-http_v2_module \
            --with-http_dav_module \
            --with-http_stub_status_module \
            --with-threads \
            --with-file-aio \
            --with-http_realip_module \
            --with-http_gzip_static_module \
            --with-pcre \
            --with-stream \
            --with-stream_ssl_module \
            --with-stream_realip_module\
            --conf-path=/etc/Nginx/Nginx.conf \
            --error-log-path=/var/log/Nginx/error.log \
            --http-log-path=/var/log/Nginx/access.log \
            --pid-path=/var/run/Nginx.pid \
            --lock-path=/var/run/Nginx.lock
        make && make install
  4. 配置PHP-fpm
    更改/etc/PHP-fpm.d/www.conf

        user = Nginx
        group = Nginx
    systemctl start PHP-fpm
  5. 安装wordpress
    tar -zxvf wordpress-4.9.13.tar.gz -C /
    复制/wordpress/wp-config-sample.PHP到/wordpress/wp-config.php并更改内容

        /** The name of the database for wordpress */
        define('DB_NAME', 'wpdb');
    
        /** MysqL database username */
        define('DB_USER', 'wpdb');
    
        /** MysqL database password */
        define('DB_PASSWORD', '123');
    
        /** MysqL hostname */
        define('DB_HOST', 'localhost');
    setfacl -R -m u:Nginx:rwx /wordpress
  6. 配置Nginx
    ln -s /opt/Nginx/sbin/Nginx /usr/sbin/
    vim /etc/Nginx/Nginx.conf在server中

        listen 80;
        server_name www.chaoyi.com;
        location ~* \.PHP$ {
            root /wordpress;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.PHP;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        } 

    配置虚拟主机,www.chao.com域名实现首页访问,admin.chao.com域名实现wordpress后台访问

    在上一个配置基础上于http{}中加入

    server { 
        listen      80; 
        server_name admin.chaoyi.com;
        index wp-login.PHP;
        location ~* \.PHP$ {
            root /wordpress;
            fastcgi_pass 127.0.0.1:9000;                                      
            fastcgi_index index.PHP;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐