1.更新yum源谒获,更新linux內(nèi)核[http://www.reibang.com/writer#/notebooks/43300763/notes/61824713/preview]
2.直接安裝apche,安裝好以后蛤肌,設(shè)置開機啟動,然后配置ServerName
vi /etc/httpd/conf/httpd.conf
將#ServerName www.example.com:80修改為ServerName localhost:80
yum install httpd
*如果是centos7批狱,那么用的防火窗是為firewalle,而不是iptabes.如果有些設(shè)備需要用到端口檢測設(shè)備裸准,那么先要停止firewalle,新安裝iptables相關(guān)服務。
3.centos7使用的默認數(shù)據(jù)庫為MariaDB赔硫,所以直接使用yum直接安裝的話炒俱,會安裝這個mysql的兄弟數(shù)據(jù)庫,yum install mysql-server.所以要用weget重新拉取自己需要的mysql版本爪膊,然后安裝权悟。
4.安裝PHP,安裝好PHP后,要重啟apache推盛,使PHP在apache中生效峦阁。安裝PHP拓建,再重啟apache
如果使用ngnix來做服務器耘成,那么要安裝php-fpm.只安裝nginx是執(zhí)行不了php文件的榔昔。
5.安裝目錄
Apache默認將網(wǎng)站的根目錄指向/var/www/html 目錄
默認的主配置文件是/etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
nginx 默認的路徑為 usr/share/nginx/html/
1).linux 如何重置root密碼,如果在騰訊云瘪菌,那么直接在騰訊云后臺可以直接更改件豌。
其他方法(在虛擬機中如何修改):https://blog.csdn.net/niu_hao/article/details/52882895
2).終端窗口向前或向后查看
shift+pageUp
shift+pageDown
3).iptables 是linux以前的端口監(jiān)控程序,他是個防火窗控嗜,默認監(jiān)聽的端口為3306
4).新裝的mysql茧彤,怎么授權(quán)給外部訪問的三種方法
https://blog.csdn.net/yuhan61659/article/details/80590227
(1).直接修改表(2)通過設(shè)置指定密碼(3)直接授權(quán)
其他日記有。
mkdir file1 file2
mv file2 file1
mkdir -p file1/file2/file3
ln -s /root/test/file1 /filelink /root/test/file1指的是文件的路徑 /filelink 指的是軟鏈接
cp file1 file2
cp file1/* .
cp file1/* /root/
tar zcvf file1 /root/rile1
tar zcvf mypro.tar.gz test
zip -r mytest.zip test //mytest.zip 代表打包并壓縮到當前目錄下疆栏,使用這個名字曾掂,test代碼從哪里打包
unzip mytest.zip
unzip mytest.zip -d test
yum install -y unzip zip
源碼安裝-》rpm->yum
rpm/yum yum是管理rpm的前段界面惫谤,只要通過rpm安裝的軟件,都可以通過yum來管理
yum install xxx
yum remove xxx
yum check-update
yum update 安裝所有更新軟件
yum -y install xxx
在命令后面加| more
在命令后面加| less
按q或者ctrl+c退出
使用nat 鏈接方式
linux 虛擬主機不能正常鏈接網(wǎng)絡(luò)的解決方法 //https://www.cnblogs.com/dplearning/p/5890332.html
進入/etc/sysconfig/netwoerk-scripts/ 查看這下面的文件
每個人的這個文件有所不一樣珠洗,但前輟是一樣的溜歪,vi ifcfg-ens33
將ONBOOT=no 改成ONBOOT= yes
重啟服務service network restart 重啟網(wǎng)卡
appach 軟件的軟件包名稱叫做httpd,因此,要安裝Apache軟件许蓖,就使用命令:yum install httpd
service httpd start
service httpd restart
service httpd stop
安裝Apache
yum install httpd 安裝
systemctl start httpd.service //開啟
systemctl enable httpd.service //設(shè)置開機啟動
告訴防火墻80讓它過去
firewall-cmd --zone=public --add-port=80/tcp --permanent
重啟生效
firewall-cmd --reload
ip addr 可以查看iP地址蝴猪,然后直接在瀏覽器直接訪問IP即可
yum install mysql
在版本5.7中,mysql.user 表沒有了password字段了膊爪,
用authentication_string 代替
在5.7之前的版本自阱,修改密碼。
修改msyql的登陸設(shè)置:
vi /etc/my.cnf
在mysql的字段中加上一句:skip-grant-tables
service mysqld restart
登陸并修改密碼米酬;
mysql -uroot -p
use mysql;
update user set password = password('123456') where user = "root";
update user set authentication_string = password('新密碼') where user = 'root';
mysql5.7后沛豌,字段password 變成了authentication_string,但是函數(shù)password()沒有變赃额;
flush privileges;
quit
將mysql的登陸的安全模塊修改為正常的
vi /etc/my.cnf
刪除skip-grant-tables
然后登陸mysql -hlocalhost -uroot -p123456
set password = password('Rush123456?');
select * from user;
password_expired 為密碼的過期時間
如何設(shè)置限制固定的IP登陸
update user set Host = '%' where user = 'root' limit 1;
其中%的意思是允許所有的IP遠程訪問加派,如果需要制定的某個IP就
寫上具體的IP即可。
exit
mysqladmin -uroot -p舊密碼 password 新密碼 //修改密碼在知道什么密碼的情況下跳芳。
centos 7 ,啟用的不是iptables 芍锦,所有3306是不能訪問的,我們一般啟用這個iptables做為端口檢測飞盆。
文件無法創(chuàng)建的原因有娄琉,文件沒有777 權(quán)限,還有一個原因就是selinux 是開啟的狀態(tài)桨啃,這個端口,是一個最小化的權(quán)限控制檬输,自己不懂照瘾,有
兼容有問題,所有丧慈,我們很多時候析命,安裝完apache ,第一個事情就是關(guān)掉這個服務,注意:一定要reboot ,重啟才有用逃默。
改變目錄的權(quán)限可以用winscp 來設(shè)置鹃愤, 這樣就避免了 linux 的命令操作。
winscp 可以不用裝ssh 就可以傳輸文件完域。
cp -r file1 file2 加-r表示遞歸
update user set Host = '%' where user = root limit 1;
CentOS 7.0默認使用的是firewall作為防火墻软吐,這里改為iptables防火墻。
1吟税、關(guān)閉firewall:
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
2凹耙、安裝iptables防火墻
yum install iptables-services -y
3.啟動設(shè)置防火墻
systemctl enable iptables
systemctl start iptables
4.查看防火墻狀態(tài)
systemctl status iptables
5編輯防火墻姿现,增加端口
vi /etc/sysconfig/iptables #編輯防火墻配置文件
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
:wq! #保存退出
3.重啟配置,重啟系統(tǒng)
systemctl restart iptables.service #重啟防火墻使配置生效
systemctl enable iptables.service #設(shè)置防火墻開機啟動