標籤:sed php程式 sha support mat params 啟動指令碼 c++ adb
關閉防火牆
[[email protected] ~]# systemctl stop firewalld[[email protected] ~]# systemctl disable firewalld[[email protected] ~]# sed -ri ‘s/(SELINUX=).*/\1disabled/g‘ /etc/selinux/config[[email protected] ~]# setenforce 0
配置安裝163的源
[[email protected] ~]# cd /etc/yum.repos.d///建立備份目錄[[email protected] yum.repos.d]# mkdir /etc/repo-bf//將原yum倉庫的檔案備份到repo-bf[[email protected] yum.repos.d]# mv * /etc/repo-bf//下載163的源到yum倉庫[[email protected] yum.repos.d]# curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo//將改為版本的7[[email protected] yum.repos.d]# sed -i ‘s/\$releasever/7/g‘ /etc/yum.repos.d/163.repo[[email protected] yum.repos.d]# sed -i ‘s/enabled=0/enabled=1/g‘ /etc/yum.repos.d/163.repo//自動設定yum的軟體倉庫,也可以自己配置[[email protected] yum.repos.d]# yum -y install epel-release[[email protected] yum.repos.d]# yum clean all//安裝編譯環境[[email protected] yum.repos.d]# yum -y install gcc gcc-c++[[email protected] yum.repos.d]# yum -y install wget
安裝依賴包
//建立使用者[[email protected] ~]# useradd -r -M -s /sbin/nologin nginx //安裝編譯環境[[email protected] ~]# yum -y groups list[[email protected] ~]# yum -y install pcre-devel openssl openssl-devel gd-devel
檔案中的包,如果如果在xshell中無法下載,可以先下載然後傳入
//建立日誌存放目錄[[email protected] ~]# mkdir -p /var/log/nginx [[email protected] ~]# chown -R nginx.nginx /var/log/nginx //下載nginx,編譯安裝[[email protected] ~]# cd /usr/src/[[email protected] src]# wget http://64.123.28.133/files/21490000000827F6/nginx.org/download/nginx-1.14.0.tar.gz[[email protected] src]# tar xf nginx-1.14.0.tar.gz [[email protected] src]# cd nginx-1.14.0[[email protected] nginx-1.14.0]# yum -y install gcc gcc-c++[[email protected] nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log[[email protected] nginx-1.14.0]# make -j 4 && make install
//設定環境變數
[[email protected] nginx-1.14.0]# echo ‘export PATH=/usr/local/nginx/sbin:$PATH‘ > /etc/profile.d/nginx.sh[[email protected] nginx-1.14.0]# . /etc/profile.d/nginx.sh//啟動[[email protected] nginx-1.14.0]# nginx
2.安裝mysql
//安裝依賴包[[email protected] ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel建立使用者和組[[email protected] ~]# groupadd -r -g 306 mysql[[email protected] ~]# useradd -M -s /sbin/nologin -g 306 -u 306 mysql
下載二進位格式的mysql軟體包
[[email protected] ~]# cd /usr/src/[[email protected] src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz解壓軟體至/usr/local/[[email protected] ~]# cd /usr/src/[[email protected] src]# lsdebug kernels mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz nginx-1.14.0 nginx-1.14.0.tar.gz[[email protected] src]# tar xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/[[email protected] src]# ls /usr/local/bin etc games include lib lib64 libexec mysql-5.7.22-linux-glibc2.12-x86_64 nginx sbin share src[[email protected] src]# cd /usr/local/[[email protected] local]# ln -sv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql"mysql" -> "mysql-5.7.22-linux-glibc2.12-x86_64/"//修改屬主[[email protected] local]# chown -R mysql.mysql /usr/local/mysql[[email protected] local]# ll /usr/local/mysql -dlrwxrwxrwx. 1 mysql mysql 36 8月 24 16:13 /usr/local/mysql -> mysql-5.7.22-linux-glibc2.12-x86_64///設定環境變數[[email protected] local]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ > /etc/profile.d/mysql.sh[[email protected] local]# . /etc/profile.d/mysql.sh[[email protected] local]# echo $PATH/usr/local/mysql/bin:/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin//建立資料存放目錄[[email protected] local]# cd /usr/local/mysql[[email protected] mysql]# mkdir /opt/data[[email protected] mysql]# chown -R mysql.mysql /opt/data///初始化資料庫,最後產生的是一個臨時密碼[[email protected] mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/2018-08-24T08:20:10.891585Z 1 [Note] A temporary password is generated for [email protected]: nEU8fScMEm(M
配置mysql
[[email protected] mysql]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql"/usr/local/include/mysql" -> "/usr/local/mysql/include/"[[email protected] mysql]# echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf[[email protected] mysql]# ldconfig -v
//組建組態檔案[[email protected] ~]# cat > /etc/my.cnf <<EOF[mysqld]basedir = /usr/local/mysqldatadir = /opt/datasocket = /tmp/mysql.sockport = 3306pid-file = /opt/data/mysql.piduser = mysqlskip-name-resolveEOF
配置啟動指令碼
[[email protected] mysql]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql]# sed -ri ‘s#^(basedir=).*#\1/usr/local/mysql#g‘ /etc/init.d/mysqld[[email protected] mysql]# sed -ri ‘s#^(datadir=).*#\1/opt/data#g‘ /etc/init.d/mysqld
啟動mysql
[[email protected] mysql]# service mysqld startStarting MySQL.Logging to ‘/opt/data/localhost.localdomain.err‘.SUCCESS![[email protected] mysql]# ps -ef|grep mysqlroot 24348 1 0 16:25 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pidmysql 24526 24348 2 16:25 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306root 24556 2316 0 16:25 pts/0 00:00:00 grep --color=auto mysql
[[email protected] mysql]# ss -antl
修改臨時密碼
[[email protected] mysql]# mysql -uroot -pEnter password:mysql> set password = password(‘guohui123‘);Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> quit
安裝PHP
//安裝依賴包
[[email protected] ~]# yum -y install bzip2-devel curl-devel freetype-devel gcc libjpeg-devel libpng-devel libxslt-devel libxml2-devel openssl-devel pcre-devel pcre-devel zlib-devel//下載[[email protected] ~]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz[[email protected] ~]# tar xf php-7.2.8.tar.xz[[email protected] ~]# cd php-7.2.8//配置安裝變數,“/usr/local/php”是安裝路徑,可以改成自己喜歡的安裝路徑。[[email protected] php-7.2.8]#./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip//編譯源碼,在解壓目錄執行編譯命令:make[[email protected] php-7.2.8]# make//安裝php[[email protected] php-7.2.8]# make install
//配置PHP將PHP源碼包(/root/php-7.2.8)中的php.ini-development檔案複製到/usr/local/php/下,更名為php.ini源碼包在root下下載,所以在root下[[email protected] php-7.2.8]# cp /root/php-7.2.8/php.ini-development /usr/local/php/php.ini[[email protected] php-7.2.8]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf[[email protected] php-7.2.8]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf配置php.ini “cgi.fix_pathinfo=0”
[[email protected] php-7.2.8]# vim /usr/local/php/php.inicgi.fix_pathinfo=0啟動php-fpm服務:啟動完畢之後,php-fpm服務預設使用9000連接埠
[[email protected] php-7.2.8]# /usr/local/php/sbin/php-fpm[[email protected] php-7.2.8]# ss -anltLISTEN 0 128 127.0.0.1:9000 *:*
最後配置nginx編輯nginx設定檔/usr/local/nginx/conf/nginx.conf ,主要修改nginx的server,{}配置塊中的內容,修改location塊,追加index.php讓nginx伺服器預設支援index.php為首頁:(在尾部追加了index.php)2.更換為下方內容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;}
編輯更改
[[email protected] php-7.2.8]# vim /usr/local/nginx/conf/nginx.conf1.index index.html index.htm; 更改成 index index.html index.htm index.php; 2.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;}
//這裡面很多都是預設的,root是配置PHP程式放置的根目錄,主要修改的就是fastcgi_param中的/scripts為$document_root
修改完成這些儲存並退出,然後重啟nginx:/usr/local/nginx/sbin/nginx -s reload
接下來編輯一個測試的php程式,在nginx下的html目錄下建立test.php檔案,列印一下php配置:[[email protected] ~]# cd /usr/local/nginx/html[[email protected] html]# touch test.php<?php phpinfo();?>
然後開啟瀏覽器輸入對應的地址進行訪問
http://192.168.56.11/test.php
LINUX——lnmp架構的搭建,與lamp架構類似