搜索

一、 介绍

微擎是一家开源的公众平台SAAS领域技术服务提供商,成立于2013年7月,总部位于安徽宿州。微擎是免费开源的公众平台管理系统,拥有近百万的注册用户数,开发者认证超20,000名,3,000+款应用插件,10,000+应用场景,服务规模超200,000家,直接间接服务用户过亿--百度百科

二、搭建LNMP环境

  1. 查看wget是否安装

    `rpm -qa wget`
    
    没有则安装
    
    `yum install wget`</p>
  2. 查看是否安装编译器

    `rpm -qa gcc`
    
    没有则安装
    
    `yum install gcc gcc-c++`
    
  3. 安装Nginx
  • 安装Nginx依赖:

    yum -y install pcre pcre-devel
    yum -y install zlib zlib-devel
    yum -y install openssl openssl-devel
    `</pre>

  • 下载并解压Nginx:
`     cd /usr/local/src
         wget http://nginx.org/download/nginx-1.18.0.tar.gz
         tar -zxvf nginx-1.18.0.tar.gz
    `
  • 编译安装Nginx:
`     cd nginx-1.18.0
         ./configure --prefix=/usr/local/nginx
         make
         make install
    `
  • 创建nginx账号:
`     groupadd nginx
         useradd -M -g nginx -s /sbin/nologin nginx
         cd /usr/local/nginx/conf
    `
`vim nginx.conf`
    将第一行user改为:
     `user nginx nginx`
     完成后执行命令
     `/usr/local/nginx/sbin/nginx -t`
     ESC+:wq+Enter退出并保存
  1. 启动Nginx:/usr/local/nginx/sbin/nginx ,浏览器输入服务器公网IP,出现Welcome to nginx!则启动成功
  2. 安装MySQL
  • 下载并应用MySQL的yum资源包:
`     cd ~
         wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
         rpm -ivh mysql-community-release-el7-5.noarch.rpm
         yum update
         yum install mysql-server
    `
  • 改变文件属主和属组:

    `chown mysql:mysql -R /var/lib/mysql`
  • 初始化并启动MySQL:

    `mysqld --initialize`
    `service mysqld start`
  • 修改密码并登陆MySQL:

    `mysqladmin -u root password "your-password"`
    `mysql -u root -p`
    输入密码登陆,出现`mysql&gt;`则成功
    
  1. 安装PHP
  • 安装PHP依赖:
`     yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
    `
  • 下载PHP:

    `wget https://www.php.net/distributions/php-7.3.21.tar.gz`
    `tar -zxvf php-7.3.21.tar.gz`
  • 编译安装:
`     cd php-7.3.21
         ./configure --prefix=/usr/local/php --disable-fileinfo --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-zip --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --enable-bcmath
         make
         make install
    `
  • 移动PHP配置文件:

    `cp php.ini-development /etc/php.ini`
  • 配置php-fpm运行账号:
`     cd /usr/local/php/etc
         cp php-fpm.conf.default php-fpm.conf
         cd php-fpm.d
         cp www.conf.default www.conf
    `
`vim www.conf`
将其中的`user=nobody`和`group=nobody`改为`user=nginx`和`group=nginx`
  1. 使Nginx支持PHP
  • 修改配置文件:vim /usr/local/nginx/conf/nginx.conf
`         #location ~ .php$ {
             #    root           html;
             #    fastcgi_pass   127.0.0.1:9000;
             #    fastcgi_index  index.php;
             #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
             #    include        fastcgi_params;
             #}
    `
将其中的改为注释取消,ESC+:wq+Enter退出并保存
  • 将Nginx添加到系统服务:

    `vim /etc/init.d/nginx`
    ​  内容为:
    
