2022年CentOS.安装配置LAMP服务 .pdf

上传人:Che****ry 文档编号:27252770 上传时间:2022-07-23 格式:PDF 页数:4 大小:39.14KB
返回 下载 相关 举报
2022年CentOS.安装配置LAMP服务 .pdf_第1页
第1页 / 共4页
2022年CentOS.安装配置LAMP服务 .pdf_第2页
第2页 / 共4页
点击查看更多>>
资源描述

《2022年CentOS.安装配置LAMP服务 .pdf》由会员分享,可在线阅读,更多相关《2022年CentOS.安装配置LAMP服务 .pdf(4页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、CentOS 6.1 安装配置 LAMP 服务器 (Apache+PHP5+MySQL)准备篇:1、配置防火墙,开启80 端口、 3306端口 vi /etc/sysconfig/iptables -A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT(允许 80 端口通过防火墙) -A INPUT -m state -state NEW -m tcp -p tcp -dport 3306 -j ACCEPT(允许 3306 端口通过防火墙) /etc/init.d/iptables restart #重启防火墙使配置生效2

2、、关闭 SELINUX vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq 保存,关闭 shutdown -r now #重启系统安装篇:一、安装 Apache1、检查是否已安装Apache rpm -qa|grep httpd httpd-tools-2.2.15-9.el6.centos.i686 httpd-2.2.15-9.el6.centos.i686 如果看到上面的信息,说明系统已经安装了Apache 2、安装 Apache yum in

3、stall httpd 根据提示,输入 Y安装即可成功安装 /etc/init.d/httpd start #启动 Apache chkconfig httpd on #设为开机启动 /etc/init.d/httpd restart #重启 Apache 备注: Apache启动之后会提示错误:正在启动 httpd:httpd: Could not reliably determine the servers fully qualif domain name, using :1 for ServerName 解决办法: vi /etc/httpd/conf/httpd.conf #编辑找到

4、#ServerName :80修改为 ServerName localhost:80 :wq! #保存退出二、安装 MySQL1、检查是否已安装MySQL rpm -qa|grep mysql 2、安装 MySQL yum install mysql mysql-server 询问是否要安装,输入Y即可自动安装 , 直到安装完成。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 4 页 - - - - - - - - - /etc/init.d/mysqld start #

5、启动 MySQL chkconfig mysqld on #设为开机启动 cp /usr/share/mysql/my-f /etc/f #拷贝配置文件(注意:如果 /etc 目录下面默认有一个f ,直接覆盖即可) 3 、为 root 账户设置密码 mysql_secure_installation 根据提示输入 Y,回车输入 2 次密码,回车最后出现: Thanks for using MySQL! MySql密码设置完成重新正常启动 MySQL : /etc/init.d/mysqld stop #停止 /etc/init.d/mysqld start #启动 /etc/init.d/my

6、sqld restart #重启三、安装 PHP5 1、检查是否已安装PHP5 rpm -q php 出现 package php is not installed 说明系统没有安装PHP5 2、安装 PHP5 yum install php 根据提示输入 Y直到安装完成3、安装 PHP组件,使 PHP5 支持 MySQL yum install 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

7、 libmcrypt 这里选择以上安装包进行安装根据提示输入 Y回车 /etc/init.d/mysqld restart #重启 MySql /etc/init.d/httpd restart #重启 Apche 配置篇一、Apache配置vi /etc/httpd/conf/httpd.conf 编辑文件ServerTokens OS 在 44 行修改为: ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称) ServerSignature On 在 536 行 修改为: ServerSignature Off (在错误页中不显示 Apache的版本) Op

8、tions Indexes FollowSymLinks 在 331 行 修改为: Options Includes ExecCGI FollowSymLinks (允许服务器执行CGI及 SSI,禁止列出目录) #AddHandler cgi-script .cgi 在 796 行 修改为: AddHandler cgi-script .cgi .pl (允许扩展名为 .pl 的 CGI脚本运行) AllowOverride None 在 338 行 修改为: AllowOverride All (允许.htaccess )名师资料总结 - - -精品资料欢迎下载 - - - - - - -

9、 - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 4 页 - - - - - - - - - AddDefaultCharset UTF-8 在 759 行 修改为: AddDefaultCharset GB2312 (添加 GB2312为默认编码) Options Indexes MultiViews FollowSymLinks 在 554 行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构) DirectoryIndex index.html index.html.var 在

10、402 行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php ) KeepAlive Off 在 76 行 修改为: KeepAlive On (允许程序性联机) MaxKeepAliveRequests 100 在 83 行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数):wq! #保存退出 /etc/init.d/httpd restart 重启 rm -f /e

11、tc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页二、php配置vi /etc/php.ini #编辑date.timezone = PRC #在 946行 把前面的分号去掉,改为date.timezone = PRC disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,sy

12、slog,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

13、,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_t

14、tyname,posix_uname #在 386 行 列出 PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 expose_php = Off #在 432 行 禁止显示 php 版本的信息 magic_quotes_gpc = On #在 745 行 打开 magic_quotes_gpc 来防止 SQL注入 log_errors = On #记录错误日志 open_basedir = .:/tmp/ #在 380 行 设置表示允许访问当前目录(即 PHP脚本文件所在之目录 )和/tmp/ 目录, 可以防止 php 木马跨站:wq! #保存退出/etc/init.d

15、/mysqld restart #重启 MySql /etc/init.d/httpd restart #重启 Apche 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 4 页 - - - - - - - - - 测试篇cd /var/www/html index.php #输入下面内容 :wq! 在客户端浏览器输入服务器IP 地址,可以看到相关的配置信息!注意: apache 默认的程序目录是 /var/www/html权限设置: chown apache.apache -R /var/www/html名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 4 页 - - - - - - - - -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com