Пример #1
0
        private void button10_Click(object sender, EventArgs e)
        {
            var serviceControllers = ServiceController.GetServices();

            var ApacheService = serviceControllers.FirstOrDefault(service => service.ServiceName == mysql);

            if (ApacheService == null)
            {
                string cmdline = rootPath + "\\soft\\mysql\\mysql-5.7.28-winx64\\bin\\mysqld.exe -install";

                cmd.ShowOpaqueLayer(this.tabPage1, 125, true);
                try
                {
                    this.writeLog("安装MySQL服务");
                    ThreadPool.QueueUserWorkItem(new WaitCallback(ExeCmd), cmdline);
                }
                catch (Exception ee)
                {
                }
                if (!File.Exists(rootPath + @"\soft\mysql\mysql-5.7.28-winx64\my.ini"))
                {
                    MessageBox.Show("数据库配置文件不存在或路径错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                INIUtil iniUtil = new INIUtil(rootPath + @"\soft\mysql\mysql-5.7.28-winx64\my.ini");

                iniUtil.Write("mysqld", "basedir", "\"" + rootPath.Replace(@"\", @"/") + @"/soft/mysql/mysql-5.7.28-winx64""");
                iniUtil.Write("mysqld", "datadir", "\"" + rootPath.Replace(@"\", @"/") + @"/soft/mysql/mysql-5.7.28-winx64/data""");
            }
            else
            {
                MessageBox.Show(mysql + "服务已存在,请勿重复安装", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #2
0
 private void btn_updateServerInfo_Click(object sender, EventArgs e)
 {
     try
     {
         if (INIUtil.Write("Server", "ip", label_serverIP.Text, Constant.IniFilePath) > 0 && INIUtil.Write("Server", "port", num_serverPort.Value.ToString(), Constant.IniFilePath) > 0)
         {
             MessageBox.Show("服务器信息修改成功", "提示");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("服务器信息修改失败,请重试!", "提示");
     }
 }
        public void init()
        {
            //
            if (false == System.IO.Directory.Exists(rootPath + @"\soft"))
            {
                MessageBox.Show("未安装环境包", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                try
                {
                    System.Environment.Exit(0);
                }
                catch (Exception ep)
                {
                }
            }
            //


            //PHP初始化START
            if (File.Exists(rootPath + @"\soft\php\php7.0.9nts\php.ini"))
            {
                INIUtil iniUtil                   = new INIUtil(rootPath + @"\soft\php\php7.0.9nts\php.ini");
                string  php_extension_dir         = "\"" + rootPath.Replace(@"\", @"/") + @"/soft/php/php7.0.9nts/ext""";
                string  default_extension_dir     = "";
                string  php_session_save_path     = "\"" + rootPath.Replace(@"\", @"/") + @"/soft/php/session_tmp""";
                string  default_session_save_path = "";
                try
                {
                    default_extension_dir = iniUtil.ReadValue("extension_dir", "PHP");
                    if (!default_extension_dir.Equals(php_extension_dir))
                    {
                        iniUtil.Write("PHP", "extension_dir", php_extension_dir);
                    }

                    default_session_save_path = iniUtil.ReadValue("session.save_path", "Session");
                    if (!default_session_save_path.Equals(php_session_save_path))
                    {
                        iniUtil.Write("Session", "session.save_path", php_session_save_path);
                    }
                }
                catch (Exception ep)
                {
                }
            }

            //PHP初始化END


            //APACHE
            string apache_path      = Application.StartupPath + @"\soft\apache\Apache24";
            string apache_conf_path = Application.StartupPath + @"\soft\apache\Apache24\conf\httpd.conf";

            if (File.Exists(apache_conf_path))
            {
                StreamReader apache_conf_string         = new StreamReader(apache_conf_path, System.Text.Encoding.Default);
                string       default_apache_conf_string = apache_conf_string.ReadToEnd();
                apache_conf_string.Close();
                if (!default_apache_conf_string.Contains(apache_path))
                {
                    try
                    {
                        System.IO.File.WriteAllText(apache_conf_path, WFC.apache_conf, new System.Text.UTF8Encoding(false));
                    }
                    catch (Exception ep)
                    {
                        Console.WriteLine(ep.Message);
                    }
                }
            }


            //APACHE
            //Console.WriteLine(WFC.apache_conf);
            string apache_phpmyadmin_conf_path = Application.StartupPath + @"\soft\apache\Apache24\conf\vhosts\demo.conf";

            try
            {
                System.IO.File.WriteAllText(apache_phpmyadmin_conf_path, WFC.apache_phpmyadmin_conf, new System.Text.UTF8Encoding(false));
            }
            catch (Exception ep)
            {
                Console.WriteLine(ep.Message);
            }

            //PHPMYADMIN



            //



            this.writeLog("初始化系统成功!");
        }