Linux下编译安装Nginx+PHP+Mysql方法及步骤

该方法只是大概步骤,

文件安装路径:
nginx:/home/nginx
mysql:/home/mysql
php:/home/php5.6
========================
nginx:
安装依赖包:yum -y install pcre pcre-devel openssl openssl-devel gcc-c++
useradd nginx -s /sbin/nologin -M
./configure –user=nginx –group=nginx –prefix=/home/nginx/ –with-http_stub_status_module –with-http_ssl_module
make && make install

echo “/home/nginx/sbin/nginx” >>/etc/rc.local #开机自启动
=========================
php:

下载php版本和libiconv,
编译安装/usr/local/libiconv
./configure –prefix=/usr/local/libiconv
make && make install
安装依赖包
php编译:
/configure –prefix=/home/php5.6 –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –with-openssl –enable-mbstring –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-sockets –with-mcrypt –with-bz2 –enable-fpm –with-gd –enable-bcmath
make && make install

启动php:/home/php5.6/sbin/php-fpm (将php的运行权限更改为nginx,否则会没有权限解析php)

echo “/home/php5.6/sbin/php-fpm” >>/etc/rc.local  #开机自启动
在nginx站点配置文件中添加如下代码:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
========================
mysql:
下载mysql解压到home目录下,然后执行如下命令初始化mysql
useradd mysql -s /sbin/nologin -M
/home/mysql/scripts/mysql_install_db –basedir=/home/mysql –datadir=/home/mysql/data
/home/mysql/support-files/my-default.cnf /etc/my.cnf
/bin/cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

将配置文件中/usr/local/mysql改成/home/mysql /etc/init.d/mysqld
将配置文件中/usr/local/mysql改成/home/mysql /home/mysql/bin/mysqld_safe
chown mysql.mysql /home/mysql -R
service mysqld restart

echo “export PATH=/home/mysql/bin:$PATH” >>/etc/profile

source /etc/profile

SET PASSWORD FOR root=PASSWORD(west999); 设置root密码
=========================
创建数据库命令:

create database kaoshiba;
grant all privileges on kaoshiba.* to kaoshiba@localhost identified by ‘abc999’;

=========================

西数超哥学习乐园,西数超哥基础运维经验教程分享的学习乐园,西数超哥博客,运维经验教程交流学习分享的博客

原创文章,作者:zhang sir,如若转载,请注明出处:https://www.ysidc.top/7758.html