修改默認主機名稱
[root@iZuf60c5bxd15kr9gycvv6Z~]# hostnamectl set-hostname centos7
[root@iZuf60c5bxd15kr9gycvv6Z~]# reboot
[root@iZuf60c5bxd15kr9gycvv6Z~]# yum update
安裝依賴庫
[root@centos7~]# yum -y install libaio? libaio-devel? bison? bison-devel? zlib-devel? openssl openssl-devel? ncurses? ncurses-devel libcurl-devel libarchive-devel? boost? boost-devel? lsof? wget gcc? gcc-c++ make cmake perl kernel-headers kernel-devel? pcre-devel screen
刪除系統默認數據庫配置文件
查詢
[root@centos7 ~]# find -H /etc/ | grep my.c
顯示如下:
/etc/my.cnf
/etc/my.cnf.d
/etc/my.cnf.d/mysql-clients.cnf
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
刪除
[root@centos7 ~]# rm -rf /etc/my.cnf /etc/my.cnf.d /etc/my.cnf.d/mysql-clients.cnf
確認
[root@centos7 ~]# find -H /etc/ | grep my.c
顯示如下:
/etc/pki/tls/certs/renew-dummy-cert
/etc/pki/tls/certs/make-dummy-cert
卸載系統自帶mariadb-libs
查詢
[root@centos7 ~]# rpm -qa|grep mariadb-libs
顯示如下:
mariadb-libs-5.5.52-1.el7.x86_64
刪除
[root@centos7 ~]#rpm -e mariadb-libs-5.5.52-1.el7.x86_64--nodeps
rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64
一、安裝NGINX
-下載安裝包并解壓
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.1.tar.gz
[root@localhost src]# tar -zxvf nginx-1.12.1.tar.gz
創建NGINX安裝目錄,WEB存放目錄,以及用戶組、用戶
# 創建nginx用戶組
[root@centos7 src]# groupadd -r www
# 創建nginx用戶
[root@centos7 src]# useradd -r -g www -s /sbin/nologin -d /usr/local/nginx -M www
# 創建安裝目錄
[root@centos7 src]# mkdir -p /usr/local/nginx
# 創建數據存放目錄
[root@centos7 src]# mkdir -p /data/web
# 賦以mysql用戶讀寫權限
[root@centos7 src]# chown -R www:www /data/web
-編譯安裝
[root@localhost src]#cd nginx-1.12.1
# 輸入以下參數
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
如果看到以下說明則編譯成功
# 開始安裝
[root@localhost nginx-1.12.1]#make && make install
嘗試啟動
[root@centos7 nginx-1.12.1]# /usr/local/nginx/sbin/nginx?????????????????
# 如果未提示錯誤即代表安裝成功
編寫快捷啟動腳本
[root@centos7 nginx-1.12.1]# vi /lib/systemd/system/nginx.service
?輸入以下代碼
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
設置開機啟動
[root@centos7nginx-1.12.1]# systemctl enable nginx.service
其它命令說明
# 啟動nginx
[root@centos7 nginx-1.12.1]# systemctl start nginx.service
# 停止nginx
[root@centos7 nginx-1.12.1]# systemctl stop nginx.service
# 重啟nginx
[root@centos7 nginx-1.12.1]# systemctl restart nginx.service
# 如果提示
Job for nginx.service failed because the control process exited with error code. See"systemctl status nginx.service"and"journalctl -xe"for details.
# 請選結束nginx進程后再嘗試執行上面的快捷操作??????
[root@centos7 nginx-1.12.1]# pkill -9 nginx
修改配NGINX配制文件
[root@centos7 php-7.1.10]# cd /usr/local/nginx/conf
[root@centos7 conf]# vi nginx.conf
# 修改如下代碼#
二、安裝MYSQL5.7?
開始安裝
[root@centos7 src]# rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
[root@centos7 src]# yum install -y mysql-server
設置開機啟動Mysql
[root@centos7 src]# systemctl enable mysqld.service
開啟服務
[root@centos7 src]# systemctl start mysqld.service
查看Mysql5.7默認密碼
[root@centos7 src]# grep 'temporary password' /var/log/mysqld.log
k-Lo1whpOt/!
tips
報錯1:SQLSTATE[HY000] [2002] No such file or directory
解決:? config文件中的??? ‘DB_HOST’ => 'localhost'???? 改成????? '127.0.0.1'
報錯2:? _STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/User/........
解決:? 找到runtime位置? chmod?-R?777 runtime
安裝pdo_mysql
find / -name pdo_mysql
cd /usr/local/src/php-7.1.10/ext/pdo_mysql
執行 :/usr/local/php/bin/phpize (若不是該路徑,也可以查找 find / -name phpize)
報錯:Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.
執行:yum install m4yum install autoconf
再次/usr/local/php/bin/phpize正確
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd /usr/local/php/lib/php/extensions/no-debug-zts-20160303
會出現pdo_mysql.so
打開PHP.ini
添加 extension="/usr/local/php/lib/php/extensions/no-debug-zts-20160303/pdo_mysql.so"
重啟PHP-fpm
其他
*grep 'temporary password' /var/log/mysqld.log 查看臨時密碼
mysql -uroot -p
修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';
三、安裝PHP7
下載安裝包并解壓
[root@centos7 nginx-1.12.1]# cd /usr/local/src
[root@centos7 src]# wget -O php-7.2.6.tar.gz http://cn2.php.net/get/php-7.2.6.tar.gz/from/this/mirror
[root@centos7 src]# tar -zxvf php-7.2.6.tar.gz
安裝必要的相關擴展
[root@centos7src]# yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
編譯安裝
[root@localhost src]# cd php-7.2.6
# 輸入以下參數
./configure --prefix=/usr/local/php \--with-openssl \--with-pcre-regex \--with-kerberos \--with-libdir=lib \--with-libxml-dir \--with-mysqli=shared,mysqlnd \--with-pdo-mysql=shared,mysqlnd \--with-pdo-sqlite \--with-gd \--with-iconv \--with-zlib \--with-xmlrpc \--with-xsl \--with-pear \--with-gettext \--with-curl \--with-png-dir \--with-jpeg-dir \--with-freetype-dir \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-mysqlnd \--enable-zip \--enable-inline-optimization \--enable-shared \--enable-libxml \--enable-xml \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--enable-pcntl \--enable-sockets \--enable-soap \--enable-session \--enable-opcache \--enable-fpm \--enable-maintainer-zts \--enable-fileinfo
開始安裝
[root@localhost php-7.2.6]# make && make install
配制php.ini
[root@centos7 php-7.2.6]# cp php.ini-production /usr/local/php/etc/php.ini
或cp php.ini-production /usr/local/php/lib/php.ini
[root@centos7 php-7.2.6]# vi /usr/local/php/etc/php.ini
# 做以下修改(時區,不顯示版本號,開啟opcache緩存加速PHP)#
找到:;date.timezone=? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 修改為:date.timezone= PRC.
找到:expose_php= On? ? ? ? ? ? ? ? ? ? ? ? ? ? 修改為:expose_php= Off.
找到:opcache.enable=0????????????????????????? 修改為:opcache.enable=1.
在 Dynamic Extensions 代碼塊中添加zend_extension=opcache.so
配置php-fpm
[root@centos7 php-7.2.6]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@centos7 php-7.2.6]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@centos7 php-7.2.6]# cp /usr/local/src/php-7.2.6/sapi/fpm/init.d.php-fpm /usr/local/php/bin/php-fpm
[root@centos7 php-7.2.6]# chmod 777 /usr/local/php/bin/php-fpm
嘗試啟動
[root@centos7php-7.2.6]# /usr/local/php/bin/php-fpm start
# 如提示''Starting php-fpm? done''即表示安裝成功
# ERROR: [pool www] cannot get uid for user 'www'
????? vi /usr/local/php/etc/php-fpm.d/www.conf 改成www www
編寫快捷啟動腳本
[root@centos7 php-7.2.6]# vi /lib/systemd/system/php-fpm.service
輸入以下代碼
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/bin/php-fpm start
ExecReload=/usr/local/php/bin/php-fpm restart
ExecStop=/usr/local/php/bin/php-fpm stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
設置開機啟動
[root@centos7 php-7.2.6]# systemctl enable php-fpm.service
其它命令說明
# 啟動php-fpm
[root@centos7 php-7.2.6]# systemctl start php-fpm.service
# 停止php-fpm
[root@centos7 php-7.2.6]# systemctl stop php-fpm.service
# 重啟php-fpm
[root@centos7 php-7.2.6]# systemctl restart php-fpm.service
# 如果提示:Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details.
# 請選結束php-fpm進程后再嘗試執行上面的快捷操作
[root@centos7 php-7.2.6]# pkill -9 php-fpm
# php加入環境變量
[root@centos7 php-7.2.6]#PATH=$PATH:/usr/local/php/bin
[root@centos7 php-7.2.6]#export $PATH
[root@centos7 php-7.2.6]#source /etc/profile
echo PATH=$PATH:/usr/local/php/bin/:/root/.composer/vendor/bin >> /etc/profile
# 查看引用php.ini路徑
php -i |grep php.ini
NGINX虛擬主機配制
打開配制文件
[root@centos7 php-7.2.6]# vi /usr/local/nginx/conf/nginx.conf
在http{}節點尾加入以下代碼
server {
? ? ? ? listen? ? ? ? ? 80;
? ? ? ? server_name? ? *.demo.com;
? ? ? ? root? ? ? ? ? ? /data/web/demo/www;
? ? ? ? access_log? ? ? /data/web/demo/log/access.log? main;
? ? ? ? error_log? ? ? /data/web/demo/log/error.log error;
? ? ? ? index? ? ? ? ? index.php;
? ? ? ? #THINKPHP偽靜態
? ? ? ? location / {
? ? ? ? ? ? if (!-e $request_filename) {
? ? ? ? ? ? ? ? rewrite ^(.*)$ /index.php?s=$1 last;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? #解析PHP代碼
? ? ? ? location ~ \.php$ {
? ? ? ? ? ? fastcgi_pass? 127.0.0.1:9000;
? ? ? ? ? ? fastcgi_index? index.php;
? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME $document_root$fastcgi_script_name;
? ? ? ? ? ? include? ? ? ? fastcgi_params;
? ? ? ? }
? ? ? ? #靜態資源緩存1天
? ? ? ? location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|js|css)$ {
? ? ? ? ? ? expires? ? 1d;
? ? ? ? ? ? access_log? off;
? ? ? ? }
? ? ? ? #字體文件跨域問題
? ? ? ? location ~ .*\.(eof|ttf|ttc|otf|eof|woff|woff2|svg)(.*){
? ? ? ? ? ? add_header Access-Control-Allow-Origin *;
? ? ? ? }
? ? }
GIT
安裝了git 記得設置git密碼
passwd git
設置鉤子post-receive
設置鉤子指向的web目錄 777