常用命令
查看系統(tǒng)版本:
head -n 1 /etc/issue
lsb_release?-a? ? (centos 7 )
查看系統(tǒng)位數(shù)
getconf LONG_BIT
lsof -i 8080 ?查看8080端口的訪問詳情
內(nèi)核升級(jí)
[root@localhost ~]# uname -a?? ##舊版
Linux localhost.localdomain 2.6.32-279.el6.i686?#1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
[root@localhost ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@localhost ~]# rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
[root@localhost ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y? ##此步會(huì)有點(diǎn)慢
[root@localhost ~]# vim /etc/grub.conf default=1 改為 default=0? ##設(shè)置默認(rèn)以3.10核心啟動(dòng)址否,默認(rèn)是按照舊的核心啟動(dòng)
[root@localhost ~]# reboot
[root@localhost ~]# uname -a? ##升級(jí)后的版本
CentOS 6.x 安裝 php7.0
一:檢查當(dāng)前是否有安裝php
rpm -qa|grep php
如果有安裝PHP酱畅,那么請(qǐng)先刪除這些安裝包:
?yum remove php*
2.安裝php源
Centos 5 安裝php源:
rpm -ivh http://mirror.webtatic.com/yum/el5/latest.rpm
CentOs 6 安裝php源:
? rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7 安裝php源和epel擴(kuò)展源:
rpm -ivh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3.現(xiàn)在開始安裝php
安裝php5.5的基本安裝包:
?yum install php55w php55w-gd php55w-mbstring php55w-mysql php55w-fpm
安裝php5.6的基本安裝包:
?yum install php56w php55w-gd php56w-mbstring php56w-mysql php56w-fpm
安裝php7.0的基本安裝包:
? yum install php70w php70w-gd php70w-mbstring php70w-mysql php70w-fpm
刪除PHP:
#rpm?-qa|grep?php
刪除依賴:
#rpm -e php-pdo-5.1.6-27.el5_5.3
二:nginx的yum在線安裝
添加源
wget?http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安裝源庫(kù)
chmod +x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm
安裝nginx
yum -y install nginx
安裝完成后的默認(rèn)配置文件路徑
默認(rèn)nginx配置文件: /etc/nginx/nginx.conf 【nginx主要的配置文件】
默認(rèn)nginx的ssl配置文件: /etc/nginx/conf.d/ssl.conf 【配置SSL證書的,也可以并入到nginx.conf文件里】
默認(rèn)nginx的虛擬主機(jī)配置文件: /etc/nginx/conf.d/virtual.conf 【如同Apache的虛擬主機(jī)配置,也可以并入到nginx.conf文件里】
默認(rèn)的web_root文件夾路徑: /usr/share/nginx/html 【web目錄夾,放置Magento主程序】
配置iptables
iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
(這個(gè)步驟,我之前機(jī)器上已經(jīng)裝過apache所以就忽略了)
安裝后的目錄:
配置目錄:
/etc/nginx/
項(xiàng)目目錄:
/usr/share/nginx/html/
安裝Composer
CentOS下Composer的安裝和使用
1. 下載composer.phar
curl -sS https://getcomposer.org/installer | php
2.把composer.phar移動(dòng)到環(huán)境下讓其變成可執(zhí)行
mv composer.phar /usr/local/bin/composer
3.測(cè)試
composer -V
中國(guó)全量鏡像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
安裝 php擴(kuò)展
apt-get install php7.0-mbstring
apt-get install php7.0-dom
yum install -ylibtool-ltdl?php70w-dom php70w-mbstring php70w-mcrypt
yum install php70w-pear php70w-devel
壓縮命令
zip -r etm-m-om.zip etm-m-om
解壓目錄
unzip? mydata.zip?? -d? mydatabak? ? #壓縮mydata目錄
rpm -qa|grep php
yum install update -y
rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm
rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm
安裝php7.0的基本安裝包:
yum install php70w php70w-gd php70w-mbstring php70w-mysql php70w-fpm
安裝nginx
wget?http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm ?
安裝源庫(kù)
chmod +x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm
安裝nginx
yum -y install nginx
配置iptables 80端口 ;
配置目錄:
/etc/nginx/
項(xiàng)目目錄:
/usr/share/nginx/html/
安裝 php擴(kuò)展
apt-get install php70w-mbstring
apt-get install php70w-dom
nginx 設(shè)置
vi /etc/nginx/conf.d/default
server {
? ? listen? ? ? ?80;
? ? server_name? 10.207.21.113;
? ? #charset koi8-r;
? ? #access_log? /var/log/nginx/log/host.access.log? main;
? ? root /var/www/html/etm-m/public ;
? ? index index.php index.html index.htm;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 8;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
? ? location / {
? ? ? ?#root? ?/var/www/html/etm-m/public;
? ? ? ?#index? index.php index.html index.htm;
? ? ? ?try_files $uri $uri/ /index.php?$query_string ;
? ? }
? ? #error_page? 404? ? ? ? ? ? ? /404.html;
? ? # redirect server error pages to the static page /50x.html
? ? #
? ? error_page? ?500 502 503 504? /50x.html;
? ? location = /50x.html {
? ? ? ? root? ?/usr/share/nginx/html;
? ? }
? ? # proxy the PHP scripts to Apache listening on 127.0.0.1:80
? ? #
? ? #location ~ \.php$ {
? ? ? ? #proxy_pass? ?http://127.0.0.1;
? ?#}
? ? # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
? ? #
? ? location ~ \.php$ {
? ? #? ? ?root? ? ? ? ? ?/var/www/html/etm-m/public;
? ? ? ? fastcgi_pass? ?127.0.0.1:9000;
? ? ? ? try_files $uri /index.php=404 ;
? ? ? ? fastcgi_index? index.php;
? ? ? ? fastcgi_param? SCRIPT_FILENAME? $document_root/$fastcgi_script_name;
? ? ? ? include? ? ? ? fastcgi_params;
? ? }
? ? # deny access to .htaccess files, if Apache's document root
? ? # concurs with nginx's one
? ? #
? ? #location ~ /\.ht {
? ? #? ? deny? all;
? ? #}
}
部署負(fù)載
nginx:
user? nginx;
worker_processes? 1;
error_log? /var/log/nginx/error.log warn;
pid? ? ? ? /var/run/nginx.pid;
events {
? ? worker_connections? 1024;
}
http {
? ? include? ? ? ?/etc/nginx/mime.types;
? ? default_type? application/octet-stream;
? ? log_format? main? '$remote_addr - $remote_user [$time_local] "$request" '
? ? ? ? ? ? ? ? ? ? ? '$status $body_bytes_sent "$http_referer" '
? ? ? ? ? ? ? ? ? ? ? '"$http_user_agent" "$http_x_forwarded_for"';
? ? access_log? /var/log/nginx/access.log? main;
? ? upstream myServer{
? ? ? ? ip_hash ;
? ? ? ? server? 10.207.21.111:80;
? ? ? ? server? 10.207.21.113:80;
? ?}
? ? server{
? ? ? ? listen 80;
? ? ? ? server_name etm ;
? ? ? ? location / {
? ? ? ? ? ?proxy_pass? http://myServer ;
? ? ? ? ? ?proxy_set_header Host? $host ;
? ? ? ? ? ?proxy_set_header X-Real-IP? $remote_addr ;
? ? ? ? ? ?proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
? ? ? ?}
? ?}
? ? sendfile? ? ? ? on;
? ? #tcp_nopush? ? ?on;
? ? keepalive_timeout? 65;
? ? #gzip? on;
? ? include /etc/nginx/conf.d/*.conf;
}
~
負(fù)載的 conf
server {
? ? listen? ? ? ?80;
? ? server_name? localhost;
? ? #charset koi8-r;
? ? #access_log? /var/log/nginx/log/host.access.log? main;
? ? location / {
? ? ? ? root? ?/usr/share/nginx/html;
? ? ? ? index? index.html index.htm;
? ? }
? ? #error_page? 404? ? ? ? ? ? ? /404.html;
? ? # redirect server error pages to the static page /50x.html
? ? #
? ? error_page? ?500 502 503 504? /50x.html;
? ? location = /50x.html {
? ? ? ? root? ?/usr/share/nginx/html;
? ? }
? ? # proxy the PHP scripts to Apache listening on 127.0.0.1:80
? ? #
? ? #location ~ \.php$ {
? ? #? ? proxy_pass? ?http://127.0.0.1;
? ? #}
? ? # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
? ? #
? ? #location ~ \.php$ {
? ? #? ? root? ? ? ? ? ?html;
? ? #? ? fastcgi_pass? ?127.0.0.1:9000;
? ? #? ? fastcgi_index? index.php;
? ? #? ? fastcgi_param? SCRIPT_FILENAME? /scripts$fastcgi_script_name;
? ? #? ? include? ? ? ? fastcgi_params;
? ? #}
? ? # deny access to .htaccess files, if Apache's document root
? ? # concurs with nginx's one
? ? #
? ? #location ~ /\.ht {
? ? #? ? deny? all;
? ? #}
}
上傳項(xiàng)目賦予項(xiàng)目運(yùn)行權(quán)限
chown -R :nginx etm-m-om
cd etm-m-om
chmod -R 777 public
chmod -R 777 storage
chmod -R 775 bootstrap/cache
php artisan config:cache
php artisan route:cache
r
php artisan session:table
composer dump-autoload
php artisan migrate
部署告警
啟動(dòng)命令
nohup php artisan redis:subscribe &
安裝MySQL
Step1: 檢測(cè)系統(tǒng)是否自帶安裝mysql
# yum list installed | grep mysql
Step2: 刪除系統(tǒng)自帶的mysql及其依賴命令:
要?jiǎng)h除干凈mysql
# yum -y remove mysql-libs.x86_64
Step3: 給CentOS添加rpm源,并且選擇較新的源命令:
# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# yum localinstall mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
# yum-config-manager --disable mysql55-community
# yum-config-manager --disable mysql56-community
# yum-config-manager --enable mysql57-community-dmr
# yum repolist enabled | grep mysql
Step4:安裝mysql 服務(wù)器命令:
# yum install mysql-community-server
Step5: 啟動(dòng)mysql命令:
# service mysqld start
Step6: 查看mysql是否自啟動(dòng),并且設(shè)置開啟自啟動(dòng)命令:
# chkconfig --list | grep mysqld
# chkconfig mysqld on
Step7: mysql安全設(shè)置命令:
# mysql_secure_instalation
修改mysql初始密碼:
IK290yd7Dx2
方法一:
# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
注:5.7 版本的 Password 字段已經(jīng)改名為?authentication_string; 所以密碼語(yǔ)句需要修改為:
UPDATE user SET?authentication_string=PASSWORD('new') where USER='root';
賦權(quán)限
ALTER USER 'root'@'localhost' IDENTIFIED BY '45UIkdW230..';
grant all privileges on *.*? to??'root'@'%'? identified by '45UIkdW230..'? with grant option;
?grant all privileges on *.* to 'root'@'%' identified by '45UIkdW230..';
45UIkdW230
修改mysql時(shí)間:
rm -rf??/etc/localtime
cp ?/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
-select now()?
MySQL 主主同步
機(jī)器A
server-id=101
user=mysql
log-bin=mysql-bin
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=1
auto_increment_offset=1
binlog-do-db=test1
binlog-do-db=test1
binlog-ignore-db=db1
binlog-ignore-db=db2
機(jī)器B
server-id=102
user=mysql
log-bin=mysql-bin
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1
binlog-do-db=test1
binlog-do-db=test1
binlog-ignore-db=db1
binlog-ignore-db=db2
在機(jī)器A MySQL Client中插入:?
change master to
master_host='機(jī)器B的IP',
master_user='數(shù)據(jù)庫(kù)用戶名',
master_password='數(shù)據(jù)庫(kù)密碼',
master_log_file='mysql-bin.000001',
master_log_pos=154;
在機(jī)器B MySQL Client中插入:
change master to
master_host='機(jī)器A的IP',
master_user='數(shù)據(jù)庫(kù)用戶名',
master_password='數(shù)據(jù)庫(kù)密碼',
master_log_file='mysql-bin.000001',
master_log_pos=154;
MySQL 主從同步
機(jī)器A
server-id=101
user=mysql
log-bin=mysql-bin
機(jī)器B
server-id=102
user=mysql
log-bin=mysql-bin
在機(jī)器B MySQL Client中插入:
change master to
master_host='機(jī)器A的IP',
master_user='數(shù)據(jù)庫(kù)用戶名',
master_password='數(shù)據(jù)庫(kù)密碼',
master_log_file='mysql-bin.000001',
master_log_pos=154;
安裝Redis
IK290yd7Dx2
vi /etc/redis.conf
# find # requirepass foobared
#replace it with your password
requirepass somePassword
redis?127.0.0.1:6379[1]>?config?set?requirepass?my_redis?
OK?
redis?127.0.0.1:6379[1]>?config?get?requirepass?
1)?"requirepass"?
2)?"my_redis"??
不重啟Redis設(shè)置密碼:
在配置文件中配置requirepass的密碼(當(dāng)redis重啟時(shí)密碼依然有效)音榜。
redis 127.0.0.1:6379> config set requirepass test123
查詢密碼:
redis 127.0.0.1:6379> config get requirepass
(error) ERR operation not permitted
密碼驗(yàn)證:
redis 127.0.0.1:6379> auth test123
OK
HTTPS 設(shè)置
在使用git進(jìn)行代碼更新時(shí),出現(xiàn)認(rèn)證錯(cuò)誤捧弃,起初認(rèn)為是賬戶和密碼輸入錯(cuò)誤赠叼,可是經(jīng)過再三嘗試,終于確定是git版本太低問題违霞,因此將git升級(jí)到2.x版本嘴办。以下是升級(jí)步驟。
[root@test?~]# git --version
git version 1.7.1
?1葛家、安裝依賴
[root@test ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@test ~]# yum install -y perl-ExtUtils-MakeMaker package
2户辞、卸載系統(tǒng)原有g(shù)it
[root@test?~]# rpm -e git
3、下載git源碼包
[root@test?~]# wget?https://www.kernel.org/pub/software/scm/git/git-2.0.0.tar.gz
4癞谒、安裝git
[root@test?~]# tar xf git-2.0.0.tar.gz
[root@test?tools]# cd git-2.0.0
[root@test?git-2.0.0]# ./configure
[root@test?git-2.0.0]# make
[root@test git-2.0.0]# make install
[root@test git-2.0.0]# cd
5底燎、驗(yàn)證
[root@test ~]# git --version
git version 2.0.0
項(xiàng)目配置:
etm-m-link-check ?8013
etc-m-warn-report 8012
etc-m-com ? ? ? ? 8010
etc-m-com-warn ? ?8011
安裝目錄:
查看安裝目錄 # whereis php
ubuntu 安裝軟件
apt-cache search 軟件名稱
vi
gg ? ? ? ? ? : 跳轉(zhuǎn)到文件頭
Shift+g ? : 跳轉(zhuǎn)到文件末尾
centos 安裝擴(kuò)展
CentOS 7 安裝 PHP 7.0以及memcache和redis擴(kuò)展
安裝EPEL
EPEL 是 Extra Packages for Enterprise Linux 的縮寫(EPEL),是用于 Fedora-based Red Hat Enterprise Linux (RHEL) 的一個(gè)高質(zhì)量軟件源弹砚,所以同時(shí)也適用于 CentOS 或者 Scientific Linux 等發(fā)行版双仍。
rpm?-Uvh?https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install epel-release
安裝PHP 采用webtatic的編譯版本
rpm -Uvh?https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w?php70w-devel php70w-bcmath php70w-fpm php70w-mbstring php70w-pdo php70w-soap php70w-mysql php70w-gd
安裝memcached for php7
git clone?https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
git checkout php7
phpize
./configure --disable-memcached-sasl
make && make install
add
extension=memcached.so
to php.ini
安裝redis for php7
git clone?https://github.com/phpredis/phpredis.git
cd phpredis
git checkout php7
phpize
./configure
make && make install
add
extension=redis.so
to php.ini