Home php教程 php手册 ubuntu 10.10 源码安装 nginx php mysql

ubuntu 10.10 源码安装 nginx php mysql

Jun 06, 2016 pm 07:59 PM
m nginx php ubuntu Install Source code

http://forum.ubuntu.org.cn/viewtopic.php?t=319886 鄙人初学乍练,写的不好,大家原谅~今天泡了下午论坛,没找到MYSQL的合适的安装配置教程,只好自己去看官方文档了,着实花了时间, 下列是我的操作过程,写出来,希望对大家能有点帮助。 下载地址,http

http://forum.ubuntu.org.cn/viewtopic.php?t=319886
鄙人初学乍练,写的不好,大家原谅~今天泡了下午论坛,没找到MYSQL的合适的安装配置教程,只好自己去看官方文档了,着实花了时间,
下列是我的操作过程,写出来,希望对大家能有点帮助。

下载地址,http://dev.mysql.com/downloads/mysql/
选择源码下载:source code
文件:mysql-5.5.9.tar.gz
下载后在下载目录
$ sudo tar zxvf mysql-5.5.9.tar.gz
查看文件夹下INSTALL-SOURCE文件,里面有各个系统的编译安装方式(英文)
注意,安装前应当注意安装工具的完善,否则编译的时候将出错,本帖稍后的部分给出了工具列表。这里先给出安装命令。
linux下源码的安装方式如下:

# 安装前配置
shell> groupadd mysql
shell> useradd -r -g mysql mysql

# 开始源码编译安装
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# 结束编译安装

# 初始化,下列命令使mysql得到对数据库文件的拥有权。mysql_install_db脚本能刷新授权表
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# 可选命令,配置文件位置更改,且内有五种配置模式。
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# 可选命令,自启动脚本,可以mysql自动启动。
shell> cp support-files/mysql.server /etc/init.d/mysql.server

会遇到的问题:
----------------------------------------------------------
-- MySQL 5.5.9
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev,on RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:256 (MYSQL_CHECK_READLINE)
----------------------------------------------------------
如回显所示,ubuntu下安装libncurses5-dev;redhat下安装ncurses-devel,并删除当前目录CMakeCache.txt(必须删除,否则报错依旧)并重新运行:
$ cmake .
命令
----------------------------------------------------------
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/downloads/mysql-5.5.9
----------------------------------------------------------
一个警告总算不爽,如回显所见,安装bison。
$ sudo apt-get install bison
----------------------------------------------------------
这是两个比较多的问题。



问题总结:
后来查看了官方的文档,编译安装的时候工具必须要有下列5个。
=>安装工具:
1. cmake
----没有自己编译安装cmake
----shell:~$ sudo apt-get install cmake
----版本:2.8.2
2.GNU make
----Ubuntu自带
----版本:3.81
3.GCC
----Ubuntu自带
----版本:4.4.5(官方文档:必须3.2以上)
4.Perl
----Ubuntu自带
----版本:5.10.1
5.libncurses5-dev (ncurses-devel)
----若差了这个包,在cmake的时候会报错。
----Debian/Ubuntu上的包名是libncurses5-dev,RedHat和其他版本对应的是ncurses-devel
----shell:~$ sudo apt-get install libncurses5-dev




开启mysql:
cd . ; ./bin/mysqld_safe &
当然你用root命令开启的时候,应当使用--user参数,这样才是安全的启动方式。
cd . ; ./bin/mysqld_safe --user=mysql &

为root和你的用户名设置密码,这需要在你先启动mysql的基础上,否则会报错,说你没有连接到端口:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h YourusernamE password 'new-password'
也可一用下命令替代:
./bin/mysql_secure_installation


2、编译安装php-fpm

#相关代码, [四号程序员] http://www.coder4.com
#下载
wget http://us.php.net/distributions/php-5.3.6.tar.bz2
tar -xjvf php-5.3.6.tar.bz2
cd php-5.3.6
 
#相关库
sudo apt-get install libxml2-dev zlib1g-dev libcurl4-openssl-dev libpng12-dev libmcrypt-dev
 
#configure
'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/etc/php' '--disable-cli' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-zlib' '--with-curl' '--with-gd' '--with-mhash' '--enable-mbstring' '--with-mcrypt' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--enable-pdo' '--enable-soap' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--with-pear'
 
#make
make
 
