#1. mysql安装 ``` shell # tar xvfz mysql-5.0.24.tar.gz (直接解压) # cd mysql-5.0.24 (进入解压缩后的文件目录) ./configure --prefix=/usr/local/mysql --enable-thread-safe-client --with-named-curses-libs=/usr/lib/libncursesw.so.5 # ./configure --prefix=/usr/local/mysql --enable-thread-safe-client (配置编译参数,--prefix=设定安装的目录路径 //设定安装目录 //编译线程安全版的客户端库 如果报错 checking for tgetent in -ltermcap... no checking for termcap functions library... configure: error: No curses/termcap library found 加上 --with-named-curses-libs=/usr/lib/libncursesw.so.5 # make (等配置完成,开始编译) # make install (安装) # /usr/local/mysql/bin/mysql_install_db (初始化授权) # chown -R root:root /usr/local/mysql (文件属性改为root用户) # cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf (复制配置文件) ----------------------------------启动MySQL服务---------------------------------- # /usr/local/mysql/bin/mysqld_safe --user=root & ----------------------------------修改MySQL密码---------------------------------- # /usr/local/mysql/bin/mysqladmin -uroot password gameabcd@gameabce mysqlsecret ----------------------------------关闭MySQL服务---------------------------------- # /usr/local/mysql/bin/mysqladmin -uroot -pmysqlsecret shutdown GRANT ALL PRIVILEGES ON *.* TO root@“127.0.0.1" IDENTIFIED BY ‘123456' WITH GRANT OPTION; FLUSH privileges; ``` # 安装apache2 ```shell tar -xvzf httpd-2.2.8.tar.gz cd /usr/local/src/httpd-2.2.8 ./configure -prefix=/usr/local/apache -enable-file-cache -enable-cache -enable-deflate -enable-mime-magic -enable-expires -enable-headers -enable-version -enable-ssl -enable-http -enable-cgi -enable-rewrite -enable-so make make install ``` # 安装fcgi库 ```shell cd /usr/local/src tar -xvzf fcgi-2.4.0.tar.gz cd fcgi-2.4.0 ./configure -prefix=/usr/local/fcgi-2.4.0 make make install 安装fcgi模块,并加入到apache模块中 cd /usr/local/src tar -xvzf mod_fastcgi-2.4.6.tar.gz cd mod_fastcgi-2.4.6 cp Makefile.AP2 Makefile make top_dir=/usr/local/apache make install top_dir=/usr/local/apache 安装GD库(让PHP支持GIF,PNG,JPEG) 首先下载 jpeg6,libpng,freetype 并安装模块 wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz wget http://keihanna.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.gz wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz ``` # 安装 jpeg6 建立目录 ``` shell # mkdir /usr/local/jpeg6 # mkdir /usr/local/jpeg6/bin # mkdir /usr/local/jpeg6/lib # mkdir /usr/local/jpeg6/include # mkdir /usr/local/jpeg6/man # mkdir /usr/local/jpeg6/man/man1 # cd /root/soft # tar -zxf jpegsrc.v6b.tar.gz # cd jpeg-6b # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static (如发生checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized这个错误,将/usr/share/libtool/config.guess,/usr/share/libtool/config.sub覆盖现有目录的两个文件) # make (如发生错误make: *** [jconfig.h] Error 1,打开Makefile文件,将“jconfig.h: jconfig.doc echo You must prepare a system-dependent jconfig.h file. echo Please read the installation directions in install.doc. exit 1”这几行注释掉) #make install ``` # 安装libpng ``` shell # cd /root/soft # tar -zxf libpng-1.2.8.tar.gz # cd libpng-1.2.8 # cp scripts/makefile.std makefile # make; make install ``` #安装 freetype ```shell # cd /root/soft # tar -zxf freetype-2.1.10.tar.gz # cd freetype-2.1.10 # ./configure --prefix=/usr/local/freetype # make;make install ``` # 安装最新的GD库 ```shell # cd /root/soft # tar -zxf gd-2.0.33.tar.gz # cd gd-2.0.33 # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/ # make; make install ``` # 安装最新的Curl库 ```shell # cd /root/soft # wget http://curl.haxx.se/download/curl-7.15.0.tar.gz # tar -zxf curl-7.15.0.tar.gz # ./configure --prefix=/usr/local/curl # make; make install 由于php5需libxml2的支持, 所以先下载并安装libxml2 # cd /root/soft # wget http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.19.tar.gz # tar -zxf libxml2-2.6.19.tar.gz # cd libxml2-2.6.19 # ./configure --prefix=/usr/local/libxml2 # make; make install ``` # 安装 libxslt ```shell # cd /root/soft # wget http://ftp.gnome.org/pub/GNOME/sources/libxslt/1.1/libxslt-1.1.15.tar.gz # tar -zxf libxslt-1.1.15.tar.gz # cd libxslt-1.1.15 # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2 # make; make install ``` #安装 libevent ```shell # wget http://www.monkey.org/~provos/libevent-1.4.7-stable.tar.gz # tar -zxvf libevent-1.4.7-stable.tar.gz # cd libevent-1.4.7-stable # ./configure --prefix=/usr/local/libevent-1.4.7 # make;make install ``` #安装 memcached (这个要指定libevent的安装目录) ```shell # wget http://www.danga.com/memcached/dist/memcached-1.3.0.tar.gz # tar -zxvf memcached-1.3.0.tar.gz # cd memcached-1.3.0 # ./configure --with-libevent=/usr/local/libevent-1.4.7 # make;make install 启动memcached服务 # /usr/local/bin/memcached -d -m 10 -u root -p 11211 "-m:分配内存,MB为单位 -u:以哪个用户运行 -p:监听端口 ``` #安装php ```shell tar -xvzf php-5.2.4.tar.gz ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2 --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-sockets make make install ``` #安装 php memcache库 ```shell # cd /usr/local/src # wget http://pecl.php.net/get/memcache-2.2.3.tgz # tar -zxvf memcache-2.2.3.tgz # cd memcache-2.2.3 # /usr/local/bin/phpize # ./configure –enable-memcache –with-php-config=/usr/local/bin/php-config –with-zlib-dir # make; make install # 装完后会显示一段路径,如 Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ # vi vi /usr/local/php/lib/php.ini 找到 extension_dir = "./" 改成 extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/" 顺便加入一行:extension = memcache.so #重启apache服务 ``` # 配置apache ```shell vi /usr/local/apache/conf/httpd.conf 加入: AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps LoadModule fastcgi_module modules/mod_fastcgi.so <Directory "/usr/local/apache/htdocs/fast-cgi"> Options ExecCGI AddHandler fastcgi-script .fcg </Directory> # Start a "static" server at httpd initialization inside the scope of the SetHandler FastCgiServer /usr/local/apache/htdocs/fast-cgi/market_buy -processes 5 # Start a "static" server at httpd initialization inside the scope of the AddHandler FastCgiServer /usr/local/apache/htdocs/fast-cgi/store_client.fcg ``` #创建一个fast-cgi程序 > 创建一个fastcgi程序store_client,放在/usr/local/apache/htdocs/fast-cgi/ > 创建一个fastcgi程序store_client.fcg,放在/usr/local/apache/htdocs/fast-cgi/ # fastcgi的例子: ```c++ #include <fcgi_stdio.h> #include <fcgi_config.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <sys/types.h> #include <sys/param.h> extern char **environ; // g++ -lfcgi++ -o store_client.fcg test.cpp //-----functions define------------ static void PrintEnv(char *label, char **envp) { printf("%s:<br>\n<pre>\n", label); for ( ; *envp != NULL; envp++) { printf("%s\n", *envp); } printf("</pre><p>\n"); } //----------main------------------ main(void) { char **initialEnv = environ; int count = 0; while(FCGI_Accept() >= 0) { char *contentLength = getenv("CONTENT_LENGTH"); int len; printf("Content-type: text/html\r\n" "\r\n" "<title>FastCGI echo</title>" "<h1>FastCGI echo</h1>\n" "Request number [%d], Process ID: %d<p>\n", ++count, getpid()); }// while FCGI_Finish(); return(0); } // main() ``` # 一些常用的命令 检查apache 配置是否正确 ```shell /usr/local/app/apache2/bin/apachectl configtest ``` 启动apache ```shell /usr/local/app/apache2/bin/apachectl graceful ``` 配置文件目录: ``` shell /usr/local/app/apache2/conf/ ``` 安装Google CTemplate ```shell #cd /usr/local/src #wget http://google-ctemplate.googlecode.com/files/ctemplate-0.91.tar.gz #tar -zxvf ctemplate-0.91.tar.gz #cd ctemplate-0.91 #./configure --prefix=/usr/local/ctemplate-0.91 #make;make install ``` ## Google CTemplate例子 ``` Template file example.tpl Hello {{NAME}}, You have just won ${{VALUE}}! {{#IN_CA}}Well, ${{TAXED_VALUE}}, after taxes.{{/IN_CA}} C++ program example.cpp #include <stdlib.h> #include <string> #include <iostream> #include <google/template.h> int main(int argc, char** argv) { google::TemplateDictionary dict("example"); dict.SetValue("NAME", "John Smith"); int winnings = random() % 100000; dict.SetIntValue("VALUE", winnings); dict.SetFormattedValue("TAXED_VALUE", "%.2f", winnings * 0.83); // For now, assume everyone lives in CA. // (Try running the program with a 0 here instead!) if (1) { dict.ShowSection("IN_CA"); } google::Template* tpl = google::Template::GetTemplate("example.tpl", google::DO_NOT_STRIP); std::string output; tpl->Expand(&output, &dict); std::cout << output; return 0; } ``` Cocos Creator3文本模糊优化方案 javascript面试题
No Leanote account? Sign up now.