标签:
一,安装mysql
mysql的安装方法
1,数据库初始化
解压 tar -zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
移动并重命名 mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
cd /usr/local/mysql
建立mysql用户 useradd -s /sbin/nologin/ mysql
建立datadir mkdir -p /data/mysql 存放数据的文件 日志也是在这个文件下
修改datadir的属主 chown -R mysql /data/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql 初始化数据库 以查看是否生成2个OK 或者echo $?的值是否为0。
2,拷贝配置文件
cp support-files/mysql-large.cnf /etc/my.cnf
3,拷贝服务文件并添加到服务列表,添加datadir
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld 修改datadir
chkconfig -add mysqld
chkcofnig mysqld on
service mysqld start
二,安装php
1,
cd php-5.4.37
./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 --disable-ipv6 --with-curl
make
makeinstall
2,创建php-fpm用户
useradd -s /sbin/nologin/ php-fpm
3,拷贝配置文件
cp php.ini-production /usr/local/php/etc/php.in
4,,拷贝启动脚本
cp /usr/local/php-5.4.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
mv /usr/local/php/etc/php-fpm.conf.defalut /usr/local/php/etc/php.conf
chmod 755 /etc/init.d
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
三,安装nginx
1,
tar -zxvf nginx-1.6.2.tar.gz
cd nginx 1.6.2
./configure --prefix=/usr/local/nginx/ --with-pcre
make
make install
2,启动nginx
/usr/local/nginx/sbin/nginx
四,测试php解析
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 /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
并且修改fastcgi_param SCRIPT_FILENAME 那一行。
cd /usr/local/nginx/html/
vim 1.php
<?php
phpinfo();
?>
测试: curl localhost/1.php
LNMP搭建
标签:
原文地址:http://www.cnblogs.com/lin1/p/5342490.html