添加CentOS 7 Nginx yum資源庫python
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm # 安裝nignx
sudo yum install -y nginx
Nginx將完成安裝在你的CentOS 7 服務器中。mysql
附:nginx 官方給不一樣系統準備了不少包,可到這個地址依次查找 http://nginx.org/packages/nginx
# 新增用戶
[root@VM_0_3_centos ~]# useradd zhangyafei # 設置密碼
[root@VM_0_3_centos ~]# passwd zhangyafei Changing password for user zhangyafei. New password: BAD PASSWORD: The password contains the user name in some form Retype new password: Sorry, passwords do not match. New password: BAD PASSWORD: The password contains the user name in some form Retype new password: passwd: all authentication tokens updated successfully. # 切換用戶
[root@VM_0_3_centos ~]# su zhangyafei # 查找指定文件路徑
[zhangyafei@VM_0_3_centos root]$ whereis sudoers sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz # 查看指定文件修改權限
[zhangyafei@VM_0_3_centos root]$ ls -l /etc/sudoers -r--r----- 1 root root 3907 Jun 23 2017 /etc/sudoers # 增長指定文件寫的權限
[zhangyafei@VM_0_3_centos root]$ chmod -v u+w /etc/sudoers chmod: changing permissions of ‘/etc/sudoers’: Operation not permitted failed to change mode of ‘/etc/sudoers’ from 0440 (r--r-----) to 0640 (rw-r-----) [zhangyafei@VM_0_3_centos root]$ su root Password: [root@VM_0_3_centos ~]# chmod -v u+w /etc/sudoers mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----) [root@VM_0_3_centos ~]# vi /etc/sudoers
hostnamectl set-hostname centos77.magedu.com
hostname
[root@VM_0_3_centos ~]# vim /etc/hosts [root@centos ~]# cat /etc/hosts 127.0.0.1 VM_0_3_centos VM_0_3_centos centos 127.0.0.1 localhost.localdomain localhost 127.0.0.1 localhost4.localdomain4 localhost4 ::1 VM_0_3_centos VM_0_3_centos centos ::1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
CentOS7默認安裝mariadb數據庫:yum remove mariadb-libs.x86_64git
下載Mysql源:sql
wget https://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
安裝源數據庫
yum localinstall mysql57-community-release-el7-8.noarch.rpm
安裝MySQLvim
yum install mysql-community-server
啓動centos
sudo service mysqld start
報錯服務器
首次在centos下安裝mysql,客戶端鏈接mysql時報錯: [root@localhost opt]# mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解決dom
[root@centos bin]# cat /var/log/mysqld.log | grep password 2019-02-23T13:20:38.188663Z 1 [Note] A temporary password is generated for root@localhost: 6kq9r3fS=pLB 2019-02-23T13:22:36.565007Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2019-02-23T13:23:06.290669Z 3 [Note] Access denied for user 'localhost'@'localhost' (using password: NO) 2019-02-23T13:23:55.824104Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2019-02-23T13:24:17.247383Z 0 [Note] Shutting down plugin 'validate_password' 2019-02-23T13:24:19.142034Z 0 [Note] Shutting down plugin 'sha256_password' 2019-02-23T13:24:19.142037Z 0 [Note] Shutting down plugin 'mysql_native_password' 2019-02-23T13:24:26.907100Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2019-02-23T13:25:25.294091Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2019-02-23T13:25:39.918727Z 4 [Note] Access denied for user 'root-p'@'localhost' (using password: NO) 2019-02-23T13:29:07.486422Z 0 [Note] Shutting down plugin 'validate_password' 2019-02-23T13:29:09.214411Z 0 [Note] Shutting down plugin 'sha256_password' 2019-02-23T13:29:09.214414Z 0 [Note] Shutting down plugin 'mysql_native_password' 2019-02-23T13:29:18.308960Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2019-02-23T13:30:51.366573Z 0 [Note] Shutting down plugin 'validate_password' 2019-02-23T13:30:52.507640Z 0 [Note] Shutting down plugin 'sha256_password' 2019-02-23T13:30:52.507643Z 0 [Note] Shutting down plugin 'mysql_native_password' [root@centos bin]# service mysqld start Redirecting to /bin/systemctl start mysqld.service [root@centos bin]# mysql -u root-p ERROR 1045 (28000): Access denied for user 'root-p'@'localhost' (using password: NO) [root@centos bin]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.25 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
設置密碼
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Mysqlpassw0rd.'); alter user 'root'@'localhost' identified by 'Mysqlpassw0rd.';
注意:mysql的密碼有規則限制,因此不能太簡單
sudo yum install git
備份python2.7
cd /usr/bin mv python python.bak
下載安裝python3
1. yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel mysql-devel gcc gcc-devel python-devel 2. mkdir /usr/local/python3 cd /usr/local/python3 3. wget "https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz" 4. tar -zxvf Python-3.6.5.tgz 5. Python-3.6.5/configure --prefix=/usr/local/python3 6. cd Python-3.6.5 7. make 8. make install 9. ln -s /usr/local/python3/bin/python3 /usr/bin/python3 10. ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
軟連接建立完畢以後。再說個事情,就是centos的yum命令是須要python支持的,咱們貿然把當期的版本更換了,萬一yum出錯怎麼辦,仍是讓yum依然用原來的2.7版本吧。好吧咱們幫它改一下吧:
注意:下面這個操做用vi操做,不熟悉vi的同窗必定要按照個人指示來,否則你一臉懵逼連修改後的文件怎麼保存退出都不知道。
首先輸入命令,而後回車:
[root@localhost bin]# vi /usr/bin/yum
接下來出現一個全新的界面。此時任何按鍵都不要動。聽我指示。
首先,切換到英文輸入法,再輸入字符 i 是aeiou的i
而後就能夠開始編輯這個文件了。
把文件開頭第一行的
#!/usr/bin/python改爲#!/usr/bin/python2.7 這樣就能夠了。
設置python和pip爲python3
alias python='python3' alias pip='pip3'
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 pip install virtualenv ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv virutalenv -p /usr/bin/python3
vi ~/.pip/pip.conf 內容 [global] timeout = 60 index-url = https://pypi.douban.com/simple 若是使用http連接,則須要trusted-host參數 [global] timeout = 60 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com