
2017年12月25日
一、準備
正式開始前,編譯環境gcc、g++等開發庫需要提前安裝。
nginx依賴以下模塊:
gzip模塊需要 zlib 庫
rewrite模塊需要 pcre 庫
ssl 功能需要openssl庫
源碼目錄為:/usr/local/src
1、安裝make
yum -y install gcc automake autoconf libtool make
2、安裝g++
yum install gcc gcc-c++
3、安裝PCRE庫
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz
tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42/
./configure
make && make install
出現如下報錯:
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory `/usr/local/src/pcre-8.42'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/usr/local/src/pcre-8.42'
make: *** [install] Error 2
權限不夠,切換到root,重新make install即可。
4、安裝zlib庫
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure
make && make install
5、安裝OpenSSL庫
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar -zxvf openssl-fips-2.0.16.tar.gz
cd openssl-fips-2.0.16/
./config
make && make install
編譯安裝 Openssl 1.1.1 支持國密標準
https://blog.51cto.com/1012682/2380553
6、創建用戶及用戶組
一般為了服務器安全,會指定一個普通用戶權限的賬號做為Nginx的運行角色,這里使用www用戶做為Nginx工作進程的用戶。后續安裝的PHP也以www用戶作為工作進程用戶。
groupadd -r www
useradd -r -g www www
二、NGINX
1、下載
cd /usr/local/src
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar –zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
2、配置
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi
make && make install
nginx編譯選項說明:
--prefix表示nginx要安裝到哪個路徑下,這里指定剛才新建好的/alidata/server目錄下的nginx-1.12.2;
--sbin-path表示nginx的可執行文件存放路徑
--conf-path表示nginx的主配置文件存放路徑,nginx允許使用不同的配置文件啟動,通過命令行中的-c選項
--pid-path表示nginx.pid文件的存放路徑,將存儲的主進程的進程號。安裝完成后,可以隨時改變的文件名 , 在nginx.conf配置文件中使用 PID指令。默認情況下,文件名 為prefix/logs/nginx.pid
--error-log-path表示nginx的主錯誤、警告、和診斷文件存放路徑
--http-log-path表示nginx的主請求的HTTP服務器的日志文件的存放路徑
--user表示nginx工作進程的用戶
--group表示nginx工作進程的用戶組
--with-select_module或--without-select_module表示啟用或禁用構建一個模塊來允許服務器使用select()方法
--with-poll_module或--without-poll_module表示啟用或禁用構建一個模塊來允許服務器使用poll()方法
--with-http_ssl_module表示使用https協議模塊。默認情況下,該模塊沒有被構建。建立并運行此模塊的OpenSSL庫是必需的
--with-pcre表示pcre的源碼路徑,因為解壓后的pcre是放在root目錄下的,所以是/root/pcre-8.41;
--with-zlib表示zlib的源碼路徑,這里因為解壓后的zlib是放在root目錄下的,所以是/root/zlib-1.2.11
--with-openssl表示openssl庫的源碼路徑
配置OK:
Configuration summary
+ using PCRE library: /usr/local/src/pcre-8.42
+ using OpenSSL library: /usr/local/src/openssl-1.1.0h
+ using zlib library: /usr/local/src/zlib-1.2.11
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx"
nginx configuration file: "/usr/local/nginx/nginx.conf"
nginx pid file: "/usr/local/nginx/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "/var/tmp/nginx/client/"
nginx http proxy temporary files: "/var/tmp/nginx/proxy/"
nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi/"
nginx http uwsgi temporary files: "/var/tmp/nginx/uwsgi"
nginx http scgi temporary files: "/var/tmp/nginx/scgi"
3、安裝
make && make install
4、啟動
/usr/local/nginx/sbin/nginx
啟動時報錯:
nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
手動創建該目錄即可:mkdir -p /var/tmp/nginx/client
再次啟動,打開瀏覽器訪問此機器的IP,瀏覽器出現Welcome to nginx! 則表示 Nginx 已經安裝并運行成功。
5、設置軟連接
ln -sf /usr/local/nginx/sbin/nginx /usr/sbin
這樣就可以直接執行nginx來啟動了。
6、檢測nginx
nginx -t
顯示:
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
三、PHP
1、安裝PHP需要的常用庫
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
2、下載
cd /usr/local/src
wget http://cn2.php.net/downloads.php/php-7.2.5.tar.gz
tar -zxvf php-7.2.5.tar.gz
3、配置
./configure --prefix=/usr/local/php \
--with-mysql=mysqlnd \
--enable-mysqlnd \
--with-gd \
--enable-gd-jis-conv \
--enable-fpm
4、安裝
make && make install
安裝信息如下:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP FPM binary: /usr/local/php/sbin/
Installing PHP FPM defconfig: /usr/local/php/etc/
Installing PHP FPM man page: /usr/local/php/php/man/man8/
Installing PHP FPM status page: /usr/local/php/php/php/fpm/
Installing phpdbg binary: /usr/local/php/bin/
Installing phpdbg man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar: upgrade to a newer version (1.4.3 is not newer than 1.4.3)
[PEAR] Console_Getopt: upgrade to a newer version (1.4.1 is not newer than 1.4.1)
[PEAR] Structures_Graph: upgrade to a newer version (1.1.1 is not newer than 1.1.1)
[PEAR] XML_Util: upgrade to a newer version (1.4.2 is not newer than 1.4.2)
[PEAR] PEAR: upgrade to a newer version (1.10.5 is not newer than 1.10.5)
/usr/local/src/php-7.2.5/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
5、添加環境變量
vim /etc/profile
在末尾加入
export PHP_HOME=/usr/local/php
export PATH=/bin:/usr/bin:/usr/sbin:/sbin:$PATH:PHP_HOME/bin:$PHP_HOME/sbin
保存修改后,使用source命令重新加載配置文件:
source /etc/profile
查看環境變量:
echo $PATH
6、配置php-fpm
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf
使用vim命令對php-fpm.conf的內容進行如下修改:
pid = /usr/local/php/var/run/php-fpm.pid
使用vim命令對php-fpm.conf的內容進行如下修改:
user = www
group = www
其他配置可根據需求進行修改,比如pm.max_children(php-fpm 能啟動的子進程的最大數量)、pm.start_servers(php啟動時,開啟的子進程的數量)、pm.min_spare_servers(動態方式空閑狀態下的最小php-fpm進程數量)、pm.max_spare_servers(動態方式空閑狀態下的最大php-fpm進程數量)等。
7、啟動php-fpm
/usr/local/php/sbin/php-fpm
可以通過ps aux | grep php查看php進程。
https://www.cnblogs.com/sunshineliulu/p/8991957.html
三、MySQL
https://blog.csdn.net/weixin_33859844/article/details/90948191
https://www.cnblogs.com/yangchunlong/p/8477743.html
posted @
2019-08-13 17:37 Alpha 閱讀(398) |
評論 (0) |
編輯 收藏
一、安裝git服務器所需軟件
打開終端輸入以下命令:
ubuntu:~$ sudo apt-get install git-core openssh-server openssh-client
git-core是git版本控制核心軟件
安裝openssh-server和openssh-client是由于git需要通過ssh協議來在服務器與客戶端之間傳輸文件
然后中間有個確認操作,輸入Y后等待系統自動從鏡像服務器中下載軟件安裝,安裝完后會回到用戶當前目錄。如果
安裝提示失敗,可能是因為系統軟件庫的索引文件太舊了,先更新一下就可以了,更新命令如下:
ubuntu:~$ sudo apt-get update
更新完軟件庫索引后繼續執行上面的安裝命令即可。
安裝python的setuptools和gitosis,由于gitosis的安裝需要依賴于python的一些工具,所以我們需要先安裝python
的setuptools。
執行下面的命令:
ubuntu:~$ sudo apt-get install python-setuptools
這個工具比較小,安裝也比較快,接下來準備安裝gitosis,安裝gitosis之前需要初始化一下服務器的git用戶信息,這個隨便填。
ubuntu:~$ git config --global user.name "myname"
ubuntu:~$ git config --global user.email "******@gmail.com"
初始化服務器用戶信息后,就可以安裝gitosis了,gitosis主要是用于給用戶授權,設置權限也算是很方便的。
可以通過以下命令獲取gitosis版本文件
ubuntu:~$ git clone https://github.com/res0nat0r/gitosis.git
注意:中間有兩個是數字零
獲取gitosis文件后,進入到文件目錄下面
ubuntu:/tmp$ cd gitosis/
接著使用python命令安裝目錄下的setup.py的python腳本進行安裝
ubuntu:/tmp/gitosis$ sudo python setup.py install
到這里,整個安裝步驟就完成了,下面就開始對git進行一些基本的配置。
二、創建git管理員賬戶、配置git
創建一個賬戶(git)作為git服務器的管理員,可以管理其他用戶的項目權限。
ubuntu:/tmp/gitosis$ sudo useradd -m git
ubuntu:/tmp/gitosis$ sudo passwd git
然后再/home目錄下創建一個項目倉庫存儲點,并設置只有git用戶擁有所有權限,其他用戶沒有任何權限。
ubuntu:/tmp/gitosis$ sudo mkdir /home/gitrepository
ubuntu:/tmp/gitosis$ sudo chown git:git /home/gitrepository/
ubuntu:/tmp/gitosis$ sudo chmod 700 /home/gitrepository/
由于gitosis默認狀態下會將倉庫放在用戶的repositories目錄下,例如git用戶的倉庫地址默認在/home/git/repositories/目錄下,這里我們需要創建一個鏈接映射。讓他指向我們前面創建的專門用于存放項目的倉庫目錄/home/gitrepository。
ubuntu:/tmp/gitosis$ sudo ln -s /home/gitrepository /home/git/repositories
這里我將在服務器端生成ssh公鑰,如果想在其他機器上管理也可以在其他機器上生成一個ssh的公鑰。
ubuntu:/home/git$ ssh-keygen -t rsa
這里會提示輸入密碼,我們不輸入直接回車即可。
然后用剛生成公鑰id_rsa.pub來對gitosis進行初始化。
向gitosis添加公鑰并初始化:
$ cp ~/.ssh/id_rsa.pub /tmp
$ sudo -H -u gitadmin gitosis-init < /tmp/id_rsa.pub

出現如上信息說明gitosis已經初始化成功。
gitosis主要是通過gitosis-admin.git倉庫來管理一些配置文件的,如用戶權限的管理。這里我們需要對其中的一個post-update文件添加可執行的權限。
ubuntu:/home/git$ sudo chmod 755 /home/gitrepository/gitosis-admin.git/hooks/post-update
三、服務器上創建項目倉庫
使用git賬戶在服務器上創建一個目錄(mytestproject.git)并初始化成git項目倉庫。
ubuntu:/home/git$ su git
$ cd /home/gitrepository
$ mkdir mytestproject.git
$ git init --bare mytestproject.git
$ exit
如果出現以下信息就說明已經成功創建了一個名為mytestproject.git的項目倉庫了,新建的這個倉庫暫時還是空的,不能被客戶端clone,還需要對gitosis進行一些配置操作。
四、使用gitosis管理用戶操作項目的權限
首先需要在前面生成ssh公鑰(用來初始化gitosis)的機器上將gitosis-admin.git的倉庫clone下來。
在客戶端機器上新建一個目錄用于存放gitosis-admin.git倉庫
ubuntu:~$ mkdir gitadmin
ubuntu:~$ cd gitadmin/
ubuntu:~/gitadmin$ git clone git@192.168.1.106:gitosis-admin.git
clone正確會顯示以下信息

clone下來會有一個gitosis.conf的配置文件和一個keydir的目錄。gitosis.conf用于配置用戶的權限信息,keydir主要用戶存放ssh公鑰文件(一般以“用戶名.pub”命名,gitosis.conf配置文件中需使用相同用戶名),用于認證請求的客戶端機器。
現在讓需要授權的用戶使用前面的方式各自在其自己的機器上生成相應的ssh公鑰文件,管理員把他們分別按用戶名命名好,復制到keydir目錄下。
ubuntu:~$ cp /home/aaaaa/Desktop/zhangsan.pub /home/aaaaa/gitadmin/gitosis-admin/keydir/
ubuntu:~$ cp /home/aaaaa/Desktop/lisi.pub /home/aaaaa/gitadmin/gitosis-admin/keydir/
繼續編輯gitosis.conf文件
[gitosis]
[group gitosis-admin]
####管理員組
members = charn@ubuntu
####管理員用戶名,需要在keydir目錄下找到相應的.pub文件,多個可用空格隔開(下同)
writable = gitosis-admin####可寫的項目倉庫名,多個可用空格隔開(下同)
[group testwrite]
####可寫權限組
members = zhangsan####組用戶
writable = mytestproject####可寫的項目倉庫名
[group
testread] ####只讀權限組
members =lisi####組用戶
readonly= mytestproject####只讀項目倉庫名
因為這些配置的修改只是在本地修改的,還需要推送到服務器中才能生效。
ubuntu:~/gitadmin/gitosis-admin$ git add .
ubuntu:~/gitadmin/gitosis-admin$ git commit -am "add a user permission"
ubuntu:~/gitadmin/gitosis-admin$ git push origin master
推送成功會顯示下面提示信息

又是后新增的用戶不能立即生效,這時候需要重新啟動一下sshd服務
ubuntu:~/gitadmin/gitosis-admin$ sudo /etc/init.d/ssh restart
現在,服務端的git就已經安裝和配置完成了,接下來就需要有權限的組成員在各自的機器上clone服務器上的相應
項目倉庫進行相應的工作了。
五、客戶端(windows)使用git
下載安裝windows版本的git客戶端軟件,下載地址:http://msysgit.github.io/
安裝完成后右鍵菜單會出現幾個git相關的菜單選項,我們主要使用其中的git
bash通過命令行來進行操作。
在本地新建一個目錄,使用git初始化這個目錄,然后再里面新建一個文本文件用于測試,最后關聯到git服務器倉庫
中的相關項目,最后上傳本地版本到服務器。
$ mkdir testgit
$ cd testgit
$ git init
$ echo "this is a test text file,will push to server" > hello.txt
$ git add .
$ git commit -am "init a base version,add a first file for push to server"
$ git remote add origin git@serverip:mytestproject.git
$ git push origin master
這樣服務端就創建好了一個mytestproject.git的倉庫的基礎版本了,現在其他組員只要從服務端進行clone就可以了。
window下面進入到需要克隆的本地目錄下面右鍵選擇git bash選項,輸入
$ git clone git@serverip:mytestproject.git
就可以把項目clone到本地倉庫了。
下面進行簡單的修改和提交操作
$ cd mytestproject
$ echo "this is another text file created by other" >another.txt
$ git add .
$ git commit -am "add a another file by other"
$ git push origin master
最后推送到服務器成功會顯示如下信息

gitolite搭建git倉庫(服務端+客戶端)
http://blog.csdn.net/ChiChengIT/article/details/49863383
posted @
2018-03-13 15:35 Alpha 閱讀(1199) |
評論 (0) |
編輯 收藏
摘要: Git 教程http://www.runoob.com/git/git-tutorial.htmlGit本地服務器搭建及使用Git是一款免費、開源的分布式版本控制系統。眾所周知的Github便是基于Git的開源代碼庫以及版本控制系統,由于其遠程托管服務僅對開源免費,所以搭建本地Git服務器也是個較好的選擇,本文將對此進行詳細講解。(推薦一家提供私有源代碼免費托管的網站:Bitbucket,目前支持...
閱讀全文
posted @
2018-03-08 10:44 Alpha 閱讀(3245) |
評論 (0) |
編輯 收藏
1.查看內存 free
2.查看cpu cat cpuinfo
3.查看磁盤 fdisk -l
4.查看帶寬 iptraf-ng
5.查看負載 top
6.查看請求數 netstat -anp | wc -l
7.查看請求詳情 netstat -anp
8.查看某個程序請求數 netstat -anp | grep php |wc -l
9.查看磁盤使用情況 df -h
10.查看系統日志 dmesg
11.查看進程數量 ps aux | wc -l
12.查看運行網絡程序 ps auxww | more
13.查看php運行程序 ps auxww | grep php
14.查看php運行程序數量 ps auxww | grep php | wc -l
15.查看init.d運行 ls -al /etc/init.d/
16.查找文件路徑 find / -name php.ini
17.查看mysql端口 netstat -anp | grep 3306
18.查看本機ip地址 ip add
19.查找某個字符串在文件中出現的 grep 127.0.0.1:9000 *.conf
20.
posted @
2017-12-25 10:16 Alpha 閱讀(627) |
評論 (0) |
編輯 收藏