资讯专栏INFORMATION COLUMN

CentOS LNMP 环境搭建记录

bitkylin / 2939人阅读

*仅供参考,如有不当之处,欢迎批评指正。以下安装过程以 CentOS 5.* 系列为例 *

准备需要的源 1、添加 EPEL 源:

项目地址:http://fedoraproject.org/wiki/EPEL
安装步骤:

</>复制代码

  1. //根据 CentOS 版本不同,下方地址也不同
  2. wget http://ftp.sjtu.edu.cn/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
  3. //安装
  4. rpm -ivh epel-release-5-4.noarch.rpm
2、添加 Remi 源:

项目地址:http://rpms.famillecollet.com/
安装步骤:

</>复制代码

  1. //根据 CentOS 版本不同,下方地址也不同
  2. wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
  3. //安装
  4. rpm -ivh remi-release-5.rpm
  5. //查看 Remi 源的软件列表
  6. yum --disablerepo=* --enablerepo=remi,remi-php55,remi-test list available | less
3、添加 Nginx 官方源:

项目地址:http://nginx.org/en/linux_packages.html#stable
安装步骤:

</>复制代码

  1. //根据 CentOS 版本不同,下方地址也不同
  2. wget http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
  3. //安装
  4. rpm -ivh nginx-release-centos-5-0.el5.ngx.noarch.rpm
4、添加 MySQL 官方源:

项目地址:https://dev.mysql.com/downloads/repo/yum/
安装步骤:

</>复制代码

  1. //根据 CentOS 版本不同,下方地址也不同
  2. wget https://dev.mysql.com/get/mysql-community-release-el5-5.noarch.rpm --no-check-certificate
  3. //安装
  4. rpm -ivh mysql-community-release-el5-5.noarch.rpm
  5. //查看 MySQL 源的软件列表
  6. yum --disablerepo=* --enablerepo=mysql56-community list available | less
安装 安装 PHP

</>复制代码

  1. yum --enablerepo=remi,remi-php56,epel install php
安装 PHP 相关扩展

</>复制代码

  1. yum --enablerepo=remi,remi-php56,epel install php-gd php-mcrypt php-mbstring php-mysql php-pecl-memcached php-fpm
安装 Nginx

</>复制代码

  1. yum --disablerepo=* --enablerepo=nginx install nginx
安装 MySQL

</>复制代码

  1. yum --disablerepo=* --enablerepo=mysql56-community install mysql mysql-server
相关配置 MySQL 参考配置

</>复制代码

  1. [mysqld]
  2. datadir=/var/lib/mysql
  3. socket=/var/lib/mysql/mysql.sock
  4. character-set-server=utf8
  5. skip-name-resolve
  6. slow_query_log=1
  7. slow_query_log_file=/var/log/mysql/slowquery.log
  8. log-queries-not-using-indexes=on #记录没有使用索引的查询
  9. server-id=3
  10. log-bin=mysql-bin
  11. expire_logs_days = 10
  12. # Disabling symbolic-links is recommended to prevent assorted security risks
  13. symbolic-links=0
  14. # Settings user and group are ignored when systemd is used (fedora >= 15).
  15. # If you need to run mysqld under a different user or group,
  16. # customize your systemd unit file for mysqld according to the
  17. # instructions in http://fedoraproject.org/wiki/Systemd
  18. user=mysql
  19. # Semisynchronous Replication
  20. # http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
  21. # uncomment next line on MASTER
  22. ;plugin-load=rpl_semi_sync_master=semisync_master.so
  23. # uncomment next line on SLAVE
  24. ;plugin-load=rpl_semi_sync_slave=semisync_slave.so
  25. # Others options for Semisynchronous Replication
  26. ;rpl_semi_sync_master_enabled=1
  27. ;rpl_semi_sync_master_timeout=10
  28. ;rpl_semi_sync_slave_enabled=1
  29. # http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
  30. ;performance_schema
  31. #innodb
  32. innodb_file_per_table=1
  33. innodb_flush_log_at_trx_commit=2
  34. innodb_buffer_pool_size=1G
  35. innodb_log_buffer_size=16M
  36. innodb_log_file_size=128M
  37. back_log=100
  38. max_connections=1200
  39. max_allowed_packet=2M
  40. max_heap_table_size=64M
  41. sort_buffer_size=16M
  42. join_buffer_size=16M
  43. thread_cache_size=16
  44. tmp_table_size=64M
  45. key_buffer_size=64M
  46. read_rnd_buffer_size=16M
  47. bulk_insert_buffer_size=128M
  48. myisam_sort_buffer_size=128M
  49. myisam_recover
  50. [mysqld_safe]
  51. log-error=/var/log/mysqld.log
  52. pid-file=/var/run/mysqld/mysqld.pid
  53. #
  54. # include all files from the config directory
  55. #
  56. !includedir /etc/my.cnf.d
Nginx PATHINFO 参考配置片段

</>复制代码

  1. server {
  2. listen 80;
  3. server_name top.qimai.net;
  4. root /usr/share/nginx/html/appstore;
  5. location / {
  6. root /usr/share/nginx/html/appstore;
  7. index index.php index.html index.htm;
  8. }
  9. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  10. location ~ [^/].php(/|$) {
  11. fastcgi_index index.php;
  12. fastcgi_split_path_info ^(.+.php)(.*)$;
  13. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  14. fastcgi_param PATH_INFO $fastcgi_path_info;
  15. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  16. fastcgi_pass unix:/var/run/php5-fpm.sock;
  17. include fastcgi_params;
  18. }
  19. }

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/17370.html

相关文章

  • CentOS LNMP 环境搭建记录

    *仅供参考,如有不当之处,欢迎批评指正。以下安装过程以 CentOS 5.* 系列为例 * 准备需要的源 1、添加 EPEL 源: 项目地址:http://fedoraproject.org/wiki/EPEL 安装步骤: //根据 CentOS 版本不同,下方地址也不同 wget http://ftp.sjtu.edu.cn/fedora/epel/5/i386/epel-release...

    Me_Kun 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<