成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

小白需要的LNMP搭建教程

mcterry / 1839人閱讀

摘要:本文是本人在搭建阿里云的服務(wù)器環(huán)境的時(shí)候,結(jié)合阿里云提供的文檔和自己編譯安裝過程中的各種得來。適用對(duì)象適用于熟悉操作系統(tǒng),剛開始使用阿里云進(jìn)行建站的個(gè)人用戶。

本文是本人在搭建阿里云的ECS服務(wù)器環(huán)境的時(shí)候,結(jié)合阿里云提供的文檔和自己編譯安裝過程中的各種ERROR得來。

適用對(duì)象

適用于熟悉Linux操作系統(tǒng),剛開始使用阿里云進(jìn)行建站的個(gè)人用戶。

基本流程

使用云服務(wù)器 ECS 搭建LNMP平臺(tái)的操作步驟如下:

1.準(zhǔn)備編譯環(huán)境
2.安裝nginx
3.安裝mysql
4.安裝php-fpm
5.測(cè)試訪問

步驟一:準(zhǔn)備編譯環(huán)境

本文主要說明手動(dòng)安裝LNMP平臺(tái)的操作步驟,您也可以在云市場(chǎng)購(gòu)買LNMP鏡像直接啟動(dòng)ECS,以便快速建站。

1、系統(tǒng)版本說明

1.# cat /etc/redhat-release 
2.CentOS release 6.5 (Final)

注:這是本文檔實(shí)施時(shí)參考的系統(tǒng)版本。您的實(shí)際使用版本可能與此不同,下文中的nginx,mysql,及php版本,您也可以根據(jù)實(shí)際情況選擇相應(yīng)版本。
2、關(guān)閉SELINUX

修改配置文件,重啟服務(wù)后永久生效。

# sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config

命令行設(shè)置立即生效。

# setenforce 0

3、安全組設(shè)置

在ECS安全組放行需訪問的端口和訪問白名單,下面的示例表示允許所有IP訪問服務(wù)器的80端口。您可以根據(jù)實(shí)際情況放行允許訪問的客戶端IP。

步驟二:安裝nginx

Nginx是一個(gè)小巧而高效的Linux下的Web服務(wù)器軟件,是由 Igor Sysoev 為俄羅斯訪問量第二的 Rambler.ru 站點(diǎn)開發(fā)的,已經(jīng)在一些俄羅斯的大型網(wǎng)站上運(yùn)行多年,目前很多國(guó)內(nèi)外的門戶網(wǎng)站、行業(yè)網(wǎng)站也都在是使用Nginx,相當(dāng)穩(wěn)定。

1、添加運(yùn)行nginx服務(wù)進(jìn)程的用戶

1.# groupadd -r nginx    
2.# useradd -r -g nginx  nginx

2、下載源碼包解壓編譯。

# wget http://nginx.org/download/nginx-1.10.2.tar.gz
# tar xvf nginx-1.10.2.tar.gz -C /usr/local/src
# yum groupinstall "Development tools"
# yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel
# cd /usr/local/src/nginx-1.10.2
# ./configure 
--prefix=/usr/local/nginx 
--sbin-path=/usr/sbin/nginx 
--conf-path=/etc/nginx/nginx.conf 
--error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log 
--pid-path=/var/run/nginx.pid 
--lock-path=/var/run/nginx.lock 
--http-client-body-temp-path=/var/tmp/nginx/client 
--http-proxy-temp-path=/var/tmp/nginx/proxy 
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi 
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi 
--http-scgi-temp-path=/var/tmp/nginx/scgi 
--user=nginx 
--group=nginx 
--with-pcre 
--with-http_v2_module 
--with-http_ssl_module 
--with-http_realip_module 
--with-http_addition_module 
--with-http_sub_module 
--with-http_dav_module 
--with-http_flv_module 
--with-http_mp4_module 
--with-http_gunzip_module 
--with-http_gzip_static_module 
--with-http_random_index_module 
--with-http_secure_link_module 
--with-http_stub_status_module 
--with-http_auth_request_module 
--with-mail 
--with-mail_ssl_module 
--with-file-aio 
--with-ipv6 
--with-threads 
--with-stream 
--with-stream_ssl_module
# make && make install
# mkdir -pv /var/tmp/nginx/client

