


This article introduces in detail the process of installing and configuring the LAMP service in the CentOS6.4 system, that is, installing Apache+PHP+Mysql. It refers to the settings of online experts. Other Linux distribution systems can refer to it~
Some of the command operations in this article require root permissions. Enter the ‘’ command and then enter the password to switch the root identity.
Settings file allows port 80 and port 3306. Because port 80 is the port used by the http protocol, if the firewall blocks port 80, the website cannot be accessed from the outside even after it is configured. Port 3306 is the default port of the MySql database. Open the iptables file using VIM and add rules:
<span 1</span> <span 打开iptables文件进行修改 </span><span 2</span> vim /etc/sysconfig/<span iptables </span><span 3</span> <span 4</span> <span 加入下列两行 </span><span 5</span> -A INPUT -p tcp -m state --state NEW -m tcp --dport <span 80</span> -<span j ACCEPT </span><span 6</span> -A INPUT -p tcp -m state --state NEW -m tcp --dport <span 3306</span> -j ACCEPT
After adding, the file should be as shown below. If the file has been modified before, it may be slightly different from the author’s picture:
2. Close SELINUX
( provided in the 2.6 version of Linux )system. Of the security modules currently available, SELinux is the most comprehensive, and the most well-tested. Basically, load balancing equipment is used for traffic distribution, and only a few ports are opened to the outside world. Therefore, in terms of comprehensive security and complexity, SELinux is not cost-effective. Modify the file to turn off SELinux, as shown below:
<span 1</span> vim /etc/selinux/<span config </span><span 2</span> <span 3</span> <span 注释掉如下两行,在行首添加#注释。 </span><span 4</span> SELINUX=<span enforcing </span><span 5</span> SELINUXTYPE=<span targeted </span><span 6</span> <span 7</span> <span 在后面增加: </span><span 8</span> SELINUX=disabled
’ Restart the system.
<span 1</span> <span 通过yum软件包管理器安装MySql,管理器会自动安装依赖项,遇到询问直接输入y确认,直到显示“Complete!”完成。 </span><span 2</span> <span yum</span> <span install</span> mysql mysql-<span server </span><span 3</span> <span 4</span> <span 启动MySql </span><span 5</span> /etc/init.d/<span mysqld start </span><span 6</span> <span 7</span> <span 设置MySql服务为开机启动 </span><span 8</span> <span chkconfig mysqld on </span><span 9</span> <span 10</span> <span 复制MySql默认配置文件,直接覆盖/etc/my.cnf </span><span 11</span> <span cp</span> /usr/share/mysql/my-medium.cnf /etc/my.cnf
MySql settings:
<span <span 输入如下命令后需要连续输入两次密码确认,有询问输入Y同意即可,成功后显示</span></span><span Thanks for using MySQL!。</span>
<span mysql_secure_installation</span>
After successful setting, you need to restart the MySql service:
<span 1</span> /etc/init.d/<span mysqld stop </span><span 2</span> /etc/init.d/mysqld start
2. Installation and configuration of Apache service
<span 1</span> <span 安装httpd </span><span 2</span> <span yum</span> <span install</span><span httpd </span><span 3</span> <span 4</span> <span 启动Apache服务 </span><span 5</span> /etc/init.d/<span httpd start </span><span 6</span> <span 7</span> <span 编辑apache设置 </span><span 8</span> vim /etc/httpd/conf/<span httpd.conf </span><span 9</span> <span 查找 <span #ServerName www.example.com:80</span></span> <span 10</span> <span 修改成 <span ServerName</span> <span www.XXXX.com:80</span></span> <span 11</span> <span 其中的“www.XXXX.com”自己的域名,没有可设置为localhost,如图 </span><span 12</span> <span 13</span> <span 设置Apache服务开机启动 </span><span 14</span> <span chkconfig httpd on </span><span 15</span> <span 16</span> <span 重启Apache服务 </span><span 17</span> /etc/init.d/httpd restart
3. Install PHP
<span 遇到询问直接输y确认 </span><span yum</span> <span install</span> php
Install PHP plug-in:
<span 插件包括MySql支持等,遇到询问一如既往的y确认~~ </span><span yum</span> <span install</span> php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
Don’t forget to restart Apache and MySql after the installation is complete:
/etc/init.d/<span mysqld restart </span>/etc/init.d/httpd restart
The installation of this software is over. Next, configure and test.
<span 1</span> <span 编辑文件Apache设置文件 </span><span 2</span> <span vi</span> /etc/httpd/conf/<span httpd.conf </span><span 3</span> <span 4</span> <span <span 44行:</span> 修改 <span ServerTokens OS</span> 为 <span ServerTokens Prod </span></span><span 5</span> <span 防止错误页显示操作系统名字 </span><span 6</span> <span 7</span> <span <span 76行:</span> 修改 <span KeepAlive Off</span> 为 <span KeepAlive On </span></span><span 8</span> <span 允许程序性联机 </span><span 9</span> <span 10</span> <span 83行:</span> 修改 <span MaxKeepAliveRequests 100</span> 为 <span MaxKeepAliveRequests 1000</span> <span 11</span> <span 增加同时连接数 </span><span 12</span> <span 13</span> <span <span 331行:</span> 修改 <span Options Indexes FollowSymLinks</span> 为 <span Options Includes ExecCGI FollowSymLinks </span></span><span 14</span> <span 允许服务器执行CGI及SSI,防止列出目录 </span><span 15</span> <span 16</span> <span <span 338行:</span> 修改 <span AllowOverride None</span> 为 <span AllowOverride All </span></span><span 17</span> <span 允许.htaccess </span><span 18</span> <span 19</span> <span <span 402行:</span> 修改 <span DirectoryIndex index.html index.html.var</span> 为 <span DirectoryIndex index.php Default.php index.html index.htm Default.html Default.htm </span></span><span 20</span> <span 添加php默认文档 </span><span 21</span> <span 22</span> <span <span 536行:</span> 修改 <span ServerSignature On</span> 为 ServerSignature Off </span><span 23</span> <span 防止错误页显示Apache版本 </span><span 24</span> <span 25</span> <span <span 554行:</span> 修改 <span Options Indexes MultiViews FollowSymLinks</span> 为 <span Options MultiViews FollowSymLinks </span></span><span 26</span> <span 不显示树状目录结构 </span><span 27</span> <span 28</span> <span 759行:</span> 根据需要设置为 <span AddDefaultCharset UTF-8</span><span 或者 <span AddDefaultCharset GB2312 </span></span><span 29</span> <span 笔者大多数时候都在使用UTF-8编码,所以不进行修改 </span><span 30</span> <span 31</span> <span 796行:</span> 修改 <span #AddHandler cgi-script .cgi</span> 为 <span AddHandler cgi-script .cgi .pl </span><span 32</span> <span 允许扩展名为.pl的CGI脚本运行</span>
After the modification is completed, save, exit, restart Apache, and delete the test webpage:
/etc/init.d/<span httpd restart <span 删除测试网页 </span></span><span rm</span> -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html
<span 1</span> <span 编辑php设置文件 </span><span 2</span> vim /etc/<span php.ini </span><span 3</span> <span 4</span> <span 946行:</span> 修改 <span ;date.timezone = PRC</span> 为 <span date.timezone =</span><span <span PRC</span> <span (去掉分号) </span></span><span 5</span> <span 6</span> <span 386行:</span> 修改 <span disable_functions =</span> 为 <span disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname </span><span 7</span> <span 设置PHP的禁用函数,若程序中需要使用的函数可以删除掉。 </span><span 8</span> <span 9</span> <span 432行:</span> 设置 <span expose_php = Off </span><span 10</span> <span 禁止显示php版本的信息 </span><span 11</span> <span 12</span> <span 745行:</span> 设置 <span magic_quotes_gpc = On </span><span 13</span> <span 打开magic_quotes_gpc,用于防止SQL注入 </span><span 14</span> <span 15</span> <span 229行:</span> 设置 <span short_open_tag = ON </span><span 16</span> <span 支持php短标签 </span><span 17</span> <span 18</span> <span 380行:</span> 设置 <span open_basedir = .:/tmp/</span> <span 19</span> <span 设置允许访问的目录和/tmp/目录,防止php木马跨站</span>
Restart the service after saving the modification:
/etc/init.d/<span mysqld restart </span>/etc/init.d/httpd restart
Enter "
<span 1</span> <?<span php </span><span 2</span> <span phpinfo</span><span (); </span><span 3</span> ?>
After saving and exiting, enter localhost in the browser to view the php information:
apache.apache -R /var/www/html

