linux下配置web+ftp服务器全教程
1、安装Apahce,PHP,Mysql, 以及php连接mysql库组件,使用root用户输入如下命令:
yum -y install httpd php mysql mysql-server php-mysql
//安装主程序
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
//安装mysql扩展
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//安装php扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装apache扩展
2、配置web服务开机启动:
chkconfig httpd on 【设置开机启动http服务】
chkconfig -add mysqld 【添加mysql服务到系统服务列表】
chkconfig mysqld on 【设置mysql开机启动】
service httpd start 【启动http服务】
service mysqld start 【启动mysql服务】
3、设置mysql数据库的root密码:
mysqladmin -uroot password ‘新密码’
4、增加mysql数据库的安全性:
mysql -uroot -p 回车后提示输入密码,输入你刚刚设置的密码
登录mysql后,命令行前缀会变成 mysql> 然后继续输入如下命令:
DROP DATABASE test; 【删除测试数据库test】
DELETE FROM mysql.user WHERE user = ”; 【删除匿名账户】
FLUSH PRIVILEGES; 【重载权限】
5、配置虚拟主机(Virtualhost):
编辑一下apache的配置文件httpd.conf(这个文件的默认位置/etc/httpd/conf/httpd.conf),输入如下命令:
mkdir /var/www/html/demo 【新建一个虚拟主机目录】
chown -R apache:apache /var/www/html/demo 【修改demo目录的属组和属主为apache】*
vi /etc/httpd/conf/httpd.conf 【vi是linux下的一个编辑器工具】
在httpd.conf文件末尾加上:
<VirtualHost *:80>
ServerAdmin feng@pku120.com
DocumentRoot /var/www/html/demo
ServerName www.crazyer.com
ServerAlias crazyer.com
Errorlog logs/crazyer.com-error_log
CustomLog logs/crazyer.com-access_log common
</VirtualHost>
service httpd restart 【重启http服务,如果报错根据提示返回修改httpd.conf文件】
6、将域名解析到到此服务器ip上。