3、添加SysV啟動(dòng)腳本。

# vim /etc/init.d/nginx
#!/bin/sh 
# 
# nginx - this script starts and stops the nginx daemon 
# 
# chkconfig:   - 85 15 
# description: Nginx is an HTTP(S) server, HTTP(S) reverse  
#               proxy and IMAP/POP3 proxy server 
# processname: nginx 
# config:      /etc/nginx/nginx.conf 
# config:      /etc/sysconfig/nginx 
# pidfile:     /var/run/nginx.pid 
# Source function library. 
. /etc/rc.d/init.d/functions
# Source networking configuration. 
. /etc/sysconfig/network
# Check that networking is up. 
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: " 
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo 
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop() {
    echo -n $"Stopping $prog: " 
    killproc $prog -QUIT
    retval=$?
    echo 
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
killall -9 nginx
}
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: " 
    killproc $nginx -HUP
RETVAL=$?
    echo 
}
force_reload() {
    restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
    status $prog
}
rh_status_q() {
    rh_status >/dev/null 2>&1
}
case "$1" in
    start)
        rh_status_q && exit 0
    $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 
        exit 2
esac

4、賦予腳本執(zhí)行權(quán)限。

# chmod +x /etc/init.d/nginx

5、添加至服務(wù)管理列表,設(shè)置開機(jī)自啟。

# chkconfig --add nginx
# chkconfig  nginx on

6、啟動(dòng)服務(wù)。

# service nginx start

7、瀏覽器訪問可看到默認(rèn)歡迎頁(yè)面。

步驟三:安裝mysql

1、準(zhǔn)備編譯環(huán)境。

# yum groupinstall "Server Platform Development"  "Development tools" -y
# yum install cmake -y

2、準(zhǔn)備mysql數(shù)據(jù)存放目錄。

# mkdir /mnt/data
# groupadd -r mysql
# useradd -r -g mysql -s /sbin/nologin mysql
# id mysql
uid=497(mysql) gid=498(mysql) groups=498(mysql)

3、更改數(shù)據(jù)目錄屬主屬組。

# chown -R mysql:mysql /mnt/data

4、解壓編譯在MySQL官網(wǎng)下載的穩(wěn)定版源碼包,這里使用的是5.6.24版本

# tar xvf mysql-5.6.24.tar.gz -C  /usr/local/src
# cd /usr/local/src/mysql-5.6.24
# cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DMYSQL_DATADIR=/mnt/data 
-DSYSCONFDIR=/etc 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_ARCHIVE_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
-DWITH_READLINE=1 
-DWITH_SSL=system 
-DWITH_ZLIB=system 
-DWITH_LIBWRAP=0 
-DMYSQL_TCP_PORT=3306 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci

若出現(xiàn)如下錯(cuò)誤:

CMake Error at cmake/ssl.cmake:247 (MESSAGE):
  Cannot find appropriate system libraries for SSL.  Make sure you"ve
  specified a supported SSL version.  Consult the documentation for WITH_SSL
  alternatives
Call Stack (most recent call first):
  CMakeLists.txt:446 (MYSQL_CHECK_SSL)


-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:128 (FIND_CURSES)
  cmake/readline.cmake:218 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:448 (MYSQL_CHECK_EDITLINE)


-- Configuring incomplete, errors occurred!
See also "/usr/local/src/mysql-5.6.38/CMakeFiles/CMakeOutput.log".
See also "/usr/local/src/mysql-5.6.38/CMakeFiles/CMakeError.log".

執(zhí)行此操作:

rm CMakeCache.txt
yum install ncurses-devel

接著:

