lnmp 编译安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/black_little_/article/details/83055838

lnmp 前期需要安装相关服务

yum install pcre  gd gd2 gd-devel gd2-devel cmake wget 
yum install openssl*
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make

php需要安装libmcrypt服务

wget -O libmcrypt-2.5.8.tar.gz http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install

nginx 安装

wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/usr/local/nginx
make && make install

/usr/local/nginx/sbin/nginx      //开启nginx

安装netstat查看防火墙状态

yum install net-tools   
firewall-cmd --query-port=80/tcp    //查询端口号80 是否开启
firewall-cmd --permanent --zone=public --add-port=80/tcp             //永久开放80端口号
firewall-cmd --permanent --zone=public --remove-port=80/tcp        //移除80端口号

systemctl status firewalld.service    //查看防火墙状态
systemctl [start|stop|restart] firewalld.service     //启动|关闭|重新启动  防火墙

安装mysql

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.23.tar.gz

tar -zxvf mysql-boost-5.7.10.tar.gz
cd mysql-5.7.10

groupadd mysql 
useradd -g mysql mysql
mkdir -p /var/mysql/
mkdir -p /var/mysql/data/
mkdir -p /var/mysql/log/
chown mysql.mysql -R /var/mysql/


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/var/mysql/data \
-DWITH_BOOST=/root/mysql-5.7.23/boost/boost_1_59_0   \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DMYSQL_USER=mysql

make && make install 

配置
mv /etc/my.cnf /etc/my.cnf-`date +%F` 
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20

加入运行环境

echo pathmunge /usr/local/mysql/bin after > /etc/profile.d/mysql.sh 
. /etc/profile

开机启动
chmod 755 /etc/init.d/mysqld 
chkconfig --add mysqld
chkconfig --level 345 mysqld on

初始化mysql
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/var/mysql/data

开启mysql
/etc/init.d/mysqld start 
service mysqld restart

PHP7.0 安装包

wget http://cn2.php.net/get/php-7.0.32.tar.gz/from/this/mirror
tar -zxvf mirror
cd php-7.0.32/
 //安装mysql后
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mcrypt=/usr/local/libmcrypt --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg9 --with-freetype-dir=/usr/local/freetype --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype
//没有安装mysql
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mcrypt=/usr/local/libmcrypt --with-gd --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg9 --with-freetype-dir=/usr/local/freetype --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype

make && make install

cp php.ini-production /usr/local/php/etc/php.ini

ln -s /usr/local/php/etc/php.ini /etc/php.ini

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

vi /usr/local/php/etc/php-fpm.conf

取消前面的分号保存退出     pid = run/php-fpm.pid 

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

php-fpm常用命令

/usr/local/php/sbin/php-fpm -c /etc/php.ini      启动php-fpm

kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`        重启php-fpm

 kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid`         关闭php-fpm

nginx404解决方法
fastcgi_param SCRIPT_FILENAME d o c u m e n t r o o t document_root fastcgi_script_name;

猜你喜欢

转载自blog.csdn.net/black_little_/article/details/83055838