centos 7编译安装LNMP

前端之家收集整理的这篇文章主要介绍了centos 7编译安装LNMP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. 禁用防火墙

    systemctl disable firewalld

    systemctl stop firewalld

    setenforce 0

  2. 安装pcre库/zlib库

    yum install pcre*zlib*


  3. 编译安装openssl

增加Nginx用户:groupadd Nginx

useradd Nginx -g Nginx

编译安装Nginx:./configure --prefix=/usr/local/Nginx --error-log-path=/var/log/Nginx/error.log --http-log-path=/var/log/Nginx/access.log --user=Nginx --group=Nginx

make && make install


添加Nginx服务

vi /lib/systemd/system/Nginx.service

[Unit]

Description=NginxAfter=network.target

[Service]

Type=forking

ExecStart=/usr/local/Nginx/sbin/Nginx

ExecReload=/usr/local/Nginx/sbin/Nginx -s reload

ExecStop=/usr/local/Nginx/sbin/Nginx -s quit

PrivateTmp=true

[Install]WantedBy=multi-user.target


chmod 745 /lib/systemd/system/Nginx.service


启动Nginx:systemctlenableNginx.service

systemctl start Nginx.service


安装mariadb

yum install mariadb*


启动mariadb

systemctl start mariadb

修改mariadb root密码

MysqL -uroot -p

use MysqL;

update user

set password=password("123456") where user='root';

flush privileges;

exit;


编译安装PHP7环境

yum install libxml2* curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxslt-developenssl-devel


ln -sv /usr/local/openssl/lib/libssl.so /usr/lib64


安装PHP gd JPEG support

wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz

tar -zxf jpegsrc.v9b.tar.gz

cd jpeg-9b/

./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

make && make install


编译安装PHP7

./configure --prefix=/usr/local/PHP --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-MysqLi --with-openssl --with-pcre-regex --with-pdo-MysqL --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip--with-openssl-dir=/usr/local/openssl-1.1.0e--with-jpeg-dir=/usr/local/jpeg


make

make install


配置文件

cp PHP.ini-development /usr/local/PHP/lib/PHP.ini

cp /usr/local/PHP/etc/PHP-fpm.conf.default /usr/local/PHP/etc/PHP-fpm.conf

cp /usr/local/PHP/etc/PHP-fpm.d/www.conf.default /usr/local/PHP/etc/PHP-fpm.d/www.conf

cp -R ./sapi/fpm/PHP-fpm /etc/init.d/PHP-fpm


修改PHP.ini

pdo_MysqL.default_socket=/var/lib/MysqL/MysqL.sock

MysqLi.default_socket = /var/lib/MysqL/MysqL.sock


启动PHP/etc/init.d/PHP-fpm


修改Nginx配置文件


server {

listen 80;

server_name localhost;

#access_log logs/host.access.log main;

location / { root html;

index index.html index.htm index.PHP; }

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; }


检查PHP

vi index.PHP

<?PHP

$conn=MysqLi_connect('localhost','root','123456','MysqL');

if ($conn)

echo "OK";

else

echo "fail";

MysqLi_close($conn);


PHPinfo();

?>

14. 重新加载Nginx

/usr/local/Nginx/sbin/Nginx -s reload

15.查看index.PHP页面显示


16. 安装PHPmyadmin

unzip PHPMyAdmin-4.7.0-all-languages.zip

mv PHPMyAdmin-4.7.0-all-languages /usr/local/Nginx/html/

ln -sv PHPMyAdmin-4.7.0-all-languages pma

cp config.sample.inc.PHP config.inc.PHP

17. 通过 http://localhost/pma访问PHPmyadmin

原文链接:/centos/378094.html

猜你在找的CentOS相关文章