提示出错
/usr/local/mysql/include/mysql/my_sys.h:964:27: error: mysql/psi/psi.h: No such file or directory
/usr/local/mysql/include/mysql/m_string.h:219:26: error: mysql/plugin.h: No such file or directory
/usr/local/mysql/include/plugin.h:51:28: 错误:mysql/services.h:没有那个文件或目录
/usr/local/mysql/include/services.h:21:39: 错误:mysql/service_my_snprintf.h:没有那个文件或目录
/usr/local/mysql/include/services.h:22:37: 错误:mysql/service_thd_alloc.h:没有那个文件或目录
/usr/local/mysql/include/services.h:23:36: 错误:mysql/service_thd_wait.h:没有那个文件或目录
/usr/local/mysql/include/services.h:24:44: 错误:mysql/service_thread_scheduler.h:没有那个文件或目录
#修复MySQL的BUG
mkdir /usr/local/mysql/include/mysql
ln -s /usr/local/mysql/include/* /usr/local/mysql/include/mysql
vi /usr/local/mysql/include/my_sys.h
找到
 #include
修改为
 #include
 
vi /usr/local/mysql/include/m_string.h
找到
 #include
修改为
 #include
vi /usr/local/mysql/include/plugin.h
找到
 #include
修改为
 #include

出现以下错误:
ext/gd/libgd/.libs/gdkanji.o: In function `do_convert':
/root/php-5.2.12/ext/gd/libgd/gdkanji.c:350: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/gd/libgd/gdkanji.c:365: undefined reference to `libiconv'
/root/php-5.2.12/ext/gd/libgd/gdkanji.c:381: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strlen':
/root/php-5.2.12/ext/iconv/iconv.c:603: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:626: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:660: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `php_iconv_string':
/root/php-5.2.12/ext/iconv/iconv.c:441: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:453: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:467: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:478: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strpos':
/root/php-5.2.12/ext/iconv/iconv.c:851: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:879: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:993: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_appendl':
/root/php-5.2.12/ext/iconv/iconv.c:348: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:385: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `_php_iconv_substr':
/root/php-5.2.12/ext/iconv/iconv.c:723: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:747: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:802: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:806: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:755: undefined reference to `libiconv_open'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_decode':
/root/php-5.2.12/ext/iconv/iconv.c:1354: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:1465: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:1468: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:1823: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:1826: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_dtor':
/root/php-5.2.12/ext/iconv/iconv.c:2465: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_encode':
/root/php-5.2.12/ext/iconv/iconv.c:1043: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:1057: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/iconv/iconv.c:1316: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:1319: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:1176: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:1128: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:1160: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:1319: undefined reference to `libiconv_close'
/root/php-5.2.12/ext/iconv/iconv.c:1228: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:1259: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:1303: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_append_bucket':
/root/php-5.2.12/ext/iconv/iconv.c:2615: undefined reference to `libiconv'
/root/php-5.2.12/ext/iconv/iconv.c:2615: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o:/root/php-5.2.12/ext/iconv/iconv.c:2537: more undefined references to `libiconv' follow
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
/root/php-5.2.12/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
ext/xmlrpc/libxmlrpc/.libs/encodings.o: In function `convert':
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] ?.. 1

解决方法:
[root@server3 ~]$ vim Makefile
找到下面这行:
EXTRA_LIBS = -lcrypt   在最后添加-liconv,保存后再make通过,再make install通过。
------------------------------------------------------------------------------------------------------------------------------
EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmhash -lmcrypt -lltdl -lldap -llber -lfreetype -lpng -lz -lj
peg -lcurl -lz -lrt -lresolv -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5
-lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lmysqlclient -lz -lcrypt -lnsl -lm -lxml2 -lz
 -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -liconv
--------------------------------------------------------------------------------------------------------------------------------
make clean
make

#install
sudo make install
 
#user
cd /usr/local/php
useradd www
sudo chown -R www:www ./
 
#拷贝php配置
sudo mkdir -p /etc/php
sudo cp php.ini-production /etc/php/php.ini
 
#配置
sudo vim ./etc/php-fpm.conf
rlimit_files = 1048576
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 100
 
#运行
./sbin/php-fpm
 
#添加到开机启动
ln -s /usr/local/php/sbin/php-fpm /usr/bin/
vim /etc/rc.local
#start php-fpm at start
echo 134217728 > /proc/sys/kernel/shmmax
php-fpm
 
#安装APC
wget http://pecl.php.net/get/APC-3.1.6.tgz
tar -xzvf APC-3.1.6.tgz
cd APC-3.1.6
sudo apt-get install autoconf
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
sudo make install
#编辑
vim /etc/sysconfig/php/php.ini
#修改并添加
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
extension=apc.so
[apc]
apc.enabled = 1
apc.shm_segments = 2
apc.shm_size = 48M

3、编译安装nginx

#下载
wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar -xzvf nginx-0.8.54.tar.gz
 
#安装相关包
sudo apt-get install libpcre3-dev libmhash-dev
 

#nginx http push module

http://pushmodule.slact.net/downloads/nginx_http_push_module-0.692.tar.gz

#nginx chunkin module

https://github.com/agentzh/chunkin-nginx-module/zipball/v0.21


#configure
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --add-module=/home/lost/packet/agentzh-chunkin-nginx-module --with-http_ssl_module --add-module=/home/lost/packet/nginx_http_push_module-0.692
#make
make
#install
sudo make install
cd /usr/local/nginx
sudo chown -R www:www .
 
#配置nginx.conf
sudo vim conf/nginx.conf
#如下
user www www;
worker_processes  2;
 
error_log  /usr/local/nginx/logs/error.log;
pid        /usr/local/nginx/logs/nginx.pid;
 
worker_rlimit_nofile 1048576;
 
events {
    use epoll;
    worker_connections  65535;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    sendfile        on;
    tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  60;
 
    #gzip
    gzip  on;
    gzip_min_length  1k;
    gzip_buffers        4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 6;
    gzip_types  text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
 
    server {
        listen       80;
        server_name  node11.coder4.com;
        root /usr/local/nginx/html;
        access_log  /usr/local/nginx/logs/node11.coder4.com.access.log  main;
 
        location / {
            index  index.php index.html index.htm;
        }
 
        # redirect server error pages to the static page /50x.html
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ /.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi_params;
        }
 
        #deny htaccess
        location ~ //.ht {
            deny  all;
        }
 
        #ip
        location ~ .*/.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
            expires      30d;
            access_log   off;
        }
    }
}
 
#配置fastcgi_params
sudo vim conf/fastcgi_params
#添加一行
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

How to configure cloud server domain name in nginx How to configure cloud server domain name in nginx Apr 14, 2025 pm 12:18 PM

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to check nginx version How to check nginx version Apr 14, 2025 am 11:57 AM

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

How to start nginx server How to start nginx server Apr 14, 2025 pm 12:27 PM

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

See all articles