1. 程式人生 > >阿里雲CentOS伺服器環境搭建php+nginx+mysql+java+git+nodejs

阿里雲CentOS伺服器環境搭建php+nginx+mysql+java+git+nodejs

阿里雲CentOS伺服器環境搭建

CentOS 安裝php

1. 下載php 7.2.11

wget http://sg2.php.net/distributions/php-7.2.11.tar.gz

2. 解壓

tar -xzvf php-7.2.11.tar.gz

3. 進入原始碼目錄

cd php-7.2.11

4. 安裝相關依賴

yum install libxml2-devel
yum install openssl-devel
yum install curl-devel
yum install libpng-devel
yum install freetype-devel
yum install libxslt-devel

5.配置

./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-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip

6. 編譯安裝

make && make install

7. 將php加入PATH中

vi ~/.bash_profile
PATH=$PATH:/usr/local/php/bin:/usr/local/php/sbin
source .bash_profile

8. php.ini

cp php.ini-development /usr/local/php/lib/php.ini

9. php-fpm相關配置檔案

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

10. 啟動php-fpm

php-fpm

CentOS 安裝nginx

1. 下載原始碼

wget http://nginx.org/download/nginx-1.15.5.tar.gz

2. 解壓原始碼

tar -xzvf nginx-1.15.5.tar.gz

3. 進入原始碼目錄

cd nginx-1.15.5

4. 配置

./configure --prefix=/usr/local/nginx  --with-http_ssl_module

5. 編譯安裝

make && make install

6. 配置

vi /usr/local/nginx/conf/nginx.conf

location / {
        root   /var/www;
        index  index.php index.html index.htm;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        # try_files $uri $uri/ /index.php?$query_string; #laravel配置
}

7. 啟動nginx

nginx -s start

CentOS 安裝git

1. 安裝git

yum install git-core

CentOS 安裝mysql

1. 下載mysql 5.7.24

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

2. 安裝

rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-server

3. 啟動mysql服務

service mysqld restart

4. 修改生成的隨機密碼

grep "password" /var/log/mysqld.log #檢視隨機密碼
mysql -uroot -p
alter user 'root'@'localhost' identified by 'Test123!';

5. 相關檔案路徑備註

/etc/my.cnf
/var/log/var/log/mysqld.log

CentOS 安裝nodejs

1. 下載原始碼

wget https://nodejs.org/dist/v10.13.0/node-v10.13.0.tar.gz

2. 解壓

tar -xzvf node-v10.13.0.tar.gz

3. 進入原始碼目錄

cd node-v10.13.0

4. 安裝依賴

yum install gcc-c++

5. 配置

./configure

6. 編譯安裝

make && make install

CentOS 安裝jdk

1. 檢視yum庫中的java安裝包

yum -y list java*

2. 安裝需要的jdk版本的所有java程式

yum -y install java-1.8.0-openjdk*