# 更新Linux到最新内核
yum update -y
# 更改时区 cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 安装时间同步
yum install ntpdate
# 同步时间
ntpdate stdtime.gov.hk
# CentOS6 增加PHP5.4源(推荐)
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
# CentOS5 增加PHP5.4源
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
# 安装LAMP
yum install php54w.x86_64 php54w-cli.x86_64 php54w-devel.x86_64 php54w-intl.x86_64 php54w-mysqlnd.x86_64 php54w-pdo.x86_64 php54w-soap.x86_64 php54w-tidy.x86_64 php54w-xml.x86_64 php54w-xmlrpc.x86_64 php54w-zts.x86_64 php54w-gd.x86_64 php54w-mbstring.x86_64 php54w-pecl-apc.x86_64 php54w-mcrypt.x86_64 httpd.x86_64 httpd-devel.x86_64 httpd-tools.x86_64 mysql.x86_64 mysql-devel.x86_64 mysql-server.x86_64 vsftpd.x86_64 unzip.x86_64 -y
# 添加自启动 chkconfig httpd on chkconfig mysqld on
# 启动Apache和mysql
service httpd start
service mysqld start
# 当然要简单直接
reboot
# 更改mysql密码为123123
mysqladmin -uroot -p password 123123
# 创建web目录
mkdir -p /data/www
# 更改目录所有者为Apache默认用户
chown -R apache:apache /data
# 下载phpMyAdmin(虽然老,但好用)
wget http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.10/phpMyAdmin-3.3.10-all-languages.tar.gz
# 安装phpMyAdmin
tar zxvf phpMyAdmin-3.3.10-all-languages.tar.gz
mv phpMyAdmin-3.3.10-all-languages /data/www/phpmyadmin
chown -R apache:apache /data/www/phpmyadmin
# 修改phpMyAdmin为cookie方式登录
cd /data/www/phpmyadmin
cp config.sample.inc.php config.inc.php
# 添加phpMyAdmin对应的Apache配置文件
cat >> /etc/httpd/conf.d/phpmyadmin.conf <<EOF
Alias /phpmyadmin "/data/www/phpmyadmin"
<Directory "/data/www/phpmyadmin">
Options Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
EOF
添加新的虚拟主机:
cat >> /etc/httpd/conf.d/webname.conf <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName webname.com ServerAlias www.webname.com
DocumentRoot /data/www/webname
<Directory /data/www/webname>
Options FollowSymLinks Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF
注意添加第一个虚拟主机时,需在httpd.conf或在任意一个虚拟主机配置文件开头添加如下配置
NameVirtualHost *:80
<VirtualHost *:80>
...
</VirtualHost>
之后添加不需要重复写(因为这句的意思可以理解为是否启用虚拟主机)
启动Apache时有个警告的解决办法:
# 编辑httpd.conf文件
vim /etc/httpd/conf/httpd.conf
# 搜索"#ServerName",添加
ServerName localhost:80
重启Apache即可
|
请发表评论