摘要:啟動服務(wù)啟動查看端口進程進入數(shù)據(jù)庫設(shè)置軟連接設(shè)置密碼用戶登錄至此安裝完畢。編譯安裝下載軟件包解壓編譯安裝添加啟動腳本內(nèi)容如下設(shè)置開機啟動啟動,查看進程端口確定至此安裝完畢。
前言
系統(tǒng)環(huán)境
[root@lnmp mysql]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@lnmp mysql]# uname -r 3.10.0-514.el7.x86_64
官方下載地址
mariadb數(shù)據(jù)庫
php
ngixn
安裝mariadb10.3.131. 下載mariadb二進制包
由于源碼包編譯時間過長就不選用了,而選用已經(jīng)編譯過的二進制包
$ wget https://mirrors.shu.edu.cn/mariadb//mariadb-10.3.13/bintar-linux-x86_64/mariadb-10.3.13-linux-x86_64.tar.gz
2. 解壓
$ tar -zxvf mariadb-10.3.13-linux-x86_64.tar.gz
3. 將解壓后的二進制包放置軟件目錄
這里我習(xí)慣放置在/usr/local下,并改名mysql
$ mv mariadb-10.3.13-linux-x86_64 /usr/local/mysql
4. 創(chuàng)建數(shù)據(jù)存儲目錄與管理用戶mysql
$ groupadd mysql $ useradd -s /sbin/nologin -M mysql $ cd /usr/local/mysql $ chown -R mysql:mysql .
5.初始化
$ ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
這一步如果報錯:
/usr/local/mariadb/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決:yum install -y libaio-devel
6.檢查是否安裝成功
在初始化命令之后使用$ ech $?,查看返回結(jié)果是否為0,為0表示成功,不為0表示失敗。
7.拷貝啟動腳本,并用chkconfig工具管理
$ cd /usr/local/mysql $ cp support-files/mysql.server /etc/init.d/mysqld # 定義啟動腳本內(nèi)容,修改datadir和basedir $ vim /etc/init.d/mysqld # 修改 basedir=/usr/local/mysql # 軟件的目錄 datadir==/usr/local/mysql/data # 存放數(shù)據(jù)目錄 # 修改完,設(shè)置開機自啟動 $ chkconfig --add mysqld $ chkconfig mysqld on
8.設(shè)置mariadb配置文件/etc/my.cnf
$ vim /etc/my.cnf # 修改配置內(nèi)容為 datadir=/usr/local/mysql/data socket=/tmp/mysql.sock log-error=/usr/local/mysql/data/mariadb.log pid-file=/usr/local/mysql/data/mariadb.pid
保存退出。
9. 啟動mariadb服務(wù)
$ /etc/init.d/mysqld start #啟動mariadb
10. 查看端口進程
[root@lnmp mysql]$ netstat -lntp | grep mysql tcp6 0 0 :::3306 :::* LISTEN 4225/mysqld [root@lnmp mysql]$ ps aux | grep mysql root 4140 0.0 0.0 115436 1756 ? S 13:31 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/lnmp.pid mysql 4225 0.0 4.8 1713716 90736 ? Sl 13:31 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mariadb.log --pid-file=/usr/local/mysql/data/lnmp.pid --socket=/tmp/mysql.sock root 4280 0.0 0.0 112728 964 pts/1 S+ 13:43 0:00 grep --color=auto mysql
11. 進入mariadb數(shù)據(jù)庫
$ /usr/local/mysql/bin/mysql Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 10 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type "help;" or "h" for help. Type "c" to clear the current input statement. MariaDB [(none)]>
12. 設(shè)置軟連接
$ ln -s /usr/local/mysql/bin/mysql /usr/bin $ ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
13. 設(shè)置root密碼
$ mysqladmin -u root -p "!@#123qwe"
14. root用戶登錄mysql
[root@lnmp mysql]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 16 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type "help;" or "h" for help. Type "c" to clear the current input statement. MariaDB [(none)]>
至此mariadb安裝完畢。
安裝php7.3.31. 下載軟件包
下載地址:http://php.net/get/php-7.3.3.tar.bz2/from/a/mirror
選擇中國鏡像站點下載,或者復(fù)制鏈接地址wget下載也可以。
這里我是先下載到我的window再上傳到linux。
2. 解壓
$ tar -jxvf php-7.3.3.tar.bz2 # 如果沒有安裝bzip2工具會報錯 $ yum install -y bzip2
3. 安裝依賴包
$ yum install -y gcc libxml2-devel zlib-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel epel-release libmcrypt-devel curl-devel freetype-devel
4. 編譯參數(shù)
$ ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
5. 安裝
make && make install
6. 拷貝配置文件
$ cp /usr/local/src/php-7.3.3/php.ini-development /usr/local/php-fpm/etc/php.ini $ cp /usr/local/php-fpm/etc/php-fpm.conf.default /usr/local/php-fpm/etc/php-fpm.conf
7. 配置啟動腳本設(shè)置開機啟動
$ cp /usr/local/src/php-7.3.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm $ chmod +x php-fpm $ chkconfig --add php-fpm $ chkconfig php-fom on
8. 創(chuàng)建用戶,配置pool
$ useradd php-fpm $ cp /usr/local/php-fpm/etc/php-fpm.d/www.conf.default /usr/local/php-fpm/etc/php-fpm.d/www.conf
9.啟動服務(wù),查看進程
[root@lnmp ~]$ service php-fpm start Starting php-fpm done [root@lnmp ~]$ ps aux | grep php-fpm root 18747 0.0 0.3 115992 6284 ? Ss 13:27 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 18748 0.0 0.3 115992 5836 ? S 13:27 0:00 php-fpm: pool www php-fpm 18749 0.0 0.3 115992 5836 ? S 13:27 0:00 php-fpm: pool www root 18751 0.0 0.0 112724 988 pts/0 S+ 13:27 0:00 grep --color=auto php-fpm [root@lnmp ~]$ netstat -lntp | grep php-fpm tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 18747/php-fpm: mast
php安裝完畢。
編譯安裝nginx1.14.21. 下載軟件包
$ cd /usr/local/src $ wget http://nginx.org/download/nginx-1.14.2.tar.gz
2. 解壓
$ tar -zxvf nginx-1.14.2.tar.gz
3. 編譯安裝
$ cd nginx-1.14.2 $ ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module $ make && make install
4. 添加nginx啟動腳本
$ vim /etc/init.d/nginx
內(nèi)容如下:
#!/bin/bash # chkconfig: - 30 21 # description: http service. # Source Function Library . /etc/init.d/functions # Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" RETVAL=0 prog="Nginx" start() { echo -n $"Starting $prog: " mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? echo return $RETVAL } reload() { echo -n $"Reloading $prog: " killproc -p $NGINX_PID $NGINX_SBIN -HUP RETVAL=$? echo return $RETVAL } restart() { stop start } configtest() { $NGINX_SBIN -c $NGINX_CONF -t return 0 } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|reload|restart|configtest}" RETVAL=1 esac exit $RETVAL
5. 設(shè)置nginx開機啟動
$ chmod +x /etc/init.d/nginx $ chkconfig --add nginx $ chkconfig nginx on
6. 啟動nignx,查看進程端口
[root@lnmp nginx-1.14.2]$ /etc/init.d/nginx start Starting nginx (via systemctl): [ 確定 ] [root@lnmp nginx-1.14.2]$ ps aux | grep nginx root 21486 0.0 0.0 45948 1120 ? Ss 13:50 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf nobody 21487 0.0 0.1 46384 1900 ? S 13:50 0:00 nginx: worker process root 21489 0.0 0.0 112724 988 pts/0 S+ 13:50 0:00 grep --color=auto nginx [root@lnmp nginx-1.14.2]$ netstat -lntp | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 21486/nginx: master
至此nginx安裝完畢。
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/40375.html
閱讀 2774·2021-11-22 15:11
閱讀 3537·2021-09-28 09:43
閱讀 2889·2019-08-30 13:05
閱讀 3431·2019-08-30 11:18
閱讀 1447·2019-08-29 16:34
閱讀 1300·2019-08-29 13:53
閱讀 2908·2019-08-29 11:03
閱讀 1658·2019-08-29 10:57