Vue.js与ASP.NET的结合,实现Web应用的性能优化和扩展的技巧和建议随着Web应用的快速发展,性能优化成为开发者不可或缺的重要任务。Vue.js作为一款流行的前端框架,与ASP.NET的结合可以帮助我们实现更好的性能优化和扩展。本文将会介绍一些技巧和建议,并提供一些代码示例。一、减少HTTP请求HTTP请求的数量直接影响着Web应用的加载速度。通过

如何在ASP.NET程序中正确使用和优化MySQL连接池?引言:MySQL是一种广泛使用的数据库管理系统,它具有高性能、可靠性和易用性的特点。在ASP.NET开发中,使用MySQL数据库进行数据存储是常见的需求。为了提高数据库连接的效率和性能,我们需要正确地使用和优化MySQL连接池。本文将介绍在ASP.NET程序中如何正确使用和优化MySQL连接池的方法。

译者|陈峻审校|重楼上个世纪90年代,当人们提起软件编程时,通常意味着选择一个编辑器,将代码检入CVS或SVN代码库,然后将代码编译成可执行文件。与之对应的Eclipse和VisualStudio等集成开发环境(IDE)可以将编程、开发、文档、构建、测试、部署等步骤纳入到一个完整的软件开发生命周期(SDLC)中,从而提高了开发人员的工作效率。近年来,流行的云计算和DevSecOps自动化工具提升了开发者的综合能力,使得更多的企业能够更加轻松地开发、部署和维护软件应用。如今,生成式AI作为下一代开

