linux 安装开发工具
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 安装开发工具相关的知识,希望对你有一定的参考价值。
在学习linux上旅途中,遇到种种问题,现已解决做下笔记
一 一键安装
[转自]lnmp.org 页面解释的比较详细
安装LNMP稳定版
wget -c http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz
&& tar zxf lnmp1.3-full.tar.gz && cd lnmp1.3-full
&& ./install.sh lnmp
详细请想看 lnmp.org
安装redis等缓存
请看 https://lnmp.org/faq/addons.html
二 yum 安装 [学习于 http://blog.chinaunix.net/uid-26744202-id-5746873.html]
1,安装 epel源 EPEL源作为CENTOS官方源的补充,里边都是一些基础包(https://fedoraproject.org/wiki/EPEL 官网)
- rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
2,安装Remi源,Remi源几乎都是最新稳定版,都是Linux骨灰级大牛维护更新 (http://rpms.famillecollet.com/ 官网)
- rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
3,开始安装php,
-
======================================================================================================================= N/S Matched: php-fpm ========================================================================================================================
-
php-fpm.x86_64 : PHP FastCGI Process Manager
-
php56-php-fpm.x86_64 : PHP FastCGI Process Manager
-
php70-php-fpm.x86_64 : PHP FastCGI Process Manager
- php71-php-fpm.x86_64 : PHP FastCGI Process Manager
php-fpm默认为5.3,此处建议安装PHP56
- yum install --enablerepo=remi php56-php-fpm php56-php-mysqld php56-php-redis
可选择性安装 php56-eaccelerator , 或者 php-pecl-apc ,以及 opcahce 都是PHP加速器。
yum install --enablerepo=remi php56-php-pear php56-php-devel php56-php-opcache
- chkconfig --level 2345 php56-php-fpm on
启动PHP-FPM
- service php56-php-fpm restart
4,安装mysql
- yum -y --enablerepo=remi install mysql mysql-server
- chkconfig --level 2345 mysqld on
- service mysqld start
用 mysql_secure_installation 命令 开始设置mysqld,然后可按照自己喜好修改mysql
配置文件路径 mysql_install_db --defaults-file=/etc/my.cnf (//查看mysql 启动配置文件ps
-ef | grep mysqld)
ps :
默认 mysql 密码为空 直接按回车即可
6,安装并运行 redis
-
yum install --enablerepo=remi redis
-
- service redis start
7,安装nginx
点击(此处)折叠或打开
-
yum install nginx
- service nginx start
修改PHP session 保存方式
vim /opt/remi/php56/root/etc/php-fpm.d/www.conf
找到 session 修改
php_value[session.save_handler] = redis
php_value[session.save_path] = "tcp://127.0.0.1:6379"
最后关闭防火墙
/etc/init.d/iptables stop
如若遇到session 保存不了的情况,请检查session保存目录
#建立session保存目录
mkdir /var/lib/php/session
chmod -R 777 /var/lib/php/session
我在安装mysql的时候出现了问题
- file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
- file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-community-5.1.58-1.rhel5.i386 conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.i686
error Summary 原因是包冲突
解决办法把包全部删掉
yum remove mysql-libs-5.1.52*
删除之后再安装一遍
安装完各种环境以后,第二步要做的就是 让nginx 支持PHP
找到 nginx下的default.conf 找到
-
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-
#
-
#location ~ \.php$ {
-
# root html;
-
# fastcgi_pass 127.0.0.1:9000;
-
# fastcgi_index index.php;
-
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
-
# include fastcgi_params;
- #}
因为nginx默认没有关联PHP,所以此处
将其修改为
-
-
location ~ \.php$ {
-
root /usr/share/nginx/html;
-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
try_files $uri =403;
-
fastcgi_param SCRIPT_FILENAME $request_filename;
-
include fastcgi_params;
- }
-
location ~ \.php$ {
-
然后,将解析所有文件处 加上默认 index.php ,按照先后顺序决定优先解析那种文件
-
location / {
-
root /usr/share/nginx/html;
-
index index.html index.htm;
- }
修改为
-
location / {
-
root /usr/share/nginx/html;
-
index index.php index.html index.htm;
- }
这样 nginx就能解析PHP文件了
另外 此处可加上用socket方式执行php-fpm 来优化速度,具体方式为
找到 php-fpm.d/www.conf 然后 修改其中的
- listen = 127.0.0.1:9000
将其改成
- listen = /tmp/php-fcgi.sock
另外注意 权限问题,默认mode 是 0660 重启php-fpm会没办法读取 fcgi 需改成 0666
;listen.owner = php-fpm
;listen.group = php-fpm
listen.mode = 0666
然后 再在nginx解析PHP修改 fastcgi_pass 执行方式为socket
-
location ~ \.php$ {
-
root /usr/share/nginx/html;
-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
-
fastcgi_pass unix:/tmp/php-fcgi.sock;
-
fastcgi_index index.php;
-
try_files $uri =403;
-
fastcgi_param SCRIPT_FILENAME $request_filename;
-
include fastcgi_params;
- }
这样php-fpm就是以socket方式执行了
上传文件大小
vim /etc/nginx/nginx.conf
client_max_body_size 10M;
以上是关于linux 安装开发工具的主要内容,如果未能解决你的问题,请参考以下文章