lamp網站部署

來源:互聯網
上載者:User

標籤:網站

應公司要求在 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
[[email protected] ~]# yum -y install httpd

開機啟動
[[email protected] ~]# chkconfig httpd on
開啟服務
[[email protected] ~]# service httpd start

安裝一些擴充
[[email protected] ~]# yum install -y httpd-manual mod_ssl mod_perl mod_auth_mysql

查看下連接埠是否啟動
[[email protected] ~]# netstat -lnpt
在瀏覽器訪問
http://ip地址

安裝mysql資料庫
用戶端服務端開發庫
[[email protected] ~]# yum install mysql mysql-server mysql-devel -y
開機啟動

[[email protected] ~]# chkconfig mysqld on

開啟mysql服務
[[email protected] ~]# service mysqld start

看mysql運行連接埠
[[email protected] ~]# netstat -nlpt |grep mysql


安裝php

為了讓PHP支援MySQL,我們可以安裝php-mysql軟體包;也可使用以下命令搜尋可用的php模組

[[email protected] ~]# yum install php php-mysql -y


安裝php常用擴充

[[email protected] ~]# yum search php

[[email protected] ~]# yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

重啟httpd
[[email protected] ~]# service httpd restart

寫測試頁面
[[email protected] ~]# cd /var/www/html/
[[email protected] 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

lamp網站部署

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.