`     #!/bin/sh
         # nginx - this script starts and stops the nginx daemin
         #
         # chkconfig:   - 85 15
         # description:  Nginx is an HTTP(S) server, HTTP(S) reverse 
         #               proxy and IMAP/POP3 proxy server
         # processname: nginx
         # config:      /usr/local/nginx/conf/nginx.conf
         # pidfile:     /usr/local/nginx/logs/nginx.pid
         # Source function library.
         . /etc/rc.d/init.d/functions
         # Source networking configuration.
         . /etc/sysconfig/network
         # Check that networking is up.
         [ "$NETWORKING" = "no" ] && exit 0
              nginx="/usr/local/nginx/sbin/nginx"
              prog=$(basename $nginx)
              NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
              lockfile=/var/lock/subsys/nginx
              start() {
                  [ -x $nginx ] || exit 5
                  [ -f $NGINX_CONF_FILE ] || exit 6
                  echo -n $"Starting $prog: "
                  daemon $nginx -c $NGINX_CONF_FILE
                  retval=$?
                  echo
                  [ $retval -eq 0 ] &amp;&amp; touch $lockfile
                  return $retval
              }
                 stop() {
                  echo -n $"Stopping $prog: "
                  killproc $prog -QUIT
                  retval=$?
                  echo
                  [ $retval -eq 0 ] &amp;&amp; rm -f $lockfile
                  return $retval
              }
                          restart() {
                  configtest || return $?
                  stop
                  start
              }
                   reload() {
                  configtest || return $?
                  echo -n $"Reloading $prog: "
                  killproc $nginx -HUP
                  RETVAL=$?
                  echo
              }
              force_reload() {
                  restart
              }
                   configtest() {
                $nginx -t -c $NGINX_CONF_FILE
              }
                        rh_stlatus() {
                  status $prog
              }
                   rh_status_q() {
                  rh_status >/dev/null 2>&1
              }
              case "$1" in
                  start)
                      rh_status_q && exit 0
                 $1
                 ;;
                  stop)
                           rh_status_q || exit 0
                 $1
                 ;;
                  restart|configtest)
                 $1
                 ;;
                  reload)
                 rh_status_q || exit 7
                 $1
                 ;;
                       force-reload)
                 force_reload
                 ;;
             status)
                 rh_status
                 ;;
                       condrestart|try-restart)
                      rh_status_q || exit 0
                     ;;
                  *)
                      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
                 exit 2
              esac
    `
`chmod 755 /etc/init.d/nginx`
`chkconfig –add nginx`
  • 重启Nginx:

    `service nginx restart`
    
  1. 设置php-fpm为系统服务:
  • 添加配置文件:

    `vim /etc/systemd/system/php-fpm.service`
    内容为
    
`     [Unit]
              Description=php-fpm
              After=network.target
              [Service]
              Type=forking
              ExecStart=/usr/local/php/sbin/php-fpm
              PrivateTmp=True
              [Install]
              WantedBy=multi-user.target
    `
ESC+:wq+Enter退出并保存
  1. 设置php-fpm开机自启并启动php-fpm:
  • 设置php-fpm开机自启动:

    `systemctl enable php-fpm.service`
  • 启动php-fpm:

    `systemctl start php-fpm.service`
  • 查看启动是否成功:

    `ps aux | grep php-fpm`
    
    #### 三、搭建微擎
    
  1. 创建站点:
  • 创建Nginx配置文件

    `mkdir -p /usr/local/nginx/vhost/weengine`
    `vim /usr/local/nginx/vhost/vhost_weengine.conf`
    内容为:
    
`     server {
                 listen       80;
                 server_name  localhost;
                      #charset koi8-r;
                      #access_log  logs/host.access.log  main;
                      location / {
                     root   vhost/weengine;
                     index  index.html index.htm;
                 }
                      #error_page  404              /404.html;
                      # redirect server error pages to the static page /50x.html
                 #
                 error_page   500 502 503 504  /50x.html;
                 location = /50x.html {
                     root   html;
                 }
                      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
                 #
                 #location ~ .php$ {
                 #    proxy_pass   http://127.0.0.1;
                 #}
                      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                 #
                 location ~ .php$ {
                     root           html;
                     fastcgi_pass   127.0.0.1:9000;
                     fastcgi_index  index.php;
                     fastcgi_param  SCRIPT_FILENAME /usr/local/nginx/vhost/weengine$fastcgi_script_name;
                     include        fastcgi_params;
                 }
                      # deny access to .htaccess files, if Apache's document root
                 # concurs with nginx's one
                 #
                 #location ~ /.ht {
                 #    deny  all;
                 #}
             }
              vim /usr/local/nginx/conf/nginx.conf
               修改nginx默认端口listen       800;
              include /usr/local/nginx/vhost/*.conf;

vim /usr/local/nginx/conf/nginx.conf

在http{}代码块最后添加

include /usr/local/nginx/vhost/*.conf;

重启nginx

service nginx restart

*   下载并解压微擎

    cd /usr/local/nginx/vhost/weengine

    wget https://cdn.w7.cc/download/WeEngine-Laster-Online.zip

    unzip https://cdn.w7.cc/download/WeEngine-Laster-Online.zip

1.  配置微擎

*   浏览器输入公网IP/install.php按提示一步步配置即可

<p>参考文章:

LNMP环境搭建(linux+Nginx + Mysql + PHP)

service nginx start|stop|reload 报错:Failed to reload nginx.service: Unit not found.【解决方案】            

阿里云 LNMP 服务器 ECS 笔记 实践训练营 微擎 MySQL PHP Nginx

版权属于:Aersbox
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
0
查看目录

目录

来自 《ECS 7天实践训练营(三)-搭建公众号管理系统微擎》
评论

世界上只有一种真正的英雄主义,那就是在认清生活真相之后依然热爱生活。