查看: 9464|回复: 1

[原创] raspberry pi 用 Archlinux 搭建 LNMP Nginx, MySQL, PHP

[复制链接]
  • TA的每日心情
    奋斗
    2013-6-21 12:27
  • 签到天数: 26 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2013-1-1 02:20:08 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 xinxincaijq 于 2013-12-16 13:54 编辑

    http://blog.csdn.net/spaceship20008/article/details/8456601 原帖地址

    貌似复制过来失真。还没有直接填写html代码的权限。

    On Rapsberry Pi, Using Archlinux to build LNMP, linux, Nginx, MySQL, PHP
    1. [root@alarmpi /]# pacman -S php php-cgi php-fpm php-curl php-gd php-mcrypt mysql mysql-clients nginx

    2. WARNING: The host 'alarmpi' could not be looked up with resolveip.
    3. This probably means that your libc libraries are not 100 % compatible
    4. with this binary MySQL version. The MySQL daemon, mysqld, should work
    5. normally with the exception that host name resolving will not work.
    6. This means that you should use IP addresses instead of hostnames
    7. when specifying MySQL privileges !
    8. Installing MySQL system tables...
    9. OK
    10. Filling help tables...
    11. OK

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

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

    16. /usr/bin/mysqladmin -u root password 'new-password'
    17. /usr/bin/mysqladmin -u root -h alarmpi password 'new-password'

    18. Alternatively you can run:
    19. /usr/bin/mysql_secure_installation

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

    23. See the manual for more instructions.

    24. You can start the MySQL daemon with:
    25. cd /usr ; /usr/bin/mysqld_safe &

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

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

    29. (6/8) installing geoip-database [######################] 100%
    30. (7/8) installing geoip [######################] 100%
    31. (8/8) installing nginx [######################] 100%
    复制代码
    1. vi /etc/php/php.ini
    复制代码
    这里有一些extensions, 注释掉刚刚安装的这些模块。以让他们起作用。
    1. ;extension=bcmath.so
    2. ;extension=bz2.so
    3. ;extension=calendar.so
    4. extension=curl.so
    5. ;extension=dba.so
    6. ;extension=enchant.so
    7. ;extension=exif.so
    8. ;extension=ftp.so
    9. extension=gd.so
    10. extension=gettext.so
    11. ;extension=gmp.so
    12. ;extension=iconv.so
    13. ;extension=imap.so
    14. ;extension=intl.so
    15. ;extension=ldap.so
    16. extension=mcrypt.so
    复制代码
    然后
    1. vim /etc/php/php-fpm.conf
    复制代码
    去掉注释成这样:
    1. ;listen = 127.0.0.1:9000
    2. listen = /run/php-fpm/php-fpm.sock
    复制代码
    我们用上面的unix格式,目的是为了以后能更好的使用,
    其他的先不做调整
    参考内容有:https://wiki.archlinux.org/index.php/Nginx#Installation_in_a_chroot
    1. vim /etc/php/php.ini
    复制代码
    修改下面的文字,
    1. open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/nginx/html/
    复制代码
    后面加上那行:/usr/share/nginx/html/
    这个是告诉php这个存放php的文件夹可以解析

    然后我们调整Nginx.conf
    1. vim /etc/nginx/nginx.conf #修改成如下的格式
    复制代码
    1. #user html;
    2. worker_processes 1;

    3. error_log /var/log/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;

    6. #pid /var/run/nginx.pid;


    7. events {
    8. worker_connections 1024;
    9. }


    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;

    13. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    14. # '$status $body_bytes_sent "$http_referer" '
    15. # '"$http_user_agent" "$http_x_forwarded_for"';

    16. access_log /var/log/access.log main;

    17. sendfile on;
    18. #tcp_nopush on;

    19. #keepalive_timeout 0;
    20. keepalive_timeout 65;

    21. gzip on;

    22. server {
    23. listen 81;
    24. server_name localhost;

    25. root /usr/share/nginx/html;

    26. #charset koi8-r;
    27. charset utf-8;

    28. #access_log logs/host.access.log main;

    29. location / {
    30. index index.html index.htm;
    31. root /usr/share/nginx/html;
    32. }

    33. #error_page 404 /404.html;

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

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

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

    56. # deny access to .htaccess files, if Apache's document root
    57. # concurs with nginx's one
    58. #
    59. location ~ /\.ht {
    60. deny all;
    61. }
    62. }

    63. 85,0-1 45%
    复制代码
    然后
    1. systemctl enable php-fpm.service
    2. systemctl enable nginx.service
    3. systemctl start php-fpm.service
    4. systemctl start nginx.service
    复制代码
    目的是能让开机启动
    用命令行下的万维网浏览器elinks
    进入elinks,输入http://localhost/hi.php
    显示
    hello world! this is a php script.
    显示完成。PHP环境搭建成功。
    剩下的安装模块,修改php.ini, php-fpm.conf , nginx.conf
    按照用户个人需求来完成。MySQL具体操作,是通过PHP的。当然也可以远程操作。这取决于怎么使用。


    先这样分享给大家吧,祝大家新年快乐!~


    回复

    使用道具 举报

  • TA的每日心情
    无聊
    2014-3-13 15:08
  • 签到天数: 16 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2013-1-2 17:36:50 | 显示全部楼层
    支持。                     
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-11-19 04:23 , Processed in 0.122270 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.