從零開始在阿里雲上搭建伺服器(CentOS 6.8系統)
一.登陸後建立一個新使用者(例如 mirror)
useradd mirror
passwd mirror
輸入兩次密碼
二.安裝圖形介面:
yum groupinstall "Desktop" "X Window System" "Chinese Support" "Internet Browser" "Fonts"
vi /etc/inittab
將3改成5
reboot
用mirror登陸
三.配置LNMP環境
1.基礎設定:
1)關閉SELINUX
修改配置檔案,重啟服務後永久生效。
#
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
命令列設定立即生效。
# setenforce 0
2)安全組設定
在ECS安全組放行需訪問的埠和訪問白名單,下面的示例表示允許所有IP訪問伺服器的80埠。您可以根據實際情況放行允許訪問的客戶端IP。
2.安裝nginx
1)新增執行nginx服務程序的使用者
- # groupadd -r nginx
- # useradd -r -g nginx nginx
2)下載原始碼包解壓編譯。
- # wget http://nginx.org/download/nginx-1.10.2.tar.gz
- # tar xvf nginx-1.10.2.tar.gz -C /usr/local/src
- # yum groupinstall "Development tools"
- # yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel
- # cd /usr/local/src/nginx-1.10.2
- # ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --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 --user=nginx --group=nginx --with-pcre --with-http_v2_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-threads --with-stream --with-stream_ssl_module
- # make && make install
- # mkdir -pv /var/tmp/nginx/client
3)新增SysV啟動指令碼。
- # vim /etc/init.d/nginx
- #!/bin/sh
- #
- # nginx - this script starts and stops the nginx daemon
- #
- # chkconfig: - 85 15
- # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
- # proxy and IMAP/POP3 proxy server
- # processname: nginx
- # config: /etc/nginx/nginx.conf
- # config: /etc/sysconfig/nginx
- # pidfile: /var/run/nginx.pid
- # Source function library.
- ./etc/rc.d/init.d/functions
- # Source networking configuration.
- ./etc/sysconfig/network
- # Check that networking is up.
- ["$NETWORKING"="no"]&& exit 0
- nginx="/usr/sbin/nginx"
- prog=$(basename $nginx)
- NGINX_CONF_FILE="/etc/nginx/nginx.conf"
- [-f /etc/sysconfig/nginx ]&&./etc/sysconfig/nginx
- lockfile=/var/lock/subsys/nginx
- start(){
- [-x $nginx ]|| exit 5
- [-f $NGINX_CONF_FILE ]|| exit 6
- echo -n $"Starting $prog: "
- daemon $nginx -c $NGINX_CONF_FILE
- retval=$?
- echo
- [ $retval -eq 0]&& touch $lockfile
- return $retval
- }
- stop(){
- echo -n $"Stopping $prog: "
- killproc $prog -QUIT
- retval=$?
- echo
- [ $retval -eq 0]&& rm -f $lockfile
- return $retval
- killall -9 nginx
- }
- restart(){
- configtest ||return $?
- stop
- sleep 1
- start
- }
- reload(){
- configtest ||return $?
- echo -n $"Reloading $prog: "
- killproc $nginx -HUP
- RETVAL=$?
- echo
- }
- force_reload(){
- restart
- }
- configtest(){
- $nginx -t -c $NGINX_CONF_FILE
- }
- rh_status(){
- status $prog
- }
- rh_status_q(){
- rh_status >/dev/null 2>&1
- }
- case"$1"in
- start)
- rh_status_q && exit 0
- $1
- ;;
- stop)
- rh_status_q || exit 0
- $1
- ;;
- restart|configtest)
- $1
- ;;
- reload)
- rh_status_q || exit 7
- $1
- ;;
- force-reload)
- force_reload
- ;;
- status)
- rh_status
- ;;
- condrestart|try-restart)
- rh_status_q || exit 0
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
- exit 2
- esac
4)賦予指令碼執行許可權。
# chmod +x /etc/init.d/nginx
5)新增至服務管理列表,設定開機自啟。
- # chkconfig --add nginx
- # chkconfig nginx on
6)啟動服務。
# service nginx start
7)瀏覽器訪問可看到預設歡迎頁面。
3.安裝mysql
1)準備編譯環境。
- # yum groupinstall "Server Platform Development" "Development tools" -y
- # yum install cmake -y
2)準備mysql資料存放目錄。
- # mkdir /mnt/data
- # groupadd -r mysql
- # useradd -r -g mysql -s /sbin/nologin mysql
- # id mysql
3)更改資料目錄屬主屬組。
# chown -R mysql:mysql /mnt/data
4)解壓編譯在MySQL官網下載的穩定版原始碼包
wget -c https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18.tar.gz
不要感覺奇怪,其實是記憶體不夠導致的,這位兄弟也遇到一樣的問題,如下:
在這裡特別提醒, 對於mysql5.7.8的make編譯, 如果是阿里雲centos主機512M記憶體的, 會在make編譯到45%時會報錯, 這是記憶體不足所致。
c++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 1
make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
make: *** [all] Error 2
那麼設定2G交換分割槽來用下 :
# dd if=/dev/zero of=/swapfile bs=1k count=2048000 --獲取要增加的2G的SWAP檔案塊
# mkswap /swapfile -- 建立SWAP檔案
# swapon /swapfile -- 啟用SWAP檔案
# swapon -s -- 檢視SWAP資訊是否正確
# echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab -- 新增到fstab檔案中讓系統引導時自動啟動
注意, swapfile檔案的路徑在/var/下
編譯完後, 如果不想要交換分割槽了, 可以刪除:
# swapoff /swapfile
# rm -fr /swapfile
- # tar xvf mysql-5.6.36.tar.gz -C /usr/local/src
- # cd /usr/local/src/mysql-5.6.36
- # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mnt/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
- # make && make install
5)修改安裝目錄的屬組為mysql。
# chown -R mysql:mysql /usr/local/mysql/
6)初始化資料庫。
# cd /usr/local/mysql/
# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/mnt/data/
#
cd /usr/local/src/mysql-5.6.36
注:在CentOS 6.8版作業系統的最小安裝完成後,在/etc目錄下會存在一個my.cnf,需要將此檔案更名為其他的名字,如:/etc/my.cnf.bak,否則,該檔案會干擾原始碼安裝的MySQL的正確配置,造成無法啟動。
7、拷貝配置檔案和啟動指令碼。
- # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- # chmod +x /etc/init.d/mysqld
- # cp support-files/my-default.cnf /etc/my.cnf
8)設定開機自動啟動。
- # chkconfig mysqld on
- # chkconfig --add mysqld
9)修改配置檔案中的安裝路徑及資料目錄存放路徑。
# echo -e "basedir = /usr/local/mysql\ndatadir = /mnt/data\n" >> /etc/my.cnf
10)設定PATH環境變數。
- # echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh
- # source /etc/profile.d/mysql.sh
11)啟動服務。
-
# service mysqld start
-
# mysql -h 127.0.0.1
4.安裝php
1)安裝依賴包。
# yum install libmcrypt libmcrypt-devel mhash mhash-devel libxml2 libxml2-devel bzip2 bzip2-devel
2)解壓官網下載的原始碼包,編譯安裝。
# tar xvf php-5.6.23.tar.bz2 -C /usr/local/src
# cd /usr/local/src/php-5.6.23
# ./configure --prefix=/usr/local/php --with-config-file-scan-dir=/etc/php.d --with-config-file-path=/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-openssl -enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-bz2
- # make && make install
3)新增php和php-fpm配置檔案。
# cp /usr/local/src/php-5.6.23/php.ini-production /etc/php.ini
# cd /usr/local/php/etc/
# cp php-fpm.conf.default php-fpm.conf
# sed -i '[email protected];pid = run/[email protected] = /usr/local/php/var/run/[email protected]' php-fpm.conf
4)新增php-fpm啟動指令碼。
# cp /usr/local/src/php-5.6.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
5)新增php-fpm至服務列表並設定開機自啟。
# chkconfig --add php-fpm
# chkconfig --list php-fpm
# chkconfig php-fpm on
6)啟動服務。
#
service php-fpm start
7)新增nginx對fastcgi的支援,首先備份預設的配置檔案。
# cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
編輯/etc/nginx/nginx.conf,在所支援的主頁面格式中新增php格式的主頁,類似如下:
location /{
root /usr/local/nginx/html;
index index.php index.html index.htm;
}
取消以下內容前面的註釋:
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
重新載入nginx的配置檔案。
#
service nginx reload
在/usr/local/nginx/html/新建index.php的測試頁面,內容如下。
<?php
$conn=mysql_connect('127.0.0.1','root','');
if($conn){
echo "LNMP platform connect to mysql is successful!";
相關推薦
從零開始在阿里雲上搭建伺服器(CentOS 6.8系統)
一.登陸後建立一個新使用者(例如 mirror) useradd mirror passwd mirror 輸入兩次密碼 二.安裝圖形介面: yum groupinstall "Desktop" "X Window System" "Chinese Support" "I
從零開始,ubuntu上 搭建xilinx zynq linux 編譯環境
主機環境:ubuntu10.04 lts X64_64bit 編譯器:arm gnu tools for Xilinx 參考網址:http://wiki.xilinx.com/zynq-tools(這個網址的內容真的需要更新了) 詳細步驟:以下操作均在root使用者下
阿里雲上搭建RabbitMQ(1)
剛好有點閒錢,在雙十二上買了一個阿里雲伺服器,買完之後頓時就後悔了,發現騰訊雲比阿里雲更便宜,這是購買阿里雲的心得,下面開始安裝RabbitMQ了 -----------------------------------------------------------------
在阿里雲上安裝LAMP(centos6+Apache+Mysql+PHP)環境並上線Java Web專案
在雲伺服器上安裝好系統後: 1.先檢視系統上有無原有的舊版本的mysql;tomcat;java。 若有則先解除安裝;解除安裝命令使用 yum -y remove mysql*; yum -y remove mysql*; 2.附上能下載的jdk1.7的
簡述使用BIND配置本地DNS伺服器(centos 6.8)
DNS簡介: DNS,Domain Name System,域名系統,用於Internet上域名和IP地址的相互對映,使得使用者不用記憶主機IP地址,僅通過與之對應的域名就可以訪問該主機。 下面是本地dns伺服器搭建過程,環境-centos6.8,本地I
在阿里雲上搭建自己的git伺服器
這篇文章我就來介紹一下如何在一臺全裸的阿里雲主機上搭建自己的git伺服器。 1. 安裝git 首先安裝git,一般而言,現在的伺服器已經內建了git安裝包,我們只需要執行簡單的安裝命令即可安裝。比如: $ yum install git # centos $ apt-get install git #
阿里雲上搭建webRTC 伺服器——Licode
阿里雲上搭建webRTC 伺服器——Licode 系統配置 阿里雲伺服器 Ubuntu 14.04.5 LTS Docker 環境搭建 在一臺空的機器上搭建docker環境,先要安裝docker,執行下面的命令即可: apt-get update apt-get install docker.io
在阿里雲上搭建Git 伺服器
作業系統: CentOS 6.5 客戶端作業系統:Mac 1、安裝Git $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
[轉]從零開始:在Linux上覆蓋安裝WINDOWS通用教程(dd)
備份 虛擬 livecd tfs ocean syntax 文件夾 尋找 font 完整自制尚不方便,還有許多改進的地方.現在可以達到在單硬盤,無救援模式的情況下安裝Winodws.再也不需要強制要求內存大於鏡像包大小了. 本例所給的wget後鏈接均可用,教程是完整的. (
從零開始利用vue-cli搭建簡單音樂網站(一)
路徑 nod .com mman csdn desc blog -a where 最近在學習vue框架,練習了一些例子之後,想著搭建一個vue項目,了解到官方有提供一個vue-cli工具來搭建項目腳手架,嘗試了一下,寫下博客來記錄一下。 一、工具環境 1、node.js 6
從零開始系列之vue全家桶(4)帶新手小白一起搭建第一個個人網站項目
轉載 個人網站 rfi red nbsp oot ott osx 全部 未經允許,嚴禁轉載,全文由blackchaos提供。 在安裝好了前面大部分需要的插件,我們開始進行第一個個人項目。結合vue+vuex+vue-cli+vue-router+webpack使用。
[從零開始]在Jenkins上配置P4
log 圖片 isa http perf nbsp jenkin 管理 從零開始 P4+Jenkins 1. 安裝啟動jenkins (1) Jenkins下載地址:https://jenkins.io/download/ (2) 配置Jenkins工作空間 系統管
基於docker在阿里雲上搭建WordPress個人部落格
環境 centos7.4 安裝docker見https://blog.csdn.net/weixin_38280090/article/details/83590192 下載image docker pull wordpress:latest #下載wordpress在dockerh
從零開始使用vue-cli搭建一個vue專案及注意事項
一、安裝node.js 1.根據電腦的自行下載node.js安裝包http://nodejs.cn 2.點選安裝,按照正常的的一路點選下去 3.驗證安裝是否成功,按鍵win+r,輸入cmd開啟命令列工具,點選確認後再輸入node -v 出現版本好說明npm安裝成功
從零開始使用vue-cli搭建一個vue項目及註意事項
pack 註意 csharp and init 腳手架 project rect node.js安裝 一、安裝node.js 1.根據電腦的自行下載node.js安裝包http://nodejs.cn 2.點擊安裝,按照正常的的一路點擊下去 3.驗
在阿里雲上搭建DOCKER環境
前言 最近公司要為新專案搭建一套演示環境,服務比較多。所以準備用docker進行容器化部署。 安裝/升級Docker客戶端 使用yum進行安裝 # step 1: 安裝必要的一些系統工具 sudo yum install -y yum-utils devic
從零開始的Hadoop大資料叢集(偽)搭建,全免費VirtualBox虛擬機器Ubuntu版,學習向,超詳細---(一)
在公司工作了一段時間了,大資料平臺都是公司的運維人員搭建維護的,自己也想親自搭建一套,純粹為了學習和提高自己,也為了以後自己研究用。公司的環境不太適合亂來,自己的就可以隨意玩了。 寫這個也是為了記錄自己學習的過程,同時給大家提供一個參考,想要學習大資料的也
手把手教你如何從零開始在eclipse上搭起一個ssm(spring+springMVC+myBatis)框架
1.新建一個Maven專案 直接點選next: 選擇這個,這個是指javaWeb專案 輸入maven專案的座標 點選finish,建立專案完成 2.新增maven依賴並下載 找到剛建的maven專案下的pom.xml配置檔案,開啟: 接下來,在url和depe
從零開始學習--kafka叢集搭建的 兩種方式
目錄(第一種常規版,第二種bitnami版) 一、下載kafka安裝包 二、安裝 三、配置 四、執行 一、下載kafka安裝包 準備好kafka安裝包,官網下載地址: http://kafka.apache.org/do
從零開始hadoop分散式環境搭建
1. Linux虛機換機環境安裝 1.1 linux環境安裝 1.建議選擇虛擬機器:VirtualBox 2.Linux版本:Ubuntu 3.安裝時選擇動態擴充套件磁碟,最大磁碟容量50G(最大磁碟容量太小,hadoop使用過程中容易出現意想不到的