1. 程式人生 > >linux環境搭建lnmp環境

linux環境搭建lnmp環境

數據庫 pass () mat ttext test ica ket stat

編譯安裝lnmp環境準備軟件:nginx1.10.3+php-5.5.12+mariadb10.0.8(數據庫在此使用的yum安裝)

如果需要編譯安裝的可以給我留言,我後續再發布出來!

依賴包均已yum在線安裝一、yum安裝mariadb數據庫yum -y install mariadb*啟動數據庫systemctl start mariadb修改root密碼grant all privileges on *.* to [email protected] identified by "root" with grant option;grant all privileges on *.* to [email protected]
/* */%‘ identified by "root" with grant option;flush privileges;二、安裝nginx1、安裝依賴包yum install -y pcre pcre-devel openssl openssl-devel gcc-c++2、創建運行進程的用戶groupadd nginxuseradd -g nginx -s /bin/nologin nginx3、編譯安裝nginx我在這兒的軟件都放在myapp目錄下的tar -zxvf nginx-1.10.3.tar.gz #解壓到當前目錄cd nginx-1.10.3./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre --with-http_gzip_static_module --without-http_gzip_module --with-http_stub_status_modulemakemake install4、啟動nginxcd /usr/local/nginx/sbin./nginx5、驗證:瀏覽器訪問http://ip
三、編譯安裝php1、安裝依賴包yum -y install libxml2* curl curl-devel libpng-devel libpng openldap openldap-devel freetype freetype-devel libjpeg-devel libpng-devel2、編譯安裝phptar -xjf php-5.5.12.tar.bz2cd php-5.5.12./configure^C-prefix=/usr/local/php --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local/ --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64makemake testmake install3、修改php文件cp /myapp/php-5.5.12/php.ini-production /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf4、啟動php/usr/local/php/sbin/php-fpm檢查啟動是否成功netstat -lntp | grep php-fpm顯示 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 77087/php-fpm: mast四、整合nginx支持php1、修改nginx配置文件vi /usr/local/nginx/conf/nginx.conf[[email protected]
/* */ conf]# cat nginx.conf | grep -v "#"user nginx nginx;worker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; access_log logs/access.log main; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; charset utf8; location / { root html; index index.html index.htm index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }2、創建index.php文件測試cd /usr/local/nginx/htmlvi index.php[[email protected] html]# cat index.php <?php $link=mysql_connect("172.16.20.112","root","root"); if(!$link) echo "MySQL數據庫連接失敗!!"; else echo "MySQL數據庫連接成功!!"; phpinfo();?> 保存退出chmod 775 index.php3、驗證瀏覽器http://IP/index.php

有問題大家請指出來!!謝謝!!

linux環境搭建lnmp環境