目录
Home
Apache2 的安装、启动、停止、重启
正常安装过程
在终端输入更新检查命令
sudo apt-get update
在更新完成后(如果不想检查更新,也可直接输入此步)输入
sudo apt-get install apache2
完成后,在浏览器输入 http://localhost 或者 127.0.0.1,如果顺利跳出Apache版本网页,即代表安装成功
停止服务:
sudo /etc/init.d/apache2 stop
相关目录如下
Apache的默认文档根目录
/var/www
配置文件是
/etc/apache2/apache2.conf
配置存储在的子目录在
/etc/apache2
假设情况
本文假设你的apahce安装目录为 /usr/local/apache2,这些方法适合任何情况
apahce启动命令:
/usr/local/apache2/bin/apachectl start
apache停止命令
/usr/local/apache2/bin/apachectl stop
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart
要在重启 Apache 服务器时不中断当前的连接,则应运行:
/usr/local/sbin/apachectl graceful
如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start 启动 service httpd restart 重新启动 service httpd stop 停止服务
其他有可能的安装目录
/usr/sbin/apachectl
修改PHP服务的时区
修改 php.ini, 一般位于 /etc/php.ini
在 [Date] 节点下 取消注释 date.timezone 或加入下面这一行:
date.timezone = Asia/Hong_Kong
查看所有时区标识 http://us.php.net/timezones
换行符
winform 中 TextBox 的 Multiline属性设置为 true ,敲入几个字符和几个回车,然后保存到数据库,再从数据库中读取出来赋值给TextBox,换行符丢失。将读取出的字符串中的“\n”替换为“\r\n”解决问题。
- 数字列表项目TextBox 中换行符为: “\r\n”。
- Windows 中的换行符(即:Environment.NewLine) 为 “\r\n”
- MessageBox.Show() 的换行符为 “\n”
- Console 的换行符为 “\n”
从数据库中读取出来后,换行符不知为啥变成 “\n”,“\r” 莫名的丢失了。为正确显示格式要将 “\n” 替换为 “\r\n” 换行符还因平台而已,Unix/Linux 平台换行符是 “\n”。 为保持平台的通用性,最好用 Environment.NewLine。
规则统一的窗体打开管理类,限制重复打开窗体
- formsmanager.cs
using System; using System.Windows.Forms; using System.Reflection; using System.Collections; //using FD3DS.Forms; namespace EarthView.Method { class FormsManager { #region 变量 /// <summary> /// 当前已经打开的窗口对象列表 /// </summary> static ArrayList FormList = new ArrayList(); #endregion #region 创建窗体 ///// <summary> ///// 打开图层管理器 ///// </summary> ///// <returns></returns> //public static frmLayerManager OpenFrmLayerManager(IWin32Window ower) //{ // Object frm = OpenForm(typeof(frmLayerManager), ower); // return frm as frmLayerManager; //} #endregion #region 关闭窗体 /// <summary> /// 关闭窗体时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void ClosingForm(object sender, FormClosingEventArgs e) { FormList.Remove(sender); } /// <summary> /// 关闭当前所有的窗体 /// </summary> public static void CloseAllForm() { for (int i = 0; i < FormList.Count; i++) { if (FormList[i] is Form) { Form frm = FormList[i] as Form; frm.Dispose(); frm = null; FormList.RemoveAt(i); i--; } } } #endregion #region 已打开窗体检测 /// <summary> /// 查看已打开的窗口是否包括该名称的对象 /// </summary> /// <param name="formName"></param> /// <returns></returns> public static bool IsFormExist(ref object form, string formName) { bool opened = false; foreach (object frm in FormList) { if (!(frm is Form)) continue; if ((frm as Form).Name == formName) { opened = true; form = frm; break; } } return opened; } #endregion #region 打开窗体复用代码 /// <summary> /// 打开窗体 /// </summary> /// <param name="objType">窗体对象类型,如: typeof(Form)</param> /// <param name="construct_types">构造函数所需类型集合,如: new Type[] { typeof(string), typeof(int) }</param> /// <param name="construct_values">构造函数传递参数集合,如: new Object[] { "helloworld", 101 }</param> /// <param name="ower">窗体拥有者</param> /// <param name="flag">窗体唯一标示,可不填,默认使用窗体类型作为标示</param> /// <returns></returns> public static Object OpenForm(Type objType, IWin32Window ower, Type[] construct_types=null, object[] construct_values = null, string flag = "") { #region 判断 //窗体名称 if (string.IsNullOrEmpty(flag)) flag = objType.ToString(); //构造函数类型 if (construct_types == null) construct_types = new Type[] { }; //构造函数传递参数 if (construct_values == null) construct_values = new object[] { }; //类型与传递值须一致 if (construct_types.Length != construct_values.Length) { construct_types = new Type[] { }; construct_values = new object[] { }; } #endregion Type type = objType; if (type == null) return null; object obj = null; object getObj = null; //构造 ConstructorInfo construct = type.GetConstructor(construct_types); if (IsFormExist(ref getObj, flag)) { obj = getObj; //窗体是否已经关闭 object _isDisposed = type.GetProperty("IsDisposed").GetValue(obj, null); if (_isDisposed.ToString().ToLower() == "true") { obj = construct.Invoke(construct_values);//构造 FormList.Remove(getObj); FormList.Add(obj); } } else { obj = construct.Invoke(construct_values);//构造 FormList.Add(obj); } //名称 type.GetProperty("Name").SetValue(obj, flag, null); //允许透明 type.GetProperty("AllowTransparency").SetValue(obj, true, null); //透明度 type.GetProperty("Opacity").SetValue(obj, 0.8d, null); //启动位置 type.GetProperty("StartPosition").SetValue(obj, FormStartPosition.CenterScreen, null); //状态栏显示 type.GetProperty("ShowInTaskbar").SetValue(obj, false, null); object _visible = type.GetProperty("Visible").GetValue(obj, null); //使窗体显示 if (_visible.ToString().ToLower() == "false") { type.GetMethod("Show", new Type[] { typeof(IWin32Window) }).Invoke(obj, new Object[] { ower }); } //激活窗体 type.GetMethod("Activate", new Type[] { }).Invoke(obj, new Object[] { }); return obj; } /// <summary> /// 打开窗体示例 /// </summary> /// <returns></returns> public static Form OpenFrmOldMethod(IWin32Window ower) { Form frm = null; object getfrm = null; if (IsFormExist(ref getfrm, "Form1")) { frm = getfrm as Form; if (frm.IsDisposed) { frm = new Form(); FormList.Remove(getfrm); FormList.Add(frm); } } else { frm = new Form(); FormList.Add(frm); } frm.Name = "Form1"; frm.AllowTransparency = true; frm.Opacity = 0.8; frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowInTaskbar = false; if (!frm.Visible) frm.Show(ower); return frm; } /// <summary> /// 打开窗体新示例 /// </summary> /// <returns></returns> public static Form OpenFrmNewMethod(IWin32Window ower) { //构造函数无参数 Object frm = OpenForm(typeof(Form), ower); return frm as Form; ////构造函数有参数 //Object frm2 = OpenForm(typeof(Form), ower, // new Type[] { typeof(int), typeof(string) }, // new object[] { 101, "hello world" }, // "钥匙A"); //return frm2 as Form; } #endregion } }
防止窗体打开多次
/// <summary> /// 当前已经打开的窗口对象名称列表 /// </summary> public static ArrayList FormList = new ArrayList(); /// <summary> /// 查看已打开的窗口是否包括该名称的对象 /// </summary> /// <param name="formName"></param> /// <returns></returns> public static bool IsFormExist(ref Form form, string formName) { bool opened = false; foreach (Form frm in FormList) { if (frm.Name == formName) { opened = true; form = frm; break; } } return opened; } private void frmProjectManager_FormClosed(object sender, FormClosedEventArgs e) { Functions.FormList.Remove(this); } /// <summary> /// 新建项目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ctBtb_NewProject_Click(object sender, EventArgs e) { frmProjectManager frmProjectManager1 = null; Form frm = null; if (Functions.IsFormExist(ref frm, "frmProjectManager1")) { frmProjectManager1 = frm as frmProjectManager; } else { frmProjectManager1 = new frmProjectManager(); Functions.FormList.Add(frmProjectManager1); } frmProjectManager1.Name = "frmProjectManager1"; frmProjectManager1.Location = new Point(Functions.FrmBounds.Left, Functions.FrmBounds.Top); if(!frmProjectManager1.Visible) frmProjectManager1.Show(this); }
防止程序打开、运行、启动多次(a,GUID)
实现思路:
在Main()方法开始时遍历所有进程,获取每个进程的程序集GUID和PID,若发现有跟自己GUID相同且PID不同的进程,就勒令自身退出。 注:
- 采用GUID是为了尽可能保证判定的可靠性,采用进程名太不靠谱。而且程序集GUID是建立项目时就生成的,不随版本、内容的变化而变化,所以除非人为改动,否则同一项目编译若干次都还是那个GUID,用来判断程序集身份再适合不过。题外,网上盛传的互斥体方法,互斥名也建议用GUID;
- 之所以要加上进程ID的判断,是因为遍历的进程中已经包含自身进程,所以必须排除自身;
- 访问某些进程的MainModule属性会引发异常,所以采用try-catch跳过这些进程;
- 经尝试只有C#写的程序才能获取到GUID(有点废话~),但这样已经足够;
- 退出自身这里采用的是Environment.Exit()方法,Application.Exit()方法不管用,程序仍然会运行,我猜原因是Application都还没Run过,所以Exit不了~(小弟入门水平,很多东西只能靠坑蒙拐骗~哦不,是连蒙带猜)
- testallapirefreshpolicy.cs
using System; using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; namespace TestCallAPIRefreshPolicy { static class Program { [STAThread] static void Main() { Guid ownGUID = new Guid(((GuidAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute))).Value); Guid proGUID; int ownPID = Process.GetCurrentProcess().Id; int proPID; foreach (Process p in Process.GetProcesses()) { try { proGUID = new Guid(((GuidAttribute)Attribute.GetCustomAttribute(Assembly.LoadFile(p.MainModule.FileName), typeof(GuidAttribute))).Value); proPID = p.Id; if (proGUID.Equals(ownGUID) && proPID != ownPID) { MessageBox.Show("程序已运行"); Environment.Exit(Environment.ExitCode); } } catch { continue;//遇上进程访问异常就跳过该进程 } } //若未被Exit,正常启动 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FmMain()); } } }
防止程序启动多次
经常我们会有这样的需求,只让应用程序运行一个实体。通常我们的情况是,双击一个exe文件,就运行一个程序的实体,再双击一次这个exe文件,又运行这个应用程序的另一个实体。就拿QQ游戏来说吧,一台电脑上一般只能运行一个QQ游戏大厅(不过以前听说过有双开的)。 那我们的程序也能像QQ游戏那里禁止多次启动吗,答案是可以的,下面介绍下一个简单的实现方法,那就是Mutex(互斥)。
Mutex(mutual exclusion,互斥)是.Net Framework中提供跨多个线程同步访问的一个类。它非常类似了Monitor类,因为他们都只有一个线程能拥有锁定。而操作系统能够识别有名称的互斥,我们可以给互斥一个唯一的名称,在程序启动之前加一个这样的互斥。这样每次程序启动之前,都会检查这个命名的互斥是否存在。如果存在,应用程序就退出。
- main.cs
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { bool createdNew; //系统能够识别有名称的互斥,因此可以使用它禁止应用程序启动两次 //第二个参数可以设置为产品的名称:Application.ProductName //每次启动应用程序,都会验证名称为SingletonWinAppMutex的互斥是否存在 Mutex mutex = new Mutex(false, "SingletonWinAppMutex", out createdNew); //如果已运行,则在前端显示 //createdNew == false,说明程序已运行 if (!createdNew) { Process instance = GetExistProcess(); if (instance != null) { SetForegroud(instance); Application.Exit(); return; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } /// <summary> /// 查看程序是否已经运行 /// </summary> /// <returns></returns> private static Process GetExistProcess() { Process currentProcess = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessName)) { if ((process.Id != currentProcess.Id) && (Assembly.GetExecutingAssembly().Location == currentProcess.MainModule.FileName)) { return process; } } return null; } /// <summary> /// 使程序前端显示 /// </summary> /// <param name="instance"></param> private static void SetForegroud(Process instance) { IntPtr mainFormHandle = instance.MainWindowHandle; if (mainFormHandle != IntPtr.Zero) { ShowWindowAsync(mainFormHandle, 1); SetForegroundWindow(mainFormHandle); } } [DllImport("User32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("User32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); }
评论
I'd suggest this article to everyone curious about this field. Clear descriptions of important ideas. 1xbet
I'd suggest this article to everyone curious about this field. Clear descriptions of important ideas. 1xbet
I completely concur with your main argument. Additionally, I would add that this aspect is equally important. 1xbet
I completely concur with your main argument. Additionally, I would add that this aspect is equally important. 1xbet
mostbet РФ Your fortune awaits! Enjoy exclusive bonuses! Stay tuned for special events! Subscribe to our newsletter for more! Play big! Tell your colleagues about us! Huge thanks for being part of us! Very professional! Our site is fantastic! Following your latest events! Liked and registered! You're an undisputed expert! Will share with on social media! Thank you for your assistance! Very rewarding experience! Your efforts always lead to wins! mostbet играть mostbet Кыргызстан mostbet mostbet kz
mostbet РФ Your fortune awaits! Enjoy exclusive bonuses! Stay tuned for special events! Subscribe to our newsletter for more! Play big! Tell your colleagues about us! Huge thanks for being part of us! Very professional! Our site is fantastic! Following your latest events! Liked and registered! You're an undisputed expert! Will share with on social media! Thank you for your assistance! Very rewarding experience! Your efforts always lead to wins! mostbet играть mostbet Кыргызстан mostbet mostbet kz
mostbet Azərbaycan Hit the jackpot with us! Unlock your fortune! Play with ease on our licensed platform! Don't miss out on huge jackpots! Win big! Share the joy with friends! Grateful for your loyalty! Simply fantastic! Your efforts always result in victories! Eagerly awaiting your upcoming tournaments! Bookmarked your content in my browser! You're the best! Telling everyone! Thanks for the rewarding experience! Very exciting promotion! Your skills always are rewarded! mostbet ru mostbet mostbet today mostbet Киргизия
mostbet Azərbaycan Hit the jackpot with us! Unlock your fortune! Play with ease on our licensed platform! Don't miss out on huge jackpots! Win big! Share the joy with friends! Grateful for your loyalty! Simply fantastic! Your efforts always result in victories! Eagerly awaiting your upcoming tournaments! Bookmarked your content in my browser! You're the best! Telling everyone! Thanks for the rewarding experience! Very exciting promotion! Your skills always are rewarded! mostbet ru mostbet mostbet today mostbet Киргизия
¡La fortuna te acompaña! No pierdas la oportunidad de disfrutar de apuestas seguros y entretenidas en 1Win. 1win
¡La fortuna te acompaña! No pierdas la oportunidad de disfrutar de apuestas seguros y entretenidas en 1Win. 1win
Discover Bet9ja: The Best Betting Experience in Nigeria!
bet9ja old mobile Looking for a simple betting experience? Access the Bet9ja Old Mobile version and experience fast loading times and easy navigation. Bet on soccer, casino games, and virtual races without the complexities of the new version. Start betting in minutes!
old bet9ja
Discover Bet9ja: The Best Betting Experience in Nigeria!
bet9ja old mobile Looking for a simple betting experience? Access the Bet9ja Old Mobile version and experience fast loading times and easy navigation. Bet on soccer, casino games, and virtual races without the complexities of the new version. Start betting in minutes!
old bet9ja
Pinco Casino'da eğlence sizi bekliyor! pinco
Pinco Casino'da hızla kayıt olabilirsiniz. Bonuslu oyunlar ve yüksek ödeme oranları ile oyun deneyiminizi zenginleştirin. pinco
Pinco Casino'da eğlence sizi bekliyor! pinco
Pinco Casino'da hızla kayıt olabilirsiniz. Bonuslu oyunlar ve yüksek ödeme oranları ile oyun deneyiminizi zenginleştirin. pinco
Exciting casino options await you at Pin-Up! At Pin-Up Casino, you'll find engaging slot games, table games, sports wagers, and much more. Play premium games from top providers like NetEnt and Microgaming, and take your chance for huge wins!
pin up casino india Maximizing the ?450000 Welcome Bonus at Pin-Up Casino. The Pin Up casino welcome offer of up to ?450000 is generous, but how can you take full advantage of it? Have you received this offer yet? Let us know your strategies and tips for transforming the bonus into huge payouts. Let’s talk about how to make the most out of your first top-up!
Exciting casino options await you at Pin-Up! At Pin-Up Casino, you'll find engaging slot games, table games, sports wagers, and much more. Play premium games from top providers like NetEnt and Microgaming, and take your chance for huge wins!
pin up casino india Maximizing the ?450000 Welcome Bonus at Pin-Up Casino. The Pin Up casino welcome offer of up to ?450000 is generous, but how can you take full advantage of it? Have you received this offer yet? Let us know your strategies and tips for transforming the bonus into huge payouts. Let’s talk about how to make the most out of your first top-up!
Use Taya365 bonuses for maximum victories taya365 app Uncover the world of online gaming with Taya365 and enjoy top-notch live games. Register today to receive huge rewards and bonuses! Taya365 and enjoy a world of adventure. Whether you're into sports betting, there's something to enjoy. Get started and win big! taya365 app download
Use Taya365 bonuses for maximum victories taya365 app Uncover the world of online gaming with Taya365 and enjoy top-notch live games.
Register today to receive huge rewards and bonuses! Taya365 and enjoy a world of adventure. Whether you're into sports betting, there's something to enjoy. Get started and win big! taya365 app download
دائماً أراهن في 1xbet Sports Betting Egypt – مضمون ومربح! أوصي به الآن! Online betting in Egypt
دائماً أراهن في 1xbet Sports Betting Egypt – مضمون ومربح!
أوصي به الآن! Online betting in Egypt
Mostbet জুয়া – বিশাল প্ল্যাটফর্ম ভার্চুয়াল গেমস জন্য। Mostbet BD
Mostbet জুয়া – বিশাল প্ল্যাটফর্ম ভার্চুয়াল গেমস জন্য। Mostbet BD
Онлайн казино Mostbet – кең ауқымды мүмкіндіктер ұсынады спорттық ставкалар сүйінушілеріне.
mostbet kazakhstan
Онлайн казино Mostbet – кең ауқымды мүмкіндіктер ұсынады спорттық ставкалар сүйінушілеріне. mostbet kazakhstan
На данном сайте всегда доступна актуальная ссылка на мега мориарти, которая обновляется регулярно, чтобы вы могли без проблем попасть на нужную платформу.
На данном сайте всегда доступна актуальная ссылка на мега мориарти, которая обновляется регулярно, чтобы вы могли без проблем попасть на нужную платформу.
why 1xbet is the best online casino site for UAE players Thank you for your openness and openness! �� 400 Bad Request
why 1xbet is the best online casino site for UAE players Thank you for your openness and openness! �� 400 Bad Request
دائماً أراهن في 1xbet مصر – مضمون ومثالي! جربه بنفسك الآن! 1xBet تسجيل
دائماً أراهن في 1xbet مصر – مضمون ومثالي! جربه بنفسك الآن! 1xBet تسجيل
جربت 1xbet Mobile App Egypt – يتميز بواجهة ممتازة، السحب دون مشاكل!
1xBet عروض ترويجية
جربت 1xbet Mobile App Egypt – يتميز بواجهة ممتازة، السحب دون مشاكل!
1xBet عروض ترويجية
هل تحتاج إلى أشهر شركة رهان؟ 1xbet شركة الرهان يقدم أقوى الفرص ودفعات سريعة! Jogar FortuneRabbit sempre foi tão simples.
هل تحتاج إلى أشهر شركة رهان؟ 1xbet شركة الرهان يقدم أقوى الفرص ودفعات سريعة!
Jogar FortuneRabbit sempre foi tão simples.
دائماً أشارك في 1xbet Sports Betting Egypt – مريح ومربح! أنصح به الآن! 1xBet in Egypt
دائماً أشارك في 1xbet Sports Betting Egypt – مريح ومربح! أنصح به الآن! 1xBet in Egypt
هل تبحث عن أقوى كازينو أونلاين؟ 1xbet Egypt يقدم أفضل العروض ودفعات سريعة! 1xBet تطبيق الجوال
هل تبحث عن أقوى كازينو أونلاين؟ 1xbet Egypt يقدم أفضل العروض ودفعات سريعة! 1xBet تطبيق الجوال
دائماً أراهن في 1xbet مصر – مريح ومثالي!
أنصح به الآن! Apostas em futebol
دائماً أراهن في 1xbet مصر – مريح ومثالي! أنصح به الآن! Apostas em futebol