如何在ASP.NET程序中重连MySQL连接?在ASP.NET开发中,使用MySQL数据库是非常常见的。然而,由于网络或数据库服务器的原因,有时会导致数据库连接中断或超时。在这种情况下,为了保证程序的稳定性和可靠性,我们需要在连接断开后重新建立连接。本文将介绍如何在ASP.NET程序中实现重连MySQL连接的方法。引用必要的命名空间首先,在代码文件的头部引用

Vue.js与ASP.NET的结合,实现企业级应用的开发和部署在当今快速发展的互联网技术领域,企业级应用的开发和部署变得越来越重要。Vue.js和ASP.NET是两个在前端和后端开发中广泛使用的技术,将它们结合起来可以为企业级应用的开发和部署带来诸多优势。本文将通过代码示例介绍如何使用Vue.js和ASP.NET进行企业级应用的开发和部署。首先,我们需要安装

如何在ASP.NET程序中正确配置和使用MySQL连接池?随着互联网的发展和数据量的增大,对数据库的访问和连接需求也在不断增加。为了提高数据库的性能和稳定性,连接池成为了一个必不可少的技术。本文主要介绍如何在ASP.NET程序中正确配置和使用MySQL连接池,以提高数据库的效率和响应速度。一、连接池的概念和作用连接池是一种重复使用数据库连接的技术,在程序初始

ASP.NET中的内置对象有“Request”、“Response”、“Session”、“Server”、“Application”、 “HttpContext”、“Cache”、“Trace”、“Cookie”和“Server.MapPath”:1、Request,表示客户端发出的HTTP请求;2、Response:表示Web服务器返回给客户端的HTTP响应等等。

在Linux上使用VisualStudio进行ASP.NET开发的推荐配置概述:随着开源软件的发展和Linux操作系统的普及,越来越多的开发者开始在Linux上进行ASP.NET开发。而作为一款功能强大的开发工具,VisualStudio在Windows平台上一直占据着主导地位。本文将介绍如何在Linux上配置VisualStudio来进行ASP.NE


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools
