cat /etc/redhat-release // 返回 ## CentOS Linux release 7.7.1908 (Core)
cd /etc/yum.repos.d/ wget http://mirrors.163.com/.help/CentOS7-Base-163.repo mv CentOS-Base.repo CentOS-Base.repo.bak mv CentOS6-Base-163.repo CentOS-Base.repo
yum clean all && yum makecache && yum update -y
# 安裝make yum -y install gcc automake autoconf libtool make # 安裝 g++ yum -y install gcc gcc-c++
yum -y install openssl openssl-devel yum -y install pcre pcre-devel yum -y install zlib zlib-devel
# 下載nginx wget http://nginx.org/download/nginx-1.16.1.tar.gz # 解壓並進入解壓後的文件夾 tar -zxvf nginx-1.16.1.tar.gz cd nginx-1.16.1 # 配置 # 注:此處爲了在PHP使用Nginx的mod_zip模塊實現打包下載的功能,在此步驟前我先去安裝了git,再來安裝nginx,否則後面還得返回來再安裝一遍,如不須要此功能,能夠去掉./configure 後面的參數 ./configure --with-http_ssl_module --add-module=src/mod_zip # 安裝 make && make install
# 開啓 /usr/local/nginx/sbin/nginx # 重啓(修改配置文件須要測試) /usr/local/nginx/sbin/nginx -s reload # 關閉 /usr/local/nginx/sbin/nginx -s stop # 測試(修改配置文件後能夠測試下) /usr/local/nginx/sbin/nginx -t
yum -y install zlib-devel curl-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib autoconf tk perl-ExtUtils-MakeMaker
wget https://github.com/git/git/archive/v2.24.0.tar.gz tar zxvf v2.24.0.tar.gz cd git-2.24.0 autoconf ./configure make & make install
# 打開文件 vi /etc/ld.so.conf # 在最後一行加入以下 /usr/local/lib # 保存並退出 wq!
git --version # 瀏覽器測試,能夠打開服務器地址
# 或者直接經過服務器下載源文件安裝 wget http://cn2.php.net/distributions/php-7.2.24.tar.gz # 解壓(下面下載文件默認是在usr/local文件夾下) tar -zxvf php-7.2.24.tar.gz # 進入 cd php-7.2.24
# 生成configure文件包 autoconf # 配置(這裏若是服務器若是未安裝對應的依賴會報錯,好比如今未安裝Mysql,就應該先去安裝mysql再返回來安裝php也不遲) ./configure \ --prefix=/usr/local/php7 \ --with-config-file-path=/usr/local/php7/etc \ --with-curl \ --with-freetype-dir=/usr/include/freetype2/freetype \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip \ --enable-fileinfo \ --disable-inline-optimization
注:這裏出了個問題,報錯:unrecognized options: --sockets,檢查瞭解壓後的ext包,發現沒有sockets ,對比其餘服務器安裝的同版本,發現解壓後有,而後去php官網查看版本,發現最新php7.2.19已經變動了php-7.2.24php
make && make install
# 生成php.ini cp /root/php-7.2.24/php.ini-development /usr/local/php7/etc/php.ini # 生成www.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf # 生成php-fpm.conf cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
vi /usr/local/php7/etc/php-fpm.d/www.conf # 修改其中的listen 127.0.0.1:9000 端口爲9001 # user 和user_group根據狀況修改
vi /usr/local/nginx/conf/nginx.conf # 修改其中某個站點的fastcgi_pass 127.0.0.1:9000 端口爲9001
/usr/local/php7/sbin/php-fpm /usr/local/nginx/sbin/nginx -s -reload
注:centos7 yum源裏面的mysql已經將mysql替換成了MariaDB,且默認對應的是mysql5.5,這裏安裝最新版MariaDB10.4node
rpm -qa | grep mariadb # 結果有以下
cd /etc/yum.repos.d/ touch MariaDB.repo vim MariaDB.repo # 加入以下內容 # MariaDB 10.4 CentOS repository list - created 2019-11-19 09:14 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.4/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
yum install MariaDB-server MariaDB-client
systemctl start mariadb #啓動服務 systemctl enable mariadb #設置開機啓動 systemctl restart mariadb #從新啓動 systemctl stop mariadb.service #中止MariaDB
mysql_secure_installation Enter current password for root (enter for none):<–初次運行直接回車 Set root password? [Y/n] <– 是否設置root用戶密碼,輸入y並回車或直接回車 New password: <– 設置root用戶的密碼 Re-enter new password: <– 再輸入一次你設置的密碼 Remove anonymous users? [Y/n] <– 是否刪除匿名用戶,Y,回車 Disallow root login remotely? [Y/n] <–是否禁止root遠程登陸,N,回車, Remove test database and access to it? [Y/n] <– 是否刪除test數據庫,n,回車 Reload privilege tables now? [Y/n] <– 是否從新加載權限表,回車 mysql -u root -p vi /etc/my.cnf # 添加以下內容: [mysqld] init_connect='SET collation_connection = utf8_general_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_general_ci skip-character-set-client-handshake vi /etc/my.cnf.d/client.cnf # 在[client]中添加 default-character-set=utf8 vi /etc/my.cnf.d/mysql-clients.cnf # 在[mysql]中添加 default-character-set=utf8 # 重啓 systemctl restart mariadb # 檢測 mysql> show variables like "%character%";show variables like "%collation%";
建立外網可鏈接的用戶python
grant all privileges on *.* to tm@'%' identified by 'tianming2015'; flush privileges;
遠程測試鏈接,可鏈接上(不行的話要檢查防火牆)!止mysql
# 下載 wget http://download.redis.io/releases/redis-3.0.0.tar.gz # 解壓 tar -zxvf redis-3.0.0.tar.gz cd redis-3.0.0
# 指定目錄 make PREFIX=/usr/local/redis install
cd /usr/local/redis mkdir conf cp /root/redis-3.0.0/redis.conf /usr/local/redis/bin
# 修改redis.conf配置文件, daemonize yes 之後端模式啓動 vim /usr/local/redis/bin/redis.conf # 修改以下選項 daemonize yes requirepass 123456 //設置密碼 # 執行以下命令啓動redis: cd /usr/local/redis/bin ./redis-server redis.conf
# 鏈接redis /usr/local/redis/bin/redis-cli # 關閉redis cd /usr/local/redis ./bin/redis-cli shutdown # 強行終止redis pkill redis-server
vim /etc/rc.local //添加 /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis-conf
# 下載 wget https://npm.taobao.org/mirrors/node/v9.9.0/node-v9.9.0-linux-x64.tar.xz # 解壓 tar -xvf node-v9.9.0-linux-x64.tar.xz cd node-v9.9.0-linux-x64/bin && ls # 結果:有node 和 npm # 測試 ./node -v // 顯示版本號,安裝成功 # 將node.js移動到/usr/local目錄下 mv /root/node-v9.9.0-linux-x64 /usr/local/
ln -s /usr/local/node-v9.9.0-linux-x64/bin/node /usr/local/bin/node ln -s /usr/local/node-v9.9.0-linux-x64/bin/npm /usr/local/bin/npm
cd /usr/local/node-v9.9.0-linux-x64/bin npm install -g cnpm --registry=https://registry.npm.taobao.org # 創建軟鏈 ln -s /usr/local/node-v9.9.0-linux-x64/bin/cnpm /usr/local/bin/cnpm
cnpm install pm2 ln -s /usr/local/node-v9.9.0-linux-x64/bin/pm2 /usr/local/bin/pm2 pm2 start xx.js
yum install python-setuptools easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf supervisord -c /etc/supervisord.conf
vi /etc/supervisord.conf # 在include下增長以下內容 [include] files = /usr/local/share/supervisor/*.conf # 建立log日誌文件 vi /usr/local/share/supervisor/redisQueue.log
[program:casecloud-queue-listen] command=php /var/www/casecloud/server/artisan queue:work redis --tries=3 --timeout=300 user = root directory=/var/www/casecloud/server autostart=true autorestart=true startsecs=3 stdout_logfile=/usr/local/share/supervisor/redisQueue.log
說明:command=後面跟着就是你要守護的shell.linux
supervisorctl reload # 重啓 supervisorctl status # 查看正在運行的 supervisorctl help # 幫助
supervisord
yum -y install vsftpd
vi /etc/vsftpd/vsftpd.conf # 修改 anonymous_enable=NO # 末尾增長一行(添加用戶後,沒法上傳文件,設置用戶權限後,結果登陸不了,加以下項解決) allow_writeable_chroot=YES
useradd -d /www/../oa/ -s /sbin/nologin cp # 給目錄指定用戶 chown cp -R /www/../oa/
# 注意設置ftp傳輸模式爲主動