1、设置端口可以通过防火墙,例如开启80端口
防火墙配置目录 vi /etc/sysconfig/iptables
在默认开启的22端口下添加 规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#允许80端口通过防火墙
2、防火墙重启
/etc/init.d/iptables restart
3、SELinux :Security-Enhanced Linux 强制访问控制。这种访问控制体系的限制下,进程只能访问那些在他的任务中所需文件
(1)获取当前SELinux运行状态 getenforce
(2)改变SELinux运行状态 setenforce [Enforcing | Permissive | 1 | 0 ]
4、关闭SELinux
编辑路径 vi /etc/selinux/config
#SELINUX = enforcing #注释掉
#SELINUXTYPE = targeted #注释掉
SELINUX = disabled #增加
:wq #保存,关闭
shutdown -r now #重启系统
安装Apache :
yum install httpd
/etc/init.d/httpd start #启动Apache
5、公司电脑虚拟机 - Apache配置文件位置 /etc/httpd/conf/httpd.conf
6、设置apache 开机启动 chkconfig httpd on
7、重启Apache /etc/init.d/httpd restart
8、查看所有运行端口 netstat -nultp
安装MySQL :
yum install mysql mysql-server
/etc/init.d/mysql start #启动MySQL
9、设置MySQL开机启动 chkconfig mysqld on
10、拷贝MySQL配置文件到指定目录 cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
11、为root 账户设置密码
mysql_secure_installation
12、重启MySQL /etc/init.d/mysqld restart
停止MySQL /etc/init.d/mysqld stop
启动MySQL /etc/init.d/mysqld start
13、安装PHP组件
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 libmcrypt
配置篇
1、Apache配置
vi /etc/httpd/conf/httpd.conf
ServerTokens OS 改为 ServerTokens Rrod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On 改为
ServerSignature
Off (在错误页面中不显示Apache的版本)
Options Indexes FollowSymLinks 改为 Options Includes ExecCGI FollowSymLinks(容许服务器执行CGI以及SSI,禁止列出目录)
#AddHandler cgi-script.cgi 改为 AddHandler cgi-script.cgi.pl (容许扩展名为.pl的CGI脚本运行)
AllowOverride None 改为 AllowOverride All (容许.httaccess)
AddDefaultCharset UTF-8 改为 AddDefaultCharset GB2312 (添加GB2312为默认编码)
Options Indexes MultiViews FollowSymLinks 改为 Options MultiViews FollowSymLinks (不在浏览器显示树状目录结构)
DirectoryIndex index.html index.html.val 改为 DirectoryIndex index.html index.html.val Default.html Default.htm index.php Default.php index.htm (设置默认首页文件增加index.php)
KeepAlive Off 改为 KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 改为 MaxKeepAliveRequests
1000 (增加同时连接数)
:wq! #保存退出
2、PHP配置
vi /etc/php.ini
date.timezone = PRC #去掉前边封号,改为 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
#disable_functions 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off # 禁止显示PHP的版本信息
magic_quotes_gpc = On # 打开magic_quotes_gpc来防止SQL注入
short_open_tag = ON #支持PHP短标签
open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本所在目录)和tmp目录
,可以防止php木马跨站,如果改了之后安装程序有问题
(例如:织梦内容管理系统),
可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
:wq! #保存退出,重启Apache 、MySQL