首頁論壇分類網站建置虛擬專用伺服器Vultr VPS - 編譯安裝 CentOS 7 Nginx + MySQL(MariaDB) + PHP
Vultr VPS - 編譯安裝 CentOS 7 Nginx + MySQL(MariaDB) + PHP
   編 輯        刪 除      # 5c8224a781dab 發表: Odyssey     新增:2018-08-31 14:35:22     更新:2020-02-04 13:37:44
關閉新式防火牆 systemctl stop firewalld.service systemctl disable firewalld.service 切換目錄 cd /usr/local/bin 設定防火牆 vi firewall.sh 變更權限 chmod +x firewall.sh 啟動防火牆 ./firewall.sh start 新增使用者 useradd 新使用者 passwd 新使用者 設定主機名稱 hostnamectl set-hostname 主機名稱 設定主機位址 vi /etc/hosts 127.0.0.1 localhost.localdomain localhost IP位址 子網域名稱 網域名稱 設定時區 timedatectl list-timezones timedatectl set-timezone 'Asia/Taipei' yum -y remove mariadb-* postfix-* yum -y install postfix cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-ntlm cyrus-sasl-md5 cyrus-sasl-plain dovecot yum -y install mariadb mariadb-server mariadb-devel yum -y install ntp wget lynx nmap telnet crontabs mlocate bzip2-* git openssl-* boost-* GeoIP-* vi /etc/profile export LD_LIBRARY_PATH=/usr/local/lib export LD_RUN_PATH=/usr/local/lib 安裝編譯所需要的函示庫 yum -y install gcc gcc-c++ make automake autoconf kernel-devel ncurses-devel curl gd file patch mlocate diffutils curl-devel gd-devel gettext-devel glibc-devel glib2-devel libstdc++-devel libjpeg-devel libmcrypt-devel libpng-devel libxslt-devel libxml2-devel pcre-devel zlib-devel bison bison-devel pam-devel libc-client libc-client-devel 重新開機 https://my.vultr.com/ 使用這邊的 restart 重新開機 編輯 dovecot 設定檔 vi /etc/dovecot/dovecot.conf protocols = imap pop3 啟動 pop3 systemctl start dovecot 開機啟動 systemctl enable dovecot 啟動 saslauthd systemctl start saslauthd 開機啟動 systemctl enable saslauthd 編輯 postfix 設定檔 vi /etc/postfix/main.cf 郵件主機名稱 myhostname = 主機名稱 郵件主機網域名稱 mydomain = 網域名稱 郵件主機發信來源 myorigin = $myhostname 要監聽的網路介面 inet_interfaces = all 要收信的網域名稱 mydestination = /etc/postfix/local-host-names 帳號對照表 virtual_alias_maps = hash:/etc/postfix/virtual 設定信任網域 mynetworks_style = host 規定信任的用戶端 mynetworks = 127.0.0.0/8, 192.168.0.0/24, hash:/etc/postfix/access 規範可以幫忙 relay 的下一部 MTA 主機位址 relay_domains = $mydestination 啟動 SMTP 認證 smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_security_options = noanonymous smtpd_client_restrictions = permit_sasl_authenticated smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated vi /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no auth_mechanisms = plain login vi /etc/dovecot/conf.d/10-mail.conf mail_location = mbox:~/mail:INBOX=/var/mail/%u vi /etc/dovecot/conf.d/10-master.conf service auth 區塊 #unix_listener auth-userdb unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postdrop } 設定接收的網域 vi /etc/postfix/local-host-names 設定郵件帳號對應 vi /etc/postfix/virtual 轉換對照表 postmap /etc/postfix/virtual 啟動服務 systemctl start postfix 開機啟動 systemctl enable postfix 重新開機 https://my.vultr.com/ 使用這邊的 restart 重新開機 先用SFTP上傳檔案到 /usr/local/src 切換目錄 cd /usr/local/src 安裝 Make tar zxf make-4.2.1.tar.gz cd make-4.2.1 ./configure && make && make install && make clean cd .. 安裝 M4 tar zxf m4-1.4.17.tar.gz cd m4-1.4.17 ./configure && make && make install && make clean cd .. 安裝 Autoconf tar zxf autoconf-2.69.tar.gz cd autoconf-2.69 ./configure && make && make install && make clean cd .. 安裝 Automake tar zxf automake-1.15.tar.gz cd automake-1.15 ./configure && make && make install && make clean cd .. 安裝 Libtool tar zxf libtool-2.4.6.tar.gz cd libtool-2.4.6 ./configure && make && make install && make clean cd .. 安裝 Bison tar zxf bison-3.0.4.tar.gz cd bison-3.0.4 ./configure && make && make install && make clean cd .. 登出再登入 安裝 7-zip tar jxf p7zip_16.02_src_all.tar.bz2 cd p7zip_16.02 cp makefile.linux_amd64 makefile.machine make all ./install.sh make clean 執行檔位置 /usr/local/bin/7za 安裝 redis tar zxf redis-3.2.8.tar.gz cd redis-3.2.8 make make test make install cd utils ./install_server.sh make clean 啟動 redis /usr/local/bin/redis-server /etc/redis/6379.conf 命令列 /usr/local/bin/redis-cli 性能測試 /usr/local/bin/redis-benchmark -n 10000 安裝 libmcrypt tar zxf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure --prefix=/usr/local/libmcrypt && make && make install && make clean cd .. 安装 apr tar jxf apr-1.5.2.tar.bz2 cd apr-1.5.2 ./configure --prefix=/usr/local/apr && make && make install && make clean cd .. 安装 apr-util tar jxf apr-util-1.5.4.tar.bz2 cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config && make && make install && make clean cd .. 安裝 sqlite tar zxf sqlite-autoconf-3170000.tar.gz cd sqlite-autoconf-3170000 ./configure --prefix=/usr/local/sqlite3 && make && make install && make clean cd .. 執行檔位置 /usr/local/sqlite3/bin/sqlite3 安裝 subversion tar jxf subversion-1.9.5.tar.bz2 cd subversion-1.9.5 ./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-sqlite=/usr/local/sqlite3 && make && make install && make clean cd .. 安裝 cmake tar zxf cmake-3.7.2.tar.gz cd cmake-3.7.2 ./configure && make && make install && make clean cd .. 安裝 ImageMagick tar zxf ImageMagick.tar.gz cd ImageMagick-7.0.4-10 ./configure --prefix=/usr/local/ImageMagick && make && make install && make clean cd .. 安裝 mariadb tar zxf mariadb-10.0.29.tar.gz cd mariadb-10.0.29 /usr/local/bin/cmake . -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci && make && make install && make clean 切換到目的目錄 cd /usr/local/mysql 新增 mysql 使用者和群組 useradd -r mysql 建立目錄 mkdir /var/lib/mysql 變更擁有者 chown mysql /var/lib/mysql 變更擁有者 chown -R mysql . 變更群組 chgrp -R mysql . 安裝預設資料 scripts/mysql_install_db --user=mysql 變更程式擁有者為 root chown -R root . 變更資料擁有者為 mysql chown -R mysql data 複製設定檔 cp support-files/my-huge.cnf /etc/my.cnf 編輯設定檔 vi /etc/my.cnf character-set-server = utf8 collation-server = utf8_general_ci default_storage_engine = MyISAM skip-external-locking thread_concurrency skip-networking 啟動 mysql /usr/local/mysql/bin/mysqld_safe --datadir=/var/lib/mysql & 設定 root 帳號密碼 /usr/local/mysql/bin/mysqladmin -u root password '新密碼' 登入 mysql /usr/local/mysql/bin/mysql -u root -p use mysql; delete from user where Host <> 'localhost' or User <> 'root'; exit; 切換目錄 cd /usr/local/src 安裝 postgresql tar jxf postgresql-9.6.2.tar.gz cd postgresql-9.6.2 ./configure --prefix=/usr/local/pgsql --without-readline && gmake && gmake install && gmake clean 新增使用者 postgres useradd postgres 建立資料目錄 mkdir /usr/local/pgsql/data 變更資料擁有者 chown postgres /usr/local/pgsql/data 切換使用者 su - postgres 初始化資料 /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data 編輯設定檔 vi /usr/local/pgsql/data/postgresql.conf vi /usr/local/pgsql/data/pg_ident.conf vi /usr/local/pgsql/data/pg_hba.conf 讓區網或特定IP直接連線(Default Port 5432) host all all 192.168.1.0/24 trust 啟動 pgsql (須用 postgres 使用者啟動) /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start 登入 postgresql /usr/local/pgsql/bin/psql 設定 postgres 密碼 alter role postgres with password '12345678'; 登出 postgresql \q 登出 postgres 使用者 exit 重新開機 https://my.vultr.com/ 使用這邊的 restart 重新開機 切換目錄 cd /usr/local/src 安裝 nginx tar zxf nginx-1.11.10.tar.gz cd nginx-1.11.10 ./configure --prefix=/usr/local/nginx --with-threads --with-pcre && make && make install && make clean ./configure --prefix=/usr/local/nginx --with-threads --with-pcre --with-http_ssl_module --with-http_v2_module && make && make install && make clean 設定 nginx vi /usr/local/nginx/conf/nginx.conf 新增PHP支援 # 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 $document_root$fastcgi_script_name; include fastcgi_params; } 測試 nginx /usr/local/nginx/sbin/nginx -t 啟動 nginx /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 停止 nginx /usr/local/nginx/sbin/nginx -s stop /usr/local/nginx/sbin/nginx -s quit 重啟 nginx /usr/local/nginx/sbin/nginx -s reload 預設根目錄 /usr/local/nginx/html 安裝 php-7.0.16 tar jxf php-7.0.16.tar.bz2 cd php-7.0.16 # 自訂版(請自行依當時編譯情況更動) ./configure --prefix=/usr/local/php7 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --with-tsrm-pthreads --enable-bcmath --with-bz2 --enable-calendar --enable-cgi --enable-cli --enable-ctype --with-curl --enable-dom --without-enchant --enable-exif --enable-fileinfo --enable-filter --enable-ftp --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --with-gd --with-gettext --enable-hash --with-iconv --without-imap --disable-intl --enable-json --enable-libxml --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --with-mhash --enable-mysqlnd --with-mysqli=mysqlnd --with-mysql-sock --enable-opcache --with-openssl --enable-pcntl --without-pear --with-pdo-mysql=mysqlnd --with-pdo-pgsql --with-pgsql=/usr/local/pgsql --enable-phar --enable-posix --enable-session --enable-shmop --enable-simplexml --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-tokenizer --enable-wddx --enable-xml --enable-xmlreader --with-xmlrpc --with-xsl --enable-zip --with-zlib # 完整版 ./configure --prefix=/usr/local/php7 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-apxs2=/usr/local/apache2/bin/apxs --enable-maintainer-zts --with-tsrm-pthreads --enable-bcmath --with-bz2 --enable-calendar --enable-cgi --enable-cli --enable-ctype --with-curl --enable-dom --without-enchant --enable-exif --enable-fileinfo --enable-filter --enable-ftp --enable-fpm --with-gd --with-gettext --enable-hash --with-iconv --without-imap --disable-intl --enable-json --enable-libxml --enable-mbstring --with-mcrypt --with-mhash --enable-mysqlnd --with-mysqli=mysqlnd --with-mysql-sock --enable-opcache --with-openssl --enable-pcntl --without-pear --with-pdo-mysql=mysqlnd --with-pdo-pgsql --with-pdo-sqlite --with-pgsql=/usr/local/pgsql --enable-phar --enable-posix --enable-session --enable-shmop --enable-simplexml --enable-soap --enable-sockets --with-sqlite3=/usr/local/sqlite3 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-tokenizer --enable-wddx --enable-xml --enable-xmlreader --with-xmlrpc --with-xsl --enable-zip --with-zlib make make install make clean 複製 PHP 設定檔 cp php.ini-production /usr/local/php7/etc/php.ini 複製 php-fpm 設定檔 cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf 編輯設定檔 vi /usr/local/php7/etc/php.ini vi /usr/local/php7/etc/php-fpm.conf 啟動 php-fpm /usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf 將 php 加入系統環境變數 vi /etc/profile 在最後面加入 export PATH=$PATH:/usr/local/php7/bin ----------------------------------------------------------------------------------------- 安裝 php imagick tar zxf imagick-3.4.3.tgz cd imagick-3.4.3 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config --with-imagick=/usr/local/ImageMagick && make && make install && make clean cd .. vi /usr/local/php7/etc/php.ini extension=imagick.so ----------------------------------------------------------------------------------------- 安裝 php redis tar zxf phpredis-3.1.1.tar.gz cd phpredis-3.1.1 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config && make && make install && make clean vi /usr/local/php7/etc/php.ini extension=redis.so ----------------------------------------------------------------------------------------- 安裝 php geoip tar zxf geoip-1.1.1.tgz cd geoip-1.1.1 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config --with-geoip && make && make install && make clean cd .. vi /usr/local/php7/etc/php.ini extension=geoip.so ----------------------------------------------------------------------------------------- 安裝 Python tar zxf Python-3.6.0.tgz cd Python-3.6.0 ./configure --enable-optimizations make make test make install make clean 執行檔位置 /usr/local/bin/python3 python3 -m pip install --upgrade pip python3 -m pip install mysql-connector python3 -m pip install pymysql python3 -m pip search xxxxxx ----------------------------------------------------------------------------------------- 安裝 Perl tar zxf perl5-5.24.1.tar.gz cd perl5-5.24.1 ./Configure -des -Dprefix=/usr/local/perl5 make make test make install make clean 執行檔位置 /usr/local/perl5/bin/perl 安裝 DBI /usr/local/perl5/bin/perl -MCPAN -e 'install Bundle::DBI' /usr/local/perl5/bin/perl -MCPAN -e 'install Bundle::DBD::mysql' /usr/local/perl5/bin/perl -MCPAN -e 'install Bundle::DBD::Pg' /usr/local/perl5/bin/perl -MCPAN -e 'install DBD::SQLite' /usr/local/perl5/bin/perl -MCPAN -e 'install DBD::mysql' ----------------------------------------------------------------------------------------- 設定執行權限 chmod +x /etc/rc.d/rc.local 設定開機啟動 vi /etc/rc.d/rc.local #啟動 firewall /usr/local/bin/firewall.sh start #啟動 redis /usr/local/bin/redis-server /etc/redis/6379.conf #啟動 mysql /usr/local/mysql/bin/mysqld_safe --datadir=/var/lib/mysql & #啟動 nginx /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #啟動 php-fpm /usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf #啟動 subversion /usr/local/subversion/bin/svnserve -d -r /home/subversion ----------------------------------------------------------------------------------------- 設定 sshd vi /etc/ssh/sshd_config LoginGraceTime 2m PermitRootLogin yes StrictModes yes MaxAuthTries 6 MaxSessions 10 PermitEmptyPasswords no PasswordAuthentication yes 重新啟動 /etc/rc.d/init.d/sshd restart ----------------------------------------------------------------------------------------- vi +/expose_php /usr/local/php7/etc/php.ini expose_php = Off ----------------------------------------------------------------------------------------- 建議 Silicon Valley, California Los Angeles, California Vultr 優惠碼 http://www.vultr.com/?ref=7026714 For a Limited Time - Give $20, Get $30! http://www.vultr.com/?ref=7109343-3B -----------------------------------------------------------------------------------------
夢幻奧德修斯 - OdysseusDream

Website:https://www.odysseusdream.com/

Discord:https://discord.gg/ht4mwMG

FB社團:https://www.facebook.com/groups/OdysseusDream/

FB粉專:https://www.facebook.com/OdysseusDream/

我要回覆
Vultr VPS - 編譯安裝 CentOS 7 Nginx + MySQL(MariaDB) + PHP
首頁論壇分類網站建置虛擬專用伺服器Vultr VPS - 編譯安裝 CentOS 7 Nginx + MySQL(MariaDB) + PHP