raspberry pi 用 Archlinux 搭建 LNMP Nginx, MySQL, PHP

On Rapsberry Pi, Using Archlinux to build LNMP, linux, Nginx, MySQL, PHP

[root@alarmpi /]# pacman -S php php-cgi php-fpm php-curl php-gd php-mcrypt mysql mysql-clients nginx

WARNING: The host 'alarmpi' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
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/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h alarmpi password 'new-password'

Alternatively you can run:
/usr/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 ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/scripts/mysqlbug script!

(6/8) installing geoip-database                    [######################] 100%
(7/8) installing geoip                             [######################] 100%
(8/8) installing nginx                             [######################] 100%

vi /etc/php/php.ini
这里有一些extensions, 注释掉刚刚安装的这些模块。以让他们起作用。

;extension=bcmath.so
;extension=bz2.so
;extension=calendar.so
extension=curl.so
;extension=dba.so
;extension=enchant.so
;extension=exif.so
;extension=ftp.so
extension=gd.so
extension=gettext.so
;extension=gmp.so
;extension=iconv.so
;extension=imap.so
;extension=intl.so
;extension=ldap.so
extension=mcrypt.so



然后

vim /etc/php/php-fpm.conf

去掉注释成这样:

;listen = 127.0.0.1:9000
listen = /run/php-fpm/php-fpm.sock

我们用上面的unix格式,目的是为了以后能更好的使用,

其他的先不做调整

vim /etc/php/php.ini

修改下面的文字,

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/nginx/html/

后面加上那行:/usr/share/nginx/html/
这个是告诉php这个存放php的文件夹可以解析


然后我们调整Nginx.conf

vim /etc/nginx/nginx.conf  #修改成如下的格式
#user html;
worker_processes  1;

error_log  /var/log/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        /var/run/nginx.pid;


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  /var/log/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       81;
        server_name  localhost;

        root            /usr/share/nginx/html;

        #charset koi8-r;
        charset utf-8;

        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root        /usr/share/nginx/html;
            #try_files $uri =404;
            #fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        /etc/nginx/fastcgi_params;      #默认在/etc/nginx/ 下面有许多配置文件
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }

                                                                                                                                                                       85,0-1        45%

然后
systemctl enable php-fpm.service
systemctl enable nginx.service
systemctl start php-fpm.service
systemctl start nginx.service

目的是能让开机启动 :D

用命令行下的万维网浏览器elinks
进入elinks,输入http://localhost/hi.php
显示
hello world! this is a php script.
显示完成。PHP环境搭建成功。

剩下的安装模块,修改php.ini, php-fpm.conf , nginx.conf
按照用户个人需求来完成。MySQL具体操作,是通过PHP的。当然也可以远程操作。这取决于怎么使用。


下一个计划是将摄像头装在Archlinux上事实传输图像。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值