LNMP是指一組通常一起使用來運行動態網站或者服務器的自由軟體名稱首字母縮寫,L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指Perl或Python,
注:本章會提供所有軟體包的資源
文章目錄
- 一、Nginx
- 二、MySQL
- 三、PHP
- 四、最后配置
我們先配置一個自己的本地yum庫,因為LNMP有很多環境要安裝
[a]
name=1
baseurl=file:///media
gpgcheck=0
要安裝的環境有
yum -y install pcre-devel zlib-devel openssl-devel ncurses-devel gd libxml2-devel libjpeg-devel libpng-devel
注:本次用的是圖形化界面,所以不缺C環境
一、Nginx
Nginx是一個高性能的HTTP和反向代理服務器,也是一個IMAP/POP3/SMTP代理服務器,
鏈接:https://pan.baidu.com/s/1N0uQRRvE_vLRdh9GArUaDQ
提取碼:0805
[root@localhost ~]# tar zxf nginx-1.13.5.tar.gz
[root@localhost ~]# cd nginx-1.13.5/
[root@localhost nginx-1.13.5]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost nginx-1.13.5]#make -j6 && make install //這里的-j6是啟用6核編譯、一定要看好自己的核心數是多少再用
[root@localhost nginx-1.13.5]# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
[root@localhost nginx-1.13.5]# useradd -M -s /sbin/nologin nginx
配置完成
二、MySQL
MySQL是一種開放源代碼的關系型資料庫管理系統,使用最常用的資料庫管理語言–結構化查詢語言(SQL)進行資料庫管理,
資料庫(Database)是按照資料結構來組織、存盤和管理資料的倉庫,每個資料庫都有一個或多個不同的 API 用于創建,訪問,管理,搜索和復制所保存的資料,
安裝MySQL之前需要安裝cmake
cmake可以通過yum安裝或原始碼編譯安裝、在這里我用的是原始碼編譯安裝
鏈接:https://pan.baidu.com/s/1LtxHWF4NJnpFe0YJG32BQA
提取碼:0805
安裝cmake
[root@localhost ~]# tar zxf cmake-2.8.6.tar.gz
[root@localhost ~]# cd cmake-2.8.6/
[root@localhost cmake-2.8.6/]# ./configure
[root@localhost cmake-2.8.6/]# gmake -j6 && gmake install
MySQL的搭建
鏈接:https://pan.baidu.com/s/17sJkiqHS40ffb8DukEANqw
提取碼:0805
[root@localhost ~]# tar zxf mysql-5.5.22.tar.gz
[root@localhost ~]cd mysql-5.5.22/
[root@localhost mysql-5.5.22/]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
[root@localhost mysql-5.5.22/]# make -j6 && make install
[root@localhost mysql-5.5.22/]# useradd -M -s /sbin/nologin mysql
[root@localhost mysql-5.5.22/]# userdel mysqld
[root@localhost mysql-5.5.22/]# chown -R mysql.mysql /usr/local/mysql/
[root@localhost mysql-5.5.22/]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.5.22/]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.22/]# chmod +x /etc/init.d/mysqld
[root@localhost mysql-5.5.22/]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
[root@localhost mysql-5.5.22/]# echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
[root@localhost mysql-5.5.22/]# . /etc/profile
[root@localhost mysql-5.5.22/]# chkconfig --add mysqld
[root@localhost mysql-5.5.22/]# /etc/init.d/mysqld start
三、PHP
在LNMP中、PHP是一種在服務器端執行的嵌入HTML檔案的腳本語言,
鏈接:https://pan.baidu.com/s/1KWy1VU1l9-R4DSljT8-krQ
提取碼:0805
[root@localhost ~]# cd php-5.3.28/
[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib/
[root@localhost php-5.3.28]# make && make install
[root@localhost php-5.3.28]# cp php.ini-development /usr/local/php5/php.ini
[root@localhost php-5.3.28]# ln -s /usr/local/php5/bin/* /usr/local/bin/
四、最后配置
[root@localhost php-5.3.28]# vim /usr/local/php5/php.ini
大約在220行
大約在780行
[root@localhost php-5.3.28]# cd /usr/local/php5/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# useradd -M -s /sbin/nologin php
[root@localhost etc]# vim /usr/local/php5/etc/php-fpm.conf
大約在140行
[root@localhost etc]# /usr/local/php5/sbin/php-fpm
[root@localhost etc]# vim /usr/local/nginx/conf/nginx.conf
大約在90行
大約在70行
創建網頁檔案
[root@localhost etc]# cd /usr/local/nginx/html/
[root@localhost html]# ls
50x.html index.html
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
[root@localhost html]# nginx //啟動nginx
搭建完成
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/290619.html
標籤:其他
上一篇:學習HTML<一>
下一篇:【前端】一、web技識訓礎