# make && make install

5、修改安裝目錄的屬組為mysql。

# chown -R mysql:mysql /usr/local/mysql/

6、初始化數(shù)據(jù)庫(kù)。

# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mnt/data/

注:在CentOS 6.5版操作系統(tǒng)的最小安裝完成后,在/etc目錄下會(huì)存在一個(gè)my.cnf,需要將此文件更名為其他的名字,如:/etc/my.cnf.bak,否則,該文件會(huì)干擾源碼安裝的MySQL的正確配置,造成無(wú)法啟動(dòng)。

7、拷貝配置文件和啟動(dòng)腳本。

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# cp support-files/my-default.cnf /etc/my.cnf

8、設(shè)置開機(jī)自動(dòng)啟動(dòng)。

# chkconfig mysqld  on 
# chkconfig --add mysqld

9、修改配置文件中的安裝路徑及數(shù)據(jù)目錄存放路徑。

# echo -e "basedir = /usr/local/mysql
datadir = /mnt/data
" >> /etc/my.cnf

10、設(shè)置PATH環(huán)境變量。

# echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh      
# source /etc/profile.d/mysql.sh

11、啟動(dòng)服務(wù)。

# service mysqld start 

若出現(xiàn)如下錯(cuò)誤:

Starting MySQL.Logging to "/mnt/data/localhost.localdomain.err".
The server quit without updating PID file (/mnt/data/localh[FAILED]ldomain.pid).
[root@localhost mysql]# service mysqld start
Starting MySQL.The server quit without updating PID file (/mnt/data/localhost.localdomain.pid).                                            [FAILED]

若重新初始化會(huì)遇到這種問題:

[root@localhost scripts]# ./mysql_install_db --user=mysql --datadir=/mnt/data/
FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run "make install" to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

然后我們接著往下走:

[root@localhost scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/data &
[1] 16068
[root@localhost scripts]# Installing MySQL system tables...2017-12-01 01:23:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-01 01:23:46 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-12-01 01:23:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.38) starting as process 16077 ...
2017-12-01 01:23:46 16077 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-01 01:23:46 16077 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-01 01:23:46 16077 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-01 01:23:46 16077 [Note] InnoDB: Memory barrier is not used
2017-12-01 01:23:46 16077 [Note] InnoDB: Compressed tables use zlib 1.2.7
2017-12-01 01:23:46 16077 [Note] InnoDB: Using CPU crc32 instructions
2017-12-01 01:23:46 16077 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-01 01:23:46 16077 [Note] InnoDB: Completed initialization of buffer pool
2017-12-01 01:23:46 16077 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-12-01 01:23:46 16077 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-12-01 01:23:46 16077 [Note] InnoDB: Database physically writes the file full: wait...
2017-12-01 01:23:46 16077 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-12-01 01:23:46 16077 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-12-01 01:23:46 16077 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-12-01 01:23:46 16077 [Warning] InnoDB: New log files created, LSN=45781
2017-12-01 01:23:46 16077 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-12-01 01:23:46 16077 [Note] InnoDB: Doublewrite buffer created
2017-12-01 01:23:46 16077 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-01 01:23:46 16077 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-01 01:23:46 16077 [Note] InnoDB: Foreign key constraint system tables created
2017-12-01 01:23:46 16077 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-12-01 01:23:46 16077 [Note] InnoDB: Tablespace and datafile system tables created.
2017-12-01 01:23:46 16077 [Note] InnoDB: Waiting for purge to start
2017-12-01 01:23:46 16077 [Note] InnoDB: 5.6.38 started; log sequence number 0
2017-12-01 01:23:46 16077 [Note] RSA private key file not found: /mnt/data//private_key.pem. Some authentication plugins will not work.
2017-12-01 01:23:46 16077 [Note] RSA public key file not found: /mnt/data//public_key.pem. Some authentication plugins will not work.
2017-12-01 01:23:47 16077 [Note] Binlog end
2017-12-01 01:23:47 16077 [Note] InnoDB: FTS optimize thread exiting.
2017-12-01 01:23:47 16077 [Note] InnoDB: Starting shutdown...
2017-12-01 01:23:48 16077 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2017-12-01 01:23:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-01 01:23:48 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-12-01 01:23:48 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.38) starting as process 16099 ...
2017-12-01 01:23:48 16099 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-01 01:23:48 16099 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-01 01:23:48 16099 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-01 01:23:48 16099 [Note] InnoDB: Memory barrier is not used
2017-12-01 01:23:48 16099 [Note] InnoDB: Compressed tables use zlib 1.2.7
2017-12-01 01:23:48 16099 [Note] InnoDB: Using CPU crc32 instructions
2017-12-01 01:23:48 16099 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-01 01:23:48 16099 [Note] InnoDB: Completed initialization of buffer pool
2017-12-01 01:23:48 16099 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-01 01:23:48 16099 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-01 01:23:48 16099 [Note] InnoDB: Waiting for purge to start
2017-12-01 01:23:48 16099 [Note] InnoDB: 5.6.38 started; log sequence number 1625977
2017-12-01 01:23:48 16099 [Note] RSA private key file not found: /mnt/data//private_key.pem. Some authentication plugins will not work.
2017-12-01 01:23:48 16099 [Note] RSA public key file not found: /mnt/data//public_key.pem. Some authentication plugins will not work.
2017-12-01 01:23:48 16099 [Note] Binlog end
2017-12-01 01:23:48 16099 [Note] InnoDB: FTS optimize thread exiting.
2017-12-01 01:23:48 16099 [Note] InnoDB: Starting shutdown...
2017-12-01 01:23:49 16099 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password "new-password"
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password "new-password"

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[1]+  完成                  /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/data

