Linux LNMP安装 Nginx-Mysql-Php
2017-04-19 20:46
169 查看
安装Nginx
Nginx需要pcre
下载pcre pcre-8.39.tar.gz
安装pcre
sudo tar -xvf pcre-8.39.tar.gz cd pcre-8.39/
安装到/opt/pcre-8.39/
sudo ./configure --prefix=/opt/pcre-8.39/
报错,缺少C++编译器
configure: error: You need a C++ compiler for C++ support.
可以通过apt工具安装C++编译器
sudo apt-get install build-essential
安装完c++编译器后,继续安装pcre
sudo makesudo make install
接下来可以安装nginx
下载nginx nginx-1.6.2.tar.gz
sudo tar -xvf nginx-1.6.2.tar.gz cd ./nginx-1.6.2/
指定nginx安装目录,与pcre安装的位置
sudo ./configure --prefix=/opt/Nginx/ --with-pcre-opt=/opt/pcre-8.39/sudo makesudo make install
ok,浏览器打开localhost
安装mysql
sudo apt-get install mysql-server-5.7
中间会提示输入root密码
源码安装php7
sudo tar -xjf php-7.0.14.tar.bz2 cd ./php-7.0.14/
nginx需要php-fpm,这样安装php有一些常用模块没有安装,可以通过phpize命令添加模块
./configure --prefix=/opt/php7.0/ --enable-fpmsudo makesudo make install
//将nginx与php联系起来
cd /opt/Nginx/conf/sudo gedit nginx.conf
打开后将方框内的#号去掉,把/scripts改成$document_root 。变成下面这样,
//启动nginx与php-fpm
sudo /opt/Nginx/sbin/nginx -s reloadsudo /opt/php7.0/sbin/php-fpm
[22-Jan-2017 21:09:34] ERROR: failed to open configuration file '/opt/php7.0/etc/php-fpm.conf': No such file or directory (2)
[22-Jan-2017 21:09:34] ERROR: failed to load configuration file '/opt/php7.0/etc/php-fpm.conf'
[22-Jan-2017 21:09:34] ERROR: FPM initialization failed
//启动php-fpm报错,缺少php-fpm.conf ,复制etc/php-fpm.conf.default,到/opt/php7.0/etc/
重命名为php-fpm.conf
sudo cp /opt/php7.0/etc/php-fpm.conf.default /opt/php7.0/etc/php-fpm.conf
//再次启动php-fpm再次报错
[22-Jan-2017 21:14:12] WARNING: Nothing matches the include pattern '/opt/php7.0/etc/php-fpm.d/*.conf' from /opt/php7.0/etc/php-fpm.conf at line 125.
[22-Jan-2017 21:14:12] ERROR: No pool defined. at least one pool section must be specified in config file
[22-Jan-2017 21:14:12] ERROR: failed to post process the configuration
[22-Jan-2017 21:14:12] ERROR: FPM initialization failed
sudo cp /opt/php7.0/etc/php-fpm.d/www.conf.default /opt/php7.0/etc/php-fpm.d/www.confsudo /opt/php7.0/sbin/php-fpm
//再次启动php-fpm再次报错
[22-Jan-2017 21:16:27] ERROR: [pool www] cannot get gid for group 'nobody'
[22-Jan-2017 21:16:27] ERROR: FPM initialization failed
php7与nginx中的用户默认为nobody
id nobody //查看nobody用户
uid=65534(nobody) gid=65534(nogroup) 组=65534(nogroup)
nobody是有用户组的,但却 cannot get gid for group 'nobody',因为/opt/php7.0/etc/php-fpm.d/www.conf配置文件中用户组为nobody,系统中没有这个组,现在修改配置文件,用户组改为系统自带的组 nogroup。
less /etc/passwd
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
sudo gedit /opt/php7.0/etc/php-fpm.d/www.conf
php-fpm可以运行了。
启动nginx与php-fpm
sudo /opt/Nginx/sbin/nginxsudo /opt/php7.0/sbin/php-fpm
访问localhost/index.php
*.html、*.js、等放在Nginx安装目录下的html文件夹,我们可以修改 /opt/Nginx/conf/nginx.conf文件来改变站点
把方框内的 html改为你想要的地址
重启nginx
/opt/Nginx/sbin/nginx -s reload
//php-fpm也得启动
安装好所有东西,打开从window上复制过来的项目,浏览器显示403.,是因为nobody没有权限读取文件
站点下的thinphp的权限,不予许其他用户读取
drwxr-x--- 6 root root 4.0K 1月 25 19:57 thinkphp
可以通过chmod 修改 文件/目录 的权限
sudo chmod -R 755 thinkphp/
drwxr-xr-x 6 root root 4.0K 1月 25 19:57 thinkphp
现在其他用户可以读取thinkphp文件夹了!!!
Linux 严格区分大小写,不要打错了。
Nginx需要pcre
下载pcre pcre-8.39.tar.gz
安装pcre
sudo tar -xvf pcre-8.39.tar.gz cd pcre-8.39/
安装到/opt/pcre-8.39/
sudo ./configure --prefix=/opt/pcre-8.39/
报错,缺少C++编译器
configure: error: You need a C++ compiler for C++ support.
可以通过apt工具安装C++编译器
sudo apt-get install build-essential
安装完c++编译器后,继续安装pcre
sudo makesudo make install
接下来可以安装nginx
下载nginx nginx-1.6.2.tar.gz
sudo tar -xvf nginx-1.6.2.tar.gz cd ./nginx-1.6.2/
指定nginx安装目录,与pcre安装的位置
sudo ./configure --prefix=/opt/Nginx/ --with-pcre-opt=/opt/pcre-8.39/sudo makesudo make install
ok,浏览器打开localhost
安装mysql
sudo apt-get install mysql-server-5.7
中间会提示输入root密码
源码安装php7
sudo tar -xjf php-7.0.14.tar.bz2 cd ./php-7.0.14/
nginx需要php-fpm,这样安装php有一些常用模块没有安装,可以通过phpize命令添加模块
./configure --prefix=/opt/php7.0/ --enable-fpmsudo makesudo make install
//将nginx与php联系起来
cd /opt/Nginx/conf/sudo gedit nginx.conf
打开后将方框内的#号去掉,把/scripts改成$document_root 。变成下面这样,
//启动nginx与php-fpm
sudo /opt/Nginx/sbin/nginx -s reloadsudo /opt/php7.0/sbin/php-fpm
[22-Jan-2017 21:09:34] ERROR: failed to open configuration file '/opt/php7.0/etc/php-fpm.conf': No such file or directory (2)
[22-Jan-2017 21:09:34] ERROR: failed to load configuration file '/opt/php7.0/etc/php-fpm.conf'
[22-Jan-2017 21:09:34] ERROR: FPM initialization failed
//启动php-fpm报错,缺少php-fpm.conf ,复制etc/php-fpm.conf.default,到/opt/php7.0/etc/
重命名为php-fpm.conf
sudo cp /opt/php7.0/etc/php-fpm.conf.default /opt/php7.0/etc/php-fpm.conf
//再次启动php-fpm再次报错
[22-Jan-2017 21:14:12] WARNING: Nothing matches the include pattern '/opt/php7.0/etc/php-fpm.d/*.conf' from /opt/php7.0/etc/php-fpm.conf at line 125.
[22-Jan-2017 21:14:12] ERROR: No pool defined. at least one pool section must be specified in config file
[22-Jan-2017 21:14:12] ERROR: failed to post process the configuration
[22-Jan-2017 21:14:12] ERROR: FPM initialization failed
sudo cp /opt/php7.0/etc/php-fpm.d/www.conf.default /opt/php7.0/etc/php-fpm.d/www.confsudo /opt/php7.0/sbin/php-fpm
//再次启动php-fpm再次报错
[22-Jan-2017 21:16:27] ERROR: [pool www] cannot get gid for group 'nobody'
[22-Jan-2017 21:16:27] ERROR: FPM initialization failed
php7与nginx中的用户默认为nobody
id nobody //查看nobody用户
uid=65534(nobody) gid=65534(nogroup) 组=65534(nogroup)
nobody是有用户组的,但却 cannot get gid for group 'nobody',因为/opt/php7.0/etc/php-fpm.d/www.conf配置文件中用户组为nobody,系统中没有这个组,现在修改配置文件,用户组改为系统自带的组 nogroup。
less /etc/passwd
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
sudo gedit /opt/php7.0/etc/php-fpm.d/www.conf
php-fpm可以运行了。
启动nginx与php-fpm
sudo /opt/Nginx/sbin/nginxsudo /opt/php7.0/sbin/php-fpm
访问localhost/index.php
*.html、*.js、等放在Nginx安装目录下的html文件夹,我们可以修改 /opt/Nginx/conf/nginx.conf文件来改变站点
把方框内的 html改为你想要的地址
重启nginx
/opt/Nginx/sbin/nginx -s reload
//php-fpm也得启动
安装好所有东西,打开从window上复制过来的项目,浏览器显示403.,是因为nobody没有权限读取文件
站点下的thinphp的权限,不予许其他用户读取
drwxr-x--- 6 root root 4.0K 1月 25 19:57 thinkphp
可以通过chmod 修改 文件/目录 的权限
sudo chmod -R 755 thinkphp/
drwxr-xr-x 6 root root 4.0K 1月 25 19:57 thinkphp
现在其他用户可以读取thinkphp文件夹了!!!
Linux 严格区分大小写,不要打错了。
相关文章推荐
- CentOS5下安装配置nginx+fastcgi php+mysql
- 安装Nginx+MySQL+PHP后执行.php程序后产生的错误解决方法:
- ubuntu下安装php+nginx+mysql
- 在CENT OS 上编译安装NGINX+PHP+MYSQL
- 在CentOs 5.1中使用rpm安装NGINX+php+mysql(一)
- 整合freeBSD下nginx+php+mysql安装方案(ports安装)
- 一键安装LNMP(Nginx+mysql+php)
- CentOS 5.5一键安装nginx+mysql+php
- centos安装nginx+mysql+php+fastcgi+memcache最简单方法
- LNMP-Linux下Nginx+MySQL+PHP+phpMyAdmin+eAcelerator一键安装包(2009年11月17日更新)
- 在CentOs 5.1中使用rpm安装NGINX+php+mysql(一)
- xubuntu9.04 安装nginx+mysql+php
- web自动安装脚本(apache/nginx+php+mysql)
- linux,nginx,mysql,php安装备忘
- LNMP Debian/Ubuntu下Nginx+MySQL+PHP+phpMyAdmin+Zend一键安装包
- Ubuntu 9.04/9.10安装Nginx+Mysql+Php
- LNMP-Linux下Nginx+PHP+MySQL+phpMyAdmin+eAcelerator一键安装包
- VPS 快速安装 Linux+Nginx+MySQL+PHP 环境
- LNMP一键安装包 0.5 正式发布(Linux+Nginx+Mysql+PHP)
- nginx+php+memcache+xcache+mysql安装与配置