LNMP架构说明
一.LNMP架構說明
1).使前端web服務和后端存儲服務進行串聯
2).主要實現處理PHP程序動態請求
二.LNMP架構工作原理
L(Linux) N(Nginx) M(Mysql) P(Php)
三.LNMP架構部署
1).安裝LNMP相關軟件
部署Linux系統:基礎優化操作要完成(防火墻關閉 關閉selinux /tmp權限1777)
部署nginx服務:忽略(請看上篇nginx部署實踐)
部署mysql服務:忽略(接上篇mysql)
2).PHP軟件安裝過程
解決php軟件依賴關系:yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
libiconv軟件安裝---字符集轉換庫(默認可以不進行安裝)
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
cd libiconv-1.14
??????? ./configure --prefix=/usr/local/libiconv
??????? make
??????? make install
??????? cd ../
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
??????? yum -y install libmcrypt-devel mhash mcrypt
??????? rpm -qa libmcrypt-devel mhash mcrypt
下載PHP軟件(PHP官網下載php.net):
cd /server/tools/
??????? tar xf php-5.5.32.tar.gz
??????? cd php-5.5.32
編譯:./configure \
--prefix=/application/php-5.5.32 \
--with-mysql=/application/mysql-5.6.34 \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
##防錯(以下信息可以不進行配置了)
??????? ln -s /application/mysql/lib/libmysqlclient.so.18? /usr/lib64/
??????? touch ext/phar/phar.phar
?? ??? ?make
??????? make install
?? ??? ?ln -s /application/php-5.5.32/ /application/php
##設置PHP程序配置文件
php.ini php-fpm.ini
??????? cp php.ini-production /application/php-5.5.32/lib/
?? ??? ?cd /application/php/etc/
?? ??? ?cp php-fpm.conf.default php-fpm.con
##啟動php程序服務:
/application/php/sbin/php-fpm
?? ??? ?netstat -lntup|grep php
??????? tcp??????? 0????? 0 127.0.0.1:9000????????????? 0.0.0.0:*?????????????????? LISTEN????? 6251/php-fpm
四.進行軟件的結合
nginx與php結合:編寫nginx配置文件
?? ??? location ~* .*\.(php|php5)?$ {
????????? fastcgi_pass? 127.0.0.1:9000;
????????? fastcgi_index index.php;
????????? include fastcgi.conf;
?????? }
php與mysql結合:編寫php程序代碼
?? ??? <?php
?????????? //$link_id=mysql_connect('主機名','用戶','密碼');
?????????? //mysql -u用戶 -p密碼 -h 主機
?????????? $link_id=mysql_connect('localhost','root','oldboy123') or mysql_error();
?????????? if($link_id){
??????????????????????? echo "mysql successful by oldboy !\n";
?????????????????????? }else{
??????????????????????? echo mysql_error();
?????????????????????? }
?????? ?>
五.部署一個網站(wordpress為例)
1.下載與上傳網站代碼(直接搜即可)
2.解壓程序代碼,將程序代碼保存到站點目錄并進行授權
tar xf wordpress-4.7.3-zh_CN.tar.gz
?????? mv wordpress/* /application/nginx/html/blog/
?? ??? chown -R www.www /application/nginx/html/blog/
3.直接訪問blog網站,進行初始化操作
創建數據庫:
?? ??? create database wordpress;
?? ??? show databases;
4.創建連接數據用戶信息
grant all on wordpress.* to 'wordpress'@'localhost' identified by 'oldboy123';
?? ??? select user,host from mysql.user;
轉載于:https://www.cnblogs.com/datastart/p/10521919.html
總結
- 上一篇: 精选Spring Boot三十五道必知必
- 下一篇: Spring Cloud构建微服务架构: