fgew2 发表于 2015-4-17 10:55:01

CentOS6.6 部署LAMP系统架构

#部署LAMP环境
#系统环境:
OS:CentOS release 6.6
HostName:server.example.com
IP:192.168.1.100


1
2
3
4
5
6
7
8
#配置防火墙,允许80,3306端口
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
service iptables save
#配置SELinux
vim /etc/sysconfig/selinux
SELINUX=permissive
setenforce 0





1
2
3
4
#安装Apache
yum -y install httpd
service httpd start
chkconfig httpd on





1
2
3
4
5
6
7
#安装MySQL
yum -y install mysql mysql-server
service mysqld start
chkconfig mysqld on
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
mysql_secure_installation               #回车,根据提示输入Y,输入2次密码,设置MySQL密码,回车根据提示一路输入Y最后出现:Thanks for using MySQL!
service mysqld restart   





1
2
3
4
#安装PHP
yum -y install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc
service mysqld restart                                    
service httpd restart





1
2
3
4
5
6
7
8
9
10
11
12
13
#配置Apache服务
vim /etc/httpd/conf/httpd.conf
ServerTokens OS                                        #44行修改为:ServerTokens Prod(出现错误页不显示操作系统名称)
ServerSignature On                                 #536行修改为:ServerSignature Off (错误页中不显示Apache的版本)
Options 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)
AddDefaultCharset UTF-8                                    #759行 修改为:AddDefaultCharset GB2312(添加GB2312为默认编码)
Options Indexes MultiViews FollowSymLinks                        #554行修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var                      #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 (增加同时连接数)
service httpd restart





1
2
3
4
5
6
7
8
9
10
11
12
13
14
#配置PHP服务
vim /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,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         #386行列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用
expose_php = Off                                  #438行禁止显示php版本的信息
magic_quotes_gpc = On                                    #751行打开magic_quotes_gpc来防止SQL注入
short_open_tag = ON                                 #229行支持php短标签
open_basedir = .:/tmp/                                  #380行设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨





1
2
3
#重启服务
service mysqld restart
service httpd restart





1
2
3
4
5
#写测试页面
vim /var/www/html/index.php
<?php
phpinfo();
?>





1
#在浏览器地址栏输入LAMP服务器的ip地址或对应ip的域名即可看到测试页面;





页: [1]
查看完整版本: CentOS6.6 部署LAMP系统架构