查看以下mysql的狀態(tài):

[root@localhost scripts]# service mysqld status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]

啟動(dòng)與重啟均沒問題:

[root@localhost scripts]# service mysqld start
Starting MySQL.Logging to "/mnt/data/localhost.localdomain.err".
                                                           [  OK  ]
[root@localhost scripts]# service mysqld restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL.                                            [  OK  ]

登陸:

# mysql -h 127.0.0.1

步驟四:安裝php-fpm

Nginx本身不能處理PHP,作為web服務(wù)器,當(dāng)它接收到請(qǐng)求后,不支持對(duì)外部程序的直接調(diào)用或者解析,必須通過FastCGI進(jìn)行調(diào)用。如果是PHP請(qǐng)求,則交給PHP解釋器處理,并把結(jié)果返回給客戶端。PHP-FPM是支持解析php的一個(gè)FastCGI進(jìn)程管理器。提供了更好管理PHP進(jìn)程的方式,可以有效控制內(nèi)存和進(jìn)程、可以平滑重載PHP配置。

1、安裝依賴包。

yum install libmcrypt libmcrypt-devel mhash mhash-devel libxml2 libxml2-devel bzip2 bzip2-devel

2、解壓官網(wǎng)下載的源碼包,編譯安裝。

# tar xvf php-5.6.23.tar.bz2 -C /usr/local/src
# cd /usr/local/src/php-5.6.23
# ./configure --prefix=/usr/local/php 
--with-config-file-scan-dir=/etc/php.d 
--with-config-file-path=/etc 
--with-mysql=/usr/local/mysql 
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--enable-mbstring 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir=/usr 
--with-openssl 
--enable-xml 
--enable-sockets 
--enable-fpm 
--with-mcrypt 
--with-bz2 
--with-curl
# make && make install

3、添加php和php-fpm配置文件。

# cp /usr/local/src/php-5.6.23/php.ini-production /etc/php.ini
# cd /usr/local/php/etc/
# cp php-fpm.conf.default php-fpm.conf
# sed -i "s@;pid = run/php-fpm.pid@pid = /usr/local/php/var/run/php-fpm.pid@" php-fpm.conf

4、添加php-fpm啟動(dòng)腳本。

# cp /usr/local/src/php-5.6.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm

5、添加php-fpm至服務(wù)列表并設(shè)置開機(jī)自啟。

# chkconfig --add php-fpm     
# chkconfig --list php-fpm     
# chkconfig php-fpm on

6、啟動(dòng)服務(wù)。

# service php-fpm start

若出現(xiàn)如下情況:

[root@localhost etc]# service php-fpm start
Starting php-fpm [01-Dec-2017 02:31:24] WARNING: Nothing matches the include pattern "/usr/local/php/etc/php-fpm.d/*.conf" from /usr/local/php/etc/php-fpm.conf at line 125.
[01-Dec-2017 02:31:24] ERROR: No pool defined. at least one pool section must be specified in config file
[01-Dec-2017 02:31:24] ERROR: failed to post process the configuration
[01-Dec-2017 02:31:24] ERROR: FPM initialization failed
 failed

執(zhí)行此操作:

[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ll
總用量 20
-rw-r--r-- 1 root root 18517 12月  1 02:27 www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# service php-fpm start
Starting php-fpm  done
[root@localhost php-fpm.d]# 

7、添加nginx對(duì)fastcgi的支持,首先備份默認(rèn)的配置文件。

# cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

編輯/etc/nginx/nginx.conf,在所支持的主頁(yè)面格式中添加php格式的主頁(yè),類似如下:

 location / {
            root   /usr/local/nginx/html;
            index  index.php index.html index.htm;
        }

取消以下內(nèi)容前面的注釋:

  location ~ .php$ {
            root           /usr/local/nginx/html;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
        }

重新載入nginx的配置文件。

# service nginx reload

在/usr/local/nginx/html/新建index.php的測(cè)試頁(yè)面,內(nèi)容如下。

# cat index.php 
php
$conn=mysql_connect("127.0.0.1","root","");
if ($conn){
  echo "LNMP platform connect to mysql is successful!";
}else{
  echo "LNMP platform connect to mysql is failed!";
}
 phpinfo();
?>

瀏覽器訪問測(cè)試,如看到以下內(nèi)容則表示LNMP平臺(tái)構(gòu)建完成。

Done!

如有疑問,歡迎各位大佬指點(diǎn)、批評(píng)。

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/39712.html

相關(guān)文章

  • 教你從零開始使用wordpress生成微信小程序(小白教程

    摘要:準(zhǔn)備工作服務(wù)器最好使用服務(wù)器,小白推薦安裝寶塔面板。備案域名小程序賬號(hào)建議注冊(cè)企業(yè)賬號(hào),可以使用已認(rèn)證的公眾號(hào)快速創(chuàng)建。七牛賬號(hào)使用,加快網(wǎng)站訪問速度。如需使用小程序發(fā)帖,也會(huì)用到。注意不要使用以下的。 showImg(https://segmentfault.com/img/bVUUeU?w=600&h=280); 準(zhǔn)備工作 1服務(wù)器 最好使用Linux服務(wù)器,小白推薦安裝寶塔面板。...

    jaysun 評(píng)論0 收藏0
  • 小白需要LNMP搭建教程

    摘要:本文是本人在搭建阿里云的服務(wù)器環(huán)境的時(shí)候,結(jié)合阿里云提供的文檔和自己編譯安裝過程中的各種得來。適用對(duì)象適用于熟悉操作系統(tǒng),剛開始使用阿里云進(jìn)行建站的個(gè)人用戶。 本文是本人在搭建阿里云的ECS服務(wù)器環(huán)境的時(shí)候,結(jié)合阿里云提供的文檔和自己編譯安裝過程中的各種ERROR得來。 適用對(duì)象 適用于熟悉Linux操作系統(tǒng),剛開始使用阿里云進(jìn)行建站的個(gè)人用戶。 基本流程 使用云服務(wù)器 ECS 搭建L...

    siberiawolf 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<