1.更新yum源,更新linux內核[http://www.lxweimin.com/writer#/notebooks/43300763/notes/61824713/preview]
2.直接安裝apche,安裝好以后,設置開機啟動,然后配置ServerName
vi /etc/httpd/conf/httpd.conf
將#ServerName www.example.com:80修改為ServerName localhost:80
yum install httpd
*如果是centos7,那么用的防火窗是為firewalle,而不是iptabes.如果有些設備需要用到端口檢測設備,那么先要停止firewalle,新安裝iptables相關服務。
3.centos7使用的默認數據庫為MariaDB,所以直接使用yum直接安裝的話,會安裝這個mysql的兄弟數據庫,yum install mysql-server.所以要用weget重新拉取自己需要的mysql版本,然后安裝。
4.安裝PHP,安裝好PHP后,要重啟apache,使PHP在apache中生效。安裝PHP拓建,再重啟apache
如果使用ngnix來做服務器,那么要安裝php-fpm.只安裝nginx是執行不了php文件的。
5.安裝目錄
Apache默認將網站的根目錄指向/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以前的端口監控程序,他是個防火窗,默認監聽的端口為3306
4).新裝的mysql,怎么授權給外部訪問的三種方法
https://blog.csdn.net/yuhan61659/article/details/80590227
(1).直接修改表(2)通過設置指定密碼(3)直接授權
其他日記有。
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 虛擬主機不能正常鏈接網絡的解決方法 //https://www.cnblogs.com/dplearning/p/5890332.html
進入/etc/sysconfig/netwoerk-scripts/ 查看這下面的文件
每個人的這個文件有所不一樣,但前輟是一樣的,vi ifcfg-ens33
將ONBOOT=no 改成ONBOOT= yes
重啟服務service network restart 重啟網卡
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 //設置開機啟動
告訴防火墻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的登陸設置:
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,但是函數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 為密碼的過期時間
如何設置限制固定的IP登陸
update user set Host = '%' where user = 'root' limit 1;
其中%的意思是允許所有的IP遠程訪問,如果需要制定的某個IP就
寫上具體的IP即可。
exit
mysqladmin -uroot -p舊密碼 password 新密碼 //修改密碼在知道什么密碼的情況下。
centos 7 ,啟用的不是iptables ,所有3306是不能訪問的,我們一般啟用這個iptables做為端口檢測。
文件無法創建的原因有,文件沒有777 權限,還有一個原因就是selinux 是開啟的狀態,這個端口,是一個最小化的權限控制,自己不懂,有
兼容有問題,所有,我們很多時候,安裝完apache ,第一個事情就是關掉這個服務,注意:一定要reboot ,重啟才有用。
改變目錄的權限可以用winscp 來設置, 這樣就避免了 linux 的命令操作。
winscp 可以不用裝ssh 就可以傳輸文件。
cp -r file1 file2 加-r表示遞歸
update user set Host = '%' where user = root limit 1;
CentOS 7.0默認使用的是firewall作為防火墻,這里改為iptables防火墻。
1、關閉firewall:
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
2、安裝iptables防火墻
yum install iptables-services -y
3.啟動設置防火墻
systemctl enable iptables
systemctl start iptables
4.查看防火墻狀態
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.重啟配置,重啟系統
systemctl restart iptables.service #重啟防火墻使配置生效
systemctl enable iptables.service #設置防火墻開機啟動