咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
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端口通过防火墙
配置好后重启iptables生效:/etc/init.d/iptables restart
2.关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUX=targeted #注释掉
SELINUX=disabled #增加
:wq #保存和关闭
Shutdown -r now #重启系统
3.安装apache
yum -y install httpd
Chkconfig httpd on #让apache开机自启动
/etc/init.d/httpd restart #重启apache
/etc/init.d/httpd stop #关闭apache
/etc/init.d/httpd start #开启apache
vi /etc/httpd/conf/httpd.conf #apache的配置文件
4.安装MYSQL
yum install mysql mysql-server #会提示输入两次密码
mysql_secure_installation #如果不提示输入密码,请输入此指令配置root的密码
chkconfig --list|grep mysqld #查看启动信息
chkconfig mysqld on #开机自启动
/etc/init.d/mysqld restart#重启
/etc/init.d/mysqld stop #关闭
/etc/init.d/myqld start #启动
4.安装PHP
yum -y install php#安装php
#以下是安装PHP组件,让PHP支持myql:
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
5.重启
/etc/init.d/httpd restart
/etc/init.d/mysqld restart
6.测试,把下列两个文件放入/var/www/html中.
info.php文件内容:<?php infophp(); ?>
mysql.php文件内容:
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
echo "connect success ok"
// some code
?>