一些配置心得和总结!!

时间:2022-08-11 16:43:17
  在公司实习了一个多月了,让我印象最深刻的不是编程、不是代码框架而是我一直抵触的软件的安装、配置、系统命令……
   由于公司需要搭建的环境是没有网络的支持,所以我都在和源码包、依赖包、配置文件打交道  一些配置心得和总结!!
   一、apache 的安装和配置
  安装: 
  1、首先下载httpd-2.5.*.tar.gz
   2、使用 tar -zxvf 进行解压缩
   3、进入解压的目录,使用命令
    ./configure  --prefix = 默认的安装路径 
    # make 
    # make install
   4、安装过程中可能出现的问题---一般不会有问题
   1>checking for C compiler default output file name ……;error:C compiler cannot create 
executables 
     解决办法:安装 build-essential 
   2>configure : error :APR not found . please read documentation
     解决办法:安装apr和apt-util 
      5>重新执行 3 的命令
  配置:
     通过上面的命令,将apache2成功安装。现在开始对 apache 进行配置
     打开      apache 的安装路径/conf/httpd.conf
     1、要求 : 搭建 cgi 的编译环境
     2、需求 :创建一个虚拟域名 
     3、对于配置文件修改的部分进行标记和解释
  1. #
  2. ServerRoot "/usr/local/apache2"
  3. #
  4. # Listen: Allows you to bind Apache to specific IP addresses and/or
  5. # ports, instead of the default. See also the <VirtualHost>
  6. # directive.
  7. #
  8. # Change this to Listen on specific IP addresses as shown below to
  9. # prevent Apache from glomming onto all bound IP addresses.
  10. #
  11. #Listen 12.34.56.78:80
  12. Listen 80
  13. #
  14. # Dynamic Shared Object (DSO) Support
  15. #
  16. # To be able to use the functionality of a module which was built as a DSO you
  17. # have to place corresponding `LoadModule' lines at this location so the
  18. # directives contained in it are actually available _before_ they are used.
  19. # Statically compiled modules (those listed by `httpd -l') do not need
  20. # to be loaded here.
  21. #
  22. # Example:
  23. # LoadModule foo_module modules/mod_foo.so
  24. #
  25. <IfModule !mpm_netware_module>
  26. #
  27. # If you wish httpd to run as a different user or group, you must run
  28. # httpd as root initially and it will switch.
  29. #
  30. # User/Group: The name (or #number) of the user/group to run httpd as.
  31. # It is usually good practice to create a dedicated user and group for
  32. # running httpd, as with most system services.
  33. #
  34. User daemon
  35. Group daemon
  36. </IfModule>

  37. # 'Main' server configuration
  38. #
  39. # The directives in this section set up the values used by the 'main'
  40. # server, which responds to any requests that aren't handled by a
  41. # <VirtualHost> definition. These values also provide defaults for
  42. # any <VirtualHost> containers you may define later in the file.
  43. #
  44. # All of these directives may appear inside <VirtualHost> containers,
  45. # in which case these default settings will be overridden for the
  46. # virtual host being defined.
  47. #

  48. #
  49. # ServerAdmin: Your address, where problems with the server should be
  50. # e-mailed. This address appears on some server-generated pages, such
  51. # as error documents. e.g. admin@your-domain.com
  52. #
  53. ServerAdmin you@example.com

  54. #
  55. # ServerName gives the name and port that the server uses to identify itself.
  56. # This can often be determined automatically, but we recommend you specify
  57. # it explicitly to prevent problems during startup.
  58. #
  59. # If your host doesn't have a registered DNS name, enter its IP address here.
  60. #
  61. #ServerName www.example.com:80

  62. #
  63. # DocumentRoot: The directory out of which you will serve your
  64. # documents. By default, all requests are taken from this directory, but
  65. # symbolic links and aliases may be used to point to other locations.
  66. #
  67. DocumentRoot "/usr/local/apache2/htdocs"

  68. #
  69. # Each directory to which Apache has access can be configured with respect
  70. # to which services and features are allowed and/or disabled in that
  71. # directory (and its subdirectories).
  72. #
  73. # First, we configure the "default" to be a very restrictive set of
  74. # features.
  75. #
  76. <Directory />
  77. Options FollowSymLinks
  78. AllowOverride None
  79. Order deny,allow
  80. Deny from all
  81. </Directory>

  82. #
  83. # Note that from this point forward you must specifically allow
  84. # particular features to be enabled - so if something's not working as
  85. # you might expect, make sure that you have specifically enabled it
  86. # below.
  87. #

  88. #
  89. # This should be changed to whatever you set DocumentRoot to.
  90. #
  91. <Directory "/usr/local/apache2/htdocs">
  92. #
  93. # Possible values for the Options directive are "None", "All",
  94. # or any combination of:
  95. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  96. #
  97. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  98. # doesn't give it to you.
  99. #
  100. # The Options directive is both complicated and important. Please see
  101. # http://httpd.apache.org/docs/2.2/mod/core.html#options
  102. # for more information.
  103. #
  104. Options Indexes FollowSymLinks

  105. #
  106. # AllowOverride controls what directives may be placed in .htaccess files.
  107. # It can be "All", "None", or any combination of the keywords:
  108. # Options FileInfo AuthConfig Limit
  109. #
  110. AllowOverride None

  111. #
  112. # Controls who can get stuff from this server.
  113. #
  114. Order allow,deny
  115. Allow from all

  116. </Directory>

  117. #
  118. # DirectoryIndex: sets the file that Apache will serve if a directory
  119. # is requested.
  120. #
  121. <IfModule dir_module>
  122. DirectoryIndex index.html
  123. </IfModule>

  124. #
  125. # The following lines prevent .htaccess and .htpasswd files from being
  126. # viewed by Web clients.
  127. #
  128. <FilesMatch "^\.ht">
  129. Order allow,deny
  130. Deny from all
  131. Satisfy All
  132. </FilesMatch>

  133. #
  134. # ErrorLog: The location of the error log file.
  135. # If you do not specify an ErrorLog directive within a <VirtualHost>
  136. # container, error messages relating to that virtual host will be
  137. # logged here. If you *do* define an error logfile for a <VirtualHost>
  138. # container, that host's errors will be logged there and not here.
  139. #
  140. ErrorLog logs/error_log

  141. #
  142. # LogLevel: Control the number of messages logged to the error_log.
  143. # Possible values include: debug, info, notice, warn, error, crit,
  144. # alert, emerg.
  145. #
  146. LogLevel warn

  147. <IfModule log_config_module>
  148. #
  149. # The following directives define some format nicknames for use with
  150. # a CustomLog directive (see below).
  151. #
  152. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  153. LogFormat "%h %l %u %t \"%r\" %>s %b" common

  154. <IfModule logio_module>
  155. # You need to enable mod_logio.c to use %I and %O
  156. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  157. </IfModule>

  158. #
  159. # The location and format of the access logfile (Common Logfile Format).
  160. # If you do not define any access logfiles within a <VirtualHost>
  161. # container, they will be logged here. Contrariwise, if you *do*
  162. # define per-<VirtualHost> access logfiles, transactions will be
  163. # logged therein and *not* in this file.
  164. #
  165. CustomLog logs/access_log common

  166. #
  167. # If you prefer a logfile with access, agent, and referer information
  168. # (Combined Logfile Format) you can use the following directive.
  169. #
  170. #CustomLog logs/access_log combined
  171. </IfModule>

  172. <IfModule alias_module>
  173. #
  174. # Redirect: Allows you to tell clients about documents that used to
  175. # exist in your server's namespace, but do not anymore. The client
  176. # will make a new request for the document at its new location.
  177. # Example:
  178. # Redirect permanent /foo http://www.example.com/bar

  179. #
  180. # Alias: Maps web paths into filesystem paths and is used to
  181. # access content that does not live under the DocumentRoot.
  182. # Example:
  183. # Alias /webpath /full/filesystem/path
  184. #
  185. # If you include a trailing / on /webpath then the server will
  186. # require it to be present in the URL. You will also likely
  187. # need to provide a <Directory> section to allow access to
  188. # the filesystem path.

  189. #
  190. # ScriptAlias: This controls which directories contain server scripts.
  191. # ScriptAliases are essentially the same as Aliases, except that
  192. # documents in the target directory are treated as applications and
  193. # run by the server when requested rather than as documents sent to the
  194. # client. The same rules about trailing "/" apply to ScriptAlias
  195. # directives as to Alias.
  196. #
  197. ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
  198. # 一种映射,如何遇到 cgi-bin 则用 usr/local/apache2/cgi-bin 替换
  199. </IfModule>

  200. <IfModule cgid_module>
  201. #
  202. # ScriptSock: On threaded servers, designate the path to the UNIX
  203. # socket used to communicate with the CGI daemon of mod_cgid.
  204. #
  205. #Scriptsock logs/cgisock
  206. </IfModule>

  207. #
  208. # "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased
  209. # CGI directory exists, if you have that configured.
  210. #
  211. <Directory "/usr/local/apache2/cgi-bin">
  212. AllowOverride all
  213. Options all
  214. Order allow,deny
  215. Allow from all
  216. </Directory>

  217. #
  218. # DefaultType: the default MIME type the server will use for a document
  219. # if it cannot otherwise determine one, such as from filename extensions.
  220. # If your server contains mostly text or HTML documents, "text/plain" is
  221. # a good value. If most of your content is binary, such as applications
  222. # or images, you may want to use "application/octet-stream" instead to
  223. # keep browsers from trying to display binary files as though they are
  224. # text.
  225. #
  226. DefaultType text/plain

  227. <IfModule mime_module>
  228. #
  229. # TypesConfig points to the file containing the list of mappings from
  230. # filename extension to MIME-type.
  231. #
  232. TypesConfig conf/mime.types

  233. #
  234. # AddType allows you to add to or override the MIME configuration
  235. # file specified in TypesConfig for specific file types.
  236. #
  237. #AddType application/x-gzip .tgz
  238. #
  239. # AddEncoding allows you to have certain browsers uncompress
  240. # information on the fly. Note: Not all browsers support this.
  241. #
  242. #AddEncoding x-compress .Z
  243. #AddEncoding x-gzip .gz .tgz
  244. #
  245. # If the AddEncoding directives above are commented-out, then you
  246. # probably should define those extensions to indicate media types:
  247. #
  248. AddType application/x-compress .Z
  249. AddType application/x-gzip .gz .tgz

  250. #
  251. # AddHandler allows you to map certain file extensions to "handlers":
  252. # actions unrelatgged to filetype. These can be either built into the server
  253. # or added with the Action directive (see below)
  254. #
  255. # To use CGI scripts outside of ScriptAliased directories:
  256. # (You will also need to add "ExecCGI" to the "Options" directive.)
  257. #
  258. AddHandler cgi-script .cgi .pl .pl

  259. # For type maps (negotiated resources):
  260. #AddHandler type-map var

  261. #
  262. # Filters allow you to process content before it is sent to the client.
  263. #
  264. # To parse .shtml files for server-side includes (SSI):
  265. # (You will also need to add "Includes" to the "Options" directive.)
  266. #
  267. #AddType text/html .shtml
  268. #AddOutputFilter INCLUDES .shtml
  269. </IfModule>

  270. #
  271. # The mod_mime_magic module allows the server to use various hints from the
  272. # contents of the file itself to determine its type. The MIMEMagicFile
  273. # directive tells the module where the hint definitions are located.
  274. #
  275. #MIMEMagicFile conf/magic

  276. #
  277. # Customizable error responses come in three flavors:
  278. # 1) plain text 2) local redirects 3) external redirects
  279. #
  280. # Some examples:
  281. #ErrorDocument 500 "The server made a boo boo."
  282. #ErrorDocument 404 /missing.html
  283. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  284. #ErrorDocument 402 http://www.example.com/subscription_info.html
  285. #

  286. #
  287. # EnableMMAP and EnableSendfile: On systems that support it,
  288. # memory-mapping or the sendfile syscall is used to deliver
  289. # files. This usually improves server performance, but must
  290. # be turned off when serving from networked-mounted
  291. # filesystems or if support for these functions is otherwise
  292. # broken on your system.
  293. #
  294. #EnableMMAP off
  295. #EnableSendfile off

  296. # Supplemental configuration
  297. #
  298. # The configuration files in the conf/extra/ directory can be
  299. # included to add extra features or to modify the default configuration of
  300. # the server, or you may simply copy their contents here and change as
  301. # necessary.

  302. # Server-pool management (MPM specific)
  303. #Include conf/extra/httpd-mpm.conf

  304. # Multi-language error messages
  305. #Include conf/extra/httpd-multilang-errordoc.conf

  306. # Fancy directory listings
  307. #Include conf/extra/httpd-autoindex.conf

  308. # Language settings
  309. #Include conf/extra/httpd-languages.conf

  310. # User home directories
  311. #Include conf/extra/httpd-userdir.conf

  312. # Real-time info on requests and configuration
  313. #Include conf/extra/httpd-info.conf

  314. # Virtual hosts
  315. #Include conf/extra/httpd-vhosts.conf

  316. # Local access to the Apache HTTP Server Manual
  317. #Include conf/extra/httpd-manual.conf

  318. # Distributed authoring and versioning (WebDAV)
  319. #Include conf/extra/httpd-dav.conf

  320. # Various default settings
  321. #Include conf/extra/httpd-default.conf

  322. # Secure (SSL/TLS) connections
  323. #Include conf/extra/httpd-ssl.conf
  324. #
  325. # Note: The following must must be present to support
  326. # starting without SSL on platforms with no /dev/random equivalent
  327. # but a statically compiled-in mod_ssl.
  328. #
  329. #这是虚拟域名
  330. NameVirtualHost 127.0.0.1  # 说明虚拟主机的IP 和监听端口 
  331. <VirtualHost 127.0.0.1>    # 在 VirtualHost  后面的IP必须和上面一致
  332. ServerName www.glinuxi.com # 虚拟域名
  333. ServerAdmin 1162601897@qq.com #  管理员的邮箱
  334. DocumentRoot /home/gaoyi/gaoyi/WEB/htdocs/ # 虚拟主机的文档目录
  335. <Directory />
  336. Options FollowSymLinks
  337. AllowOverride None
  338. </Directory>
  339. <Directory /home/gaoyi/gaoyi/WEB/htdocs> 
  340. Options Indexes FollowSymLinks MultiViews
  341. AllowOverride None
  342. Order allow,deny
  343. allow from all
  344. # This directive allows us to have apache2's default start page
  345. # in /apache2-default/, but still have / go to the right place
  346. # Commented out for Ubuntu
  347. #RedirectMatch ^/$ /apache2-default/
  348. </Directory>
  349. ScriptAlias /cgi-bin/ /home/gaoyi/gaoyi/WEB/cgi-bin/ # 映射相应用户的cgi路径
  350. <Directory "/home/gaoyi/gaoyi/WEB/cgi-bin">
  351. AllowOverride Options
  352. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch  #执行权限
  353. Order allow,deny
  354. Allow from all 
  355. </Directory>
  356. ErrorLog / home/gaoyi/gaoyi/WEB/errorlogs/error.log 
  357. # Possible values include: debug, info, notice, warn, error, crit,
  358. # alert, emerg.
  359. LogLevel warn
  360. CustomLog /home/gaoyi/gaoyi/WEB/errorlogs/access.log combined
  361. ServerSignature On
  362. Alias /doc/ "/home/gaoyi/gaoyi/WEB/htdocs/doc/"
  363. <Directory "/home/gaoyi/gaoyi/WEB/htdocs/doc/">
  364. Options Indexes MultiViews FollowSymLinks
  365. AllowOverride None
  366. Order deny,allow
  367. Deny from all
  368. Allow from 127.0.0.0/255.0.0.0 ::1/128
  369. </Directory>
  370. </VirtualHost>

  371. <IfModule ssl_module>
  372. SSLRandomSeed startup builtin
  373. SSLRandomSeed connect builtin
  374. </IfModule>
切记:要重新启动 apache ,配置文件才能生效 
      ./apachectl  -k restart

在浏览器输入: http://www.glinuxi.com/html文件 即可
二 、mysql 的源码安装
  1、下载mysql的源码包。此时需要考虑到他与gcc 的兼容
  2、使用 tar -zxvf 进行解压缩
  4、安装成功后,开始对mysql 启动
   sudo -i
   ps aux|grep mysql 
   kill pid(mysql)
   cd   /usr/local/mysql/bin
   ./mysql_install_db --user=mysql
   ./mysqld_safe  --user=mysql&
   ./mysql -u  root -p