lamp网站部署

应公司要求在 Vsphere client部署备用网站,以便备用,不要问为什么有虚拟化任性。

环境centos6.5 直接用yum安装环境,新机器做下初始话一个脚本公司同事写的:

#!/bin/bash
# Program:
#       system_init_shell
# History:
# Release:
#       1.1
cat << EOF
 +--------------------------------------------------------------+
 |          === Welcome toCentOS6.x System init ===           |
 +--------------------------------------------------------------+
 +---------------------------by opsren--------------------------+
EOF

#update system pack
yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip libmcrypt-devel libmhash-devel ncurses-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool  system-config-network-tui system-config-firewall-tui ntp libaio-devel wget ntp iotop tcpdump openssh-clients vim telnet curl logwatch net-snmp

yum update -y
#set clock
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#set ntp
cp -f /etc/ntp.conf /etc/ntp.bak
sed -i ‘10s/^.*$/restrict default ignore/‘ /etc/ntp.conf
service ntpd restart
chkconfig --level 234 ntpd on
#set ulimit
echo "ulimit -SHn 102400" >> /etc/rc.local
cat > /etc/security/limits.conf << EOF

* hard nofile 65536
* soft nofile 4089
* hard nproc 16384
* soft nproc 10240
* hard rss 100000
EOF
#set max user processes
sed -i ‘s/1024/102400/‘ /etc/security/limits.d/90-nproc.conf

# turnoff the control-alt-delete
sed -i ‘s#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#‘ /etc/init/control-alt-delete.conf

 

#set LANG
:> /etc/sysconfig/i18n
cat >> /etc/sysconfig/i18n << EOF
 LANG="en_US.UTF-8"
EOF

#set ssh
sed -i ‘s/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/‘ /etc/ssh/sshd_config
sed -i ‘s/#UseDNS yes/UseDNS no/‘ /etc/ssh/sshd_config
#sed -i ‘s/#Port 22/Port 6343/‘ /etc/ssh/sshd_config
service sshd restart

#set sysctl
true > /etc/sysctl.conf
cat >> /etc/sysctl.conf << EOF

fs.aio-max-nr = 1048576

fs.file-max = 6815744

 

 net.ipv4.ip_forward = 0
 net.ipv4.conf.default.rp_filter = 1
 net.ipv4.conf.default.accept_source_route = 0
 kernel.sysrq = 0
 kernel.core_uses_pid = 1
 net.ipv4.tcp_syncookies = 1
 kernel.msgmnb = 65536
 kernel.msgmax = 65536
 kernel.shmmax = 68719476736
 kernel.shmall = 4294967296

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128
 net.ipv4.tcp_max_tw_buckets = 6000
 net.ipv4.tcp_sack = 1
 net.ipv4.tcp_window_scaling = 1
 net.ipv4.tcp_rmem = 4096 87380 4194304
 net.ipv4.tcp_wmem = 4096 16384 4194304
 net.core.wmem_default = 262144
 net.core.rmem_default = 262144
 net.core.rmem_max = 4194304
 net.core.wmem_max = 1048576
 net.core.netdev_max_backlog = 262144
 net.core.somaxconn = 262144
 net.ipv4.tcp_max_orphans = 3276800
 net.ipv4.tcp_max_syn_backlog = 262144
 net.ipv4.tcp_timestamps = 0
 net.ipv4.tcp_synack_retries = 1
 net.ipv4.tcp_syn_retries = 1
 net.ipv4.tcp_tw_recycle = 1
 net.ipv4.tcp_tw_reuse = 1
 net.ipv4.tcp_mem = 94500000 915000000 927000000
 net.ipv4.tcp_fin_timeout = 1
 net.ipv4.tcp_keepalive_time = 1200
 net.ipv4.ip_local_port_range = 9000 65500
EOF
/sbin/sysctl -p
echo "sysctl set OK!!"

#disable ipv6
/sbin/chkconfig ip6tables off
echo "ipv6 is disabled!"
#flush iptable
/sbin/iptables -F
/sbin/iptables-save > /etc/sysconfig/iptables
#disable selinux
sed -i ‘/SELINUX/s/enforcing/disabled/‘ /etc/selinux/config
setenforce 0

#vim setting

sed -i "8 s/^/alias vi=‘vim‘/" /root/.bashrc
echo ‘syntax on‘ > /root/.vimrc

cat << EOF
 +--------------------------------------------------------------+
 |                    ===System init over===                    |
 +--------------------------------------------------------------+
 +---------------------------by jinong--------------------------+
EOF
echo "###############################################################"

 

 

#关于脚本的解释说明:
#4.更新系统的基础软件
#5.设置系统时钟同步
#6.其中第一条语句是设定硬件时钟,第二条语句是设定系统时钟和硬件时钟同步
#7.增加打开最大文件描述符
#8.增加系统进程数(线程)的限制-->max user processes
#centos 5与centos 6不同的是,只要在/etc/security/limits.conf 设置了root soft nofile 102400 和root hard nofile102400,对应的uilmit -u 后的结果就会是102400,这里需要注意区别!
#9.关闭control-alt-delete
#10.设置系统语系
#11.设置SSH
#12.设置系统内核参数
#13.关闭IPV6
#14.关闭iptables
#15.关闭selinux
#16.vi相关设置

yum 更新一下包建立缓存

yum update

yum  makecache

 

安装lamp环境开始

 

安装apache
[root@lamp ~]# yum -y install httpd

开机启动
[root@lamp ~]# chkconfig httpd on
开启服务
[root@lamp ~]# service httpd start

安装一些扩展
[root@lamp ~]# yum install -y httpd-manual mod_ssl mod_perl mod_auth_mysql

查看下端口是否启动
[root@lamp ~]# netstat -lnpt
在浏览器访问
http://ip地址

安装mysql数据库
客户端服务端开发库
[root@lamp ~]# yum install mysql mysql-server mysql-devel -y
开机启动

[root@lamp ~]# chkconfig mysqld on

开启mysql服务
[root@lamp ~]# service mysqld start

看mysql运行端口
[root@lamp ~]# netstat -nlpt |grep mysql


安装php

为了让PHP支持MySQL,我们可以安装php-mysql软件包;也可使用以下命令搜索可用的php模块

[root@lamp ~]# yum install php php-mysql -y


安装php常用扩展

[root@lamp ~]# yum search php

[root@lamp ~]# yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

重启httpd
[root@lamp ~]# service httpd restart

写测试页面
[root@lamp ~]# cd /var/www/html/
[root@lamp html]# vim index.php

<?php
phpinfo();
?>

解压网站

tar zxvf web.tar.gz

创建mysql数据库

create database dedecmsv;

mysql加密码

 mysqladmin -uroot passwrod‘123456‘

默认mysql数据库在

/var/lib/mysql/

cp 网站数据放在数据中

修改数据库权限

 chown -R mysql.mysql dedecmsv

修改mysql连接用户密码

vim data/common.inc.php

修改php上传文件限制大小

vim /etc/php.ini

upload_max_filesize = 800M

post_max_size = 1G

request_order = "CGP"

遇到一个问题就是不能显示正常替换后正常

sed -i "s/192.168.0.208/192.168.0.91/g" `grep 192.168.0.208 -rl /var/www/html/`

本文出自 “技术革命生活” 博客,请务必保留此出处http://6769120.blog.51cto.com/6759120/1587727

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。