Linux mint 下安装配置 LNMP
2016-07-10 02:21
288 查看
操作系统Linux mint 17.3 32位
1,安装mariadb
sudo apt-get install mariadb-server
安装过程中需要输入root账号的密码
安装完毕后需要配置编码为utf8以使数据库支持中文,解决中文输入输出或存储的乱码问题
打开mariadb的配置文件/etc/mysql/my.cnf并在相应的位置添加配置语句
[client] default_character_set=utf8 #在[client]下添加该语句,如无标签,可自行添加 [mysqld] character_set_server=utf8 #在[mysqld]下添加该语句,如无标签,可自行添加
修改完后,连接到数据库查看修改是否成功
mysql -u root -p #输入密码
连接数据库后输入sql语句查询数据库编码
show variables like 'chara%';
得到如下结果,证明修改成功
+--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
2,安装nginx以及PHP
sudo apt-get install nginx php5-fpm php5 php5-mysql
修改nginx的配置文件/etc/nginx/sites-available/default,进行如下修改
server { #listen 80 default_server; #注释掉该行 #listen [::]:80 default_server ipv6only=on; #注释掉该行 listen 127.0.0.1; #添加该行 index index.html index.htm index.php; #添加index.php ....... location ~ \.php$ { #取消该行注释 fastcgi_pass 127.0.0.1:9000; #取消该行注释 fastcgi_index index.php; #取消该行注释 include fastcgi_params; #取消该行注释 }
修改php配置文件/etc/php5/fpm/pool.d/www.conf
listen.allowed_clients = 127.0.0.1 #取消该行注释 #listen = /var/run/php5-fpm.sock #注释该行 listen = 9000 #添加该行
至此修改完成,可以进行测试,在目录/usr/share/nginx/html下添加php文件 index.php,文件内容如下
<?php phpinfo(); ?>
启动或重启nginx服务器和php-fpm服务(如果php5-fpm服务没找到,可以按文后方式修改)
sudo service nginx start #启动nginx sudo service nginx restart #重启nginx sudo service php5-fpm start #启动php5-fpm服务 sudo service php5-fpm restart #重启php5-fpm服务
打开浏览器,访问地址http://localhost/index.php ,页面如下示则证明配置成功
PS,解决找不到php5-fpm服务问题
备份/etc/init.d/php5-fpm到别的目录(可以复制到用户本地目录备份)
在该目录下新建 一个php5-fpm文件,并复制以下内容到文件内保存
Skip to content Personal Open source Business Explore Pricing Blog Support This repository 4 20 8 AbhishekGhosh/Nginx-PHP5-FPM-Restart-Fix-on-Ubuntu Code Issues 1 Pull requests 1 Wiki Pulse Graphs Nginx-PHP5-FPM-Restart-Fix-on-Ubuntu/php5-fpm 589b0a0 on 19 Nov 2014 @AbhishekGhosh AbhishekGhosh Create php5-fpm 173 lines (159 sloc) 4.43 KB #!/bin/sh ### BEGIN INIT INFO # Provides: php-fpm php5-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php5-fpm # Description: Fix PHP5 FastCGI Process Manager Daemon on Ubuntu # Author: Dr. Abhishek Ghosh # Copyleft: GNU GPL 3.0 # Tested with: Ubuntu 14.10 # Tested Webhosts: DigitalOcean, HPCloud, Amazon, I can not give warrenty about Rackspace ### END INIT INFO # Author: Ondrej Sury <ondrej@debian.org> PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="PHP5 FastCGI Process Manager" NAME=php5-fpm DAEMON=/usr/sbin/$NAME DAEMON_ARGS="--fpm-config /etc/php5/fpm/php-fpm.conf" PIDFILE=/var/run/php5-fpm.pid TIMEOUT=30 SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function to check the correctness of the config file # do_check() { [ "$1" != "no" ] && $DAEMON $DAEMON_ARGS -t 2>&1 | grep -v "\[ERROR\]" FPM_ERROR=$($DAEMON $DAEMON_ARGS -t 2>&1 | grep "\[ERROR\]") if [ -n "${FPM_ERROR}" ]; then echo "Please fix your configuration file..." $DAEMON $DAEMON_ARGS -t 2>&1 | grep "\[ERROR\]" return 1 fi return 0 } # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS 2>/dev/null \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=QUIT/$TIMEOUT/TERM/5/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # If the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/TERM/5/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # start-stop-daemon --stop --signal USR2 --quiet --pidfile $PIDFILE --name $NAME return 0 } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_check $VERBOSE case "$?" in 0) do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; check) do_check yes ;; reload|force-reload) log_daemon_msg "Reloading $DESC" "$NAME" do_reload log_end_msg $? ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 exit 1 ;; esac : Status API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Contact Help
然后重启计算机,修改生效,就可以使用上述的命令启动php5-fpm服务了,也可以使用以下命令进行启动与重启
sudo /etc/init.d/php5-fpm start #启动 sudo /etc/init.d/php5-fpm restart #重启
转载于:https://my.oschina.net/hadesho/blog/709137
相关文章推荐
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
- centOS7 安装配置 lnmp参考博客整理
- LNMP(linux+nginx+mysql+php)服务器环境配置(一)mysql安装
- LNMP(linux+nginx+mysql+php)服务器环境配置(三)nginx安装
- 如何查看编译安装的lnmp环境各自的配置参数
- LNMP一键安装包常用命令及配置文件路径
- Lnmp环境搭建之nginx-1.14.1的安装配置
- Lnmp环境搭建之mysql-5.6.16的安装配置【2】
- CentOS yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- LNMP 一键安装包配置 https
- Lnmp on Ubuntu 14.04实现多站点安装配置
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
- LNMP的安装和配置
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
- LNMP架构 (2)之 Nginx安装、默认虚拟主机、用户认证、域名重定向、配置文件详解
- 使用LNMP一键安装包配置CentOS服务器环境教程
- Linux Mint 13 的安装、配置及搭建Android源码编译环境
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- Linux yum安装配置lnmp服务器