标签:
LNMP就是Linux nginx mysql php
一、mysql
下载安装mysql转至 LAMP (点击“LAMP”即可跳转)
也可以从快照跳转至mysql安装ok
二、php
下载同上,
1.安装
cd /usr/local/src/
tar zxvf php-5.6.9.tar.gz
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd--with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl
把lamp的错误解决方法yum安装完之后,新的错误解决方法
错误1
configure: error: no acceptable C compiler found in $PATH 配置:错误:不接受C编译器中发现路径
解决
yum install gcc -y
错误2
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/ 配置:错误:请重新安装libcurl分布- 一件容易的事。在< curl-dir > / h应该包括/卷/ 解决 yum -y install curl-devel
echo $?
make
echo $?
make install
echo $?
make install 之前,如果已经安装过在php,同样指定的目录位/usr/local/php,可以把原来的删掉,or,挪个位置。
2.配置文件,启动脚本
cp php.ini-production /usr/local/php/etc/php.ini
配置文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
启动脚本
chmod 755 !$
执行权限
chkconfig --add php-fpm chkconfig php-fpm on
开机启动
cd /usr/local/php/etc/ mv php-fpm.conf.default php-fpm.conf
配置文件
useradd -s /sbin/nologin -M php-fpm
用户,编译的时候指定的user group
service php-fpm start
启动
拍摄快照:备注LNMP php安装ok
php安装成功
三、nginx
1.下载
cd /usr/local/src/
wget http://mirrors.sohu.com/nginx/nginx-1.9.8.tar.gz
2.安装
tar zxvf nginx-1.9.8.tar.gz
./configure --prefix=/usr/local/nginx --with-pcre
pcre 正则
错误1
./configure: error: the HTTP rewrite module requires the PCRE library. 。/配置:错误:HTTP重写模块需要PCRE库。 解决 yum -y install pcre-devel
echo $? make echo $? make install echo $?
3.启动
/usr/local/nginx/sbin/nginx
nginx安装ok
php和nginx不能联系到一起,需要手动修改配置文件。
1.nginx
vim /usr/local/nginx/conf/nginx.conf
找到 #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; #} 改为
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
2.防火墙
vim /etc/selinux/config 找到 SELINUX=enforcing 改为 SELINUX=disabled
setenforce 0
iptables -F
service iptables save
详细说明见 LAMP 四、php 8-9小节
3.浏览器访问
192.168.1.116
Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx.
4.测试解析php
vim /usr/local/nginx/html/info.php
<?php
phpinfo();
?>
http://192.168.1.116/info.php
标签:
原文地址:http://www.cnblogs.com/wangshaojun/p